-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAboutForm.cs
More file actions
184 lines (164 loc) · 7.24 KB
/
AboutForm.cs
File metadata and controls
184 lines (164 loc) · 7.24 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
using System;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Windows.Forms;
namespace AudioSwitcher;
public class AboutForm : Form
{
public AboutForm(AppSettings settings, AudioDeviceService audioService)
{
Text = "About Audio Switcher";
Size = new Size(420, 430);
StartPosition = FormStartPosition.CenterScreen;
FormBorderStyle = FormBorderStyle.FixedDialog;
MaximizeBox = false;
MinimizeBox = false;
BackColor = Color.FromArgb(24, 24, 28);
// ── Logo panel (custom painted) ────────────────────────
var logoPanel = new Panel
{
Location = new Point(0, 0),
Size = new Size(420, 120),
BackColor = Color.Transparent
};
logoPanel.Paint += (_, e) => DrawLogo(e.Graphics, logoPanel.ClientRectangle);
Controls.Add(logoPanel);
// ── App name ───────────────────────────────────────────
Controls.Add(new Label
{
Text = "Audio Switcher",
Font = new Font("Segoe UI", 18f, FontStyle.Bold),
ForeColor = Color.White,
TextAlign = ContentAlignment.MiddleCenter,
Location = new Point(0, 125),
Size = new Size(420, 36),
BackColor = Color.Transparent
});
// ── Version ────────────────────────────────────────────
Controls.Add(new Label
{
Text = "v2.1.0",
Font = new Font("Segoe UI", 10f),
ForeColor = Color.FromArgb(140, 140, 140),
TextAlign = ContentAlignment.MiddleCenter,
Location = new Point(0, 160),
Size = new Size(420, 22),
BackColor = Color.Transparent
});
// ── Author ─────────────────────────────────────────────
Controls.Add(new Label
{
Text = "by Joshua Underwood",
Font = new Font("Segoe UI", 10f),
ForeColor = Color.FromArgb(180, 180, 180),
TextAlign = ContentAlignment.MiddleCenter,
Location = new Point(0, 186),
Size = new Size(420, 22),
BackColor = Color.Transparent
});
// ── Vibe coded credit ──────────────────────────────────
Controls.Add(new Label
{
Text = "\u2728 Vibe coded with Claude Opus",
Font = new Font("Segoe UI", 9f, FontStyle.Italic),
ForeColor = Color.FromArgb(160, 130, 220),
TextAlign = ContentAlignment.MiddleCenter,
Location = new Point(0, 212),
Size = new Size(420, 20),
BackColor = Color.Transparent
});
// ── GitHub link ────────────────────────────────────────
var ghLink = new LinkLabel
{
Text = "github.com/junderw52/AudioSwitcher",
Font = new Font("Segoe UI", 8.5f),
ForeColor = Color.FromArgb(100, 140, 255),
LinkColor = Color.FromArgb(100, 140, 255),
ActiveLinkColor = Color.FromArgb(140, 170, 255),
TextAlign = ContentAlignment.MiddleCenter,
Location = new Point(0, 234),
Size = new Size(420, 18),
BackColor = Color.Transparent
};
ghLink.LinkClicked += (_, _) =>
{
System.Diagnostics.Process.Start(new System.Diagnostics.ProcessStartInfo
{
FileName = "https://github.com/junderw52/AudioSwitcher",
UseShellExecute = true
});
};
Controls.Add(ghLink);
// ── Divider ────────────────────────────────────────────
var divider = new Panel
{
Location = new Point(40, 262),
Size = new Size(340, 1),
BackColor = Color.FromArgb(60, 60, 65)
};
Controls.Add(divider);
// ── Current config status ──────────────────────────────
string hotkey = HotkeyPickerForm.FormatHotkey(
settings.HotkeyModifiers, (Keys)settings.HotkeyKey);
var devices = audioService.GetPlaybackDevices();
string devA = devices.Find(d => d.Id == settings.DeviceA).Name ?? "(not set)";
string devB = devices.Find(d => d.Id == settings.DeviceB).Name ?? "(not set)";
string status = $"Hotkey: {hotkey}\n"
+ $"Device 1: {devA}\n"
+ $"Device 2: {devB}";
Controls.Add(new Label
{
Text = status,
Font = new Font("Segoe UI", 9f),
ForeColor = Color.FromArgb(160, 160, 160),
TextAlign = ContentAlignment.TopCenter,
Location = new Point(20, 272),
Size = new Size(380, 60),
BackColor = Color.Transparent
});
// ── Close button ───────────────────────────────────────
var closeBtn = new Button
{
Text = "Close",
Font = new Font("Segoe UI", 9f),
Size = new Size(90, 32),
Location = new Point(165, 340),
FlatStyle = FlatStyle.Flat,
ForeColor = Color.White,
BackColor = Color.FromArgb(55, 55, 60),
DialogResult = DialogResult.OK
};
closeBtn.FlatAppearance.BorderColor = Color.FromArgb(80, 80, 85);
Controls.Add(closeBtn);
AcceptButton = closeBtn;
CancelButton = closeBtn;
}
private static void DrawLogo(Graphics g, Rectangle bounds)
{
g.SmoothingMode = SmoothingMode.AntiAlias;
int cx = bounds.Width / 2;
int cy = bounds.Height / 2 + 5;
float scale = 3.5f;
using var gradBrush = new LinearGradientBrush(
new Point(cx - 30, cy - 30), new Point(cx + 30, cy + 30),
Color.FromArgb(100, 140, 255), Color.FromArgb(180, 100, 255));
// Speaker body
var body = new PointF[]
{
new(cx - 14 * scale / 2, cy - 3 * scale),
new(cx - 8 * scale / 2, cy - 3 * scale),
new(cx - 2 * scale / 2, cy - 7 * scale),
new(cx - 2 * scale / 2, cy + 7 * scale),
new(cx - 8 * scale / 2, cy + 3 * scale),
new(cx - 14 * scale / 2, cy + 3 * scale)
};
g.FillPolygon(gradBrush, body);
// Sound waves
using var pen1 = new Pen(Color.FromArgb(200, 100, 140, 255), 2.5f);
using var pen2 = new Pen(Color.FromArgb(150, 140, 120, 255), 2.2f);
using var pen3 = new Pen(Color.FromArgb(100, 180, 100, 255), 1.8f);
g.DrawArc(pen1, cx + 2, cy - 14, 14, 28, -50, 100);
g.DrawArc(pen2, cx + 8, cy - 20, 18, 40, -45, 90);
g.DrawArc(pen3, cx + 14, cy - 26, 22, 52, -40, 80);
}
}