-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathWelcomeDialog.cs
More file actions
317 lines (278 loc) · 12.2 KB
/
Copy pathWelcomeDialog.cs
File metadata and controls
317 lines (278 loc) · 12.2 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
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
using System.Windows;
using System.Windows.Controls;
using System.Windows.Media;
using System.Windows.Media.Effects;
using System.Windows.Media.Imaging;
namespace AmpUp;
/// <summary>
/// First-run welcome dialog. Shown once when HasCompletedSetup is false.
/// Pure code-behind window — no XAML file.
/// </summary>
public class WelcomeDialog : Window
{
private readonly Action _onOpenSettings;
private readonly Action? _onImport;
public WelcomeDialog(Action onOpenSettings, Action? onImport = null)
{
_onOpenSettings = onOpenSettings;
_onImport = onImport;
AllowsTransparency = true;
WindowStyle = WindowStyle.None;
Background = Brushes.Transparent;
ResizeMode = ResizeMode.NoResize;
ShowInTaskbar = false;
Width = 480;
SizeToContent = SizeToContent.Height;
WindowStartupLocation = WindowStartupLocation.CenterScreen;
Content = BuildContent();
}
private UIElement BuildContent()
{
var accent = ThemeManager.Accent;
var outer = new Border
{
CornerRadius = new CornerRadius(14),
Background = new SolidColorBrush(Color.FromArgb(250, 0x0F, 0x0F, 0x0F)),
BorderBrush = new SolidColorBrush(Color.FromArgb(0x44,
accent.R, accent.G, accent.B)),
BorderThickness = new Thickness(1),
Effect = new DropShadowEffect
{
Color = Colors.Black,
BlurRadius = 32,
ShadowDepth = 6,
Opacity = 0.8,
Direction = 270
},
Margin = new Thickness(12)
};
var root = new StackPanel { Margin = new Thickness(32, 28, 32, 28) };
outer.Child = root;
// Header with logo
var headerRow = new StackPanel { Orientation = Orientation.Horizontal, Margin = new Thickness(0, 0, 0, 6) };
try
{
var logo = new Image
{
Source = new BitmapImage(new System.Uri("pack://application:,,,/Assets/icon/ampup-64.png")),
Width = 42,
Height = 42,
Margin = new Thickness(0, 0, 12, 0),
VerticalAlignment = VerticalAlignment.Center
};
headerRow.Children.Add(logo);
}
catch { /* icon not found, skip */ }
headerRow.Children.Add(new TextBlock
{
Text = "Welcome to Amp Up",
Foreground = new SolidColorBrush(Color.FromRgb(0xE8, 0xE8, 0xE8)),
FontSize = 22,
FontWeight = FontWeights.Bold,
VerticalAlignment = VerticalAlignment.Center
});
root.Children.Add(headerRow);
root.Children.Add(new TextBlock
{
Text = "Let's get your AmpUp hardware connected in a few steps.",
Foreground = new SolidColorBrush(Color.FromRgb(0xB0, 0xB0, 0xB0)),
FontSize = 13,
Margin = new Thickness(0, 0, 0, 24),
TextWrapping = TextWrapping.Wrap
});
// Separator
root.Children.Add(new Border
{
Height = 1,
Background = new SolidColorBrush(Color.FromArgb(0x22, 0xFF, 0xFF, 0xFF)),
Margin = new Thickness(0, 0, 0, 20)
});
// Steps with colored icon circles
root.Children.Add(BuildStep("1", "Connect your hardware",
"Plug in the USB cable. Windows will install the driver automatically.",
Color.FromRgb(0x00, 0xE6, 0x76))); // green
root.Children.Add(BuildStepWithButton("2", "Find your device",
"Head to Settings → click Auto-Detect to find your device.",
"Open Settings", accent, () =>
{
_onOpenSettings();
Close();
}, Color.FromRgb(0x00, 0xB0, 0xFF))); // blue
root.Children.Add(BuildStepWithButton("3", "Import from Turn Up",
"Already have a Turn Up config? Import your knob assignments, button bindings, and light settings.",
"Import Config", accent, () =>
{
_onImport?.Invoke();
Close();
}, Color.FromRgb(0xFF, 0xB8, 0x00))); // amber
root.Children.Add(BuildStep("4", "Assign your knobs",
"In the Mixer tab, pick what each knob controls — master volume, Spotify, Discord, anything.",
Color.FromRgb(0xE0, 0x40, 0xFF))); // purple
root.Children.Add(BuildStep("5", "Set up your lights",
"Head to Lights to pick effects and colors for each knob's RGB.",
Color.FromRgb(0x00, 0xB0, 0xFF))); // blue
root.Children.Add(BuildStep("6", "Configure your buttons",
"Assign actions to each button — macros, mute toggles, profile switches, and more.",
Color.FromRgb(0xFF, 0x44, 0x44))); // red
// Bottom separator
root.Children.Add(new Border
{
Height = 1,
Background = new SolidColorBrush(Color.FromArgb(0x22, 0xFF, 0xFF, 0xFF)),
Margin = new Thickness(0, 20, 0, 20)
});
// Got it button (full-width, accent, properly rounded)
var gotItBorder = new Border
{
CornerRadius = new CornerRadius(8),
Background = new SolidColorBrush(Color.FromRgb(accent.R, accent.G, accent.B)),
Cursor = System.Windows.Input.Cursors.Hand,
Padding = new Thickness(0, 14, 0, 14),
HorizontalAlignment = HorizontalAlignment.Stretch,
Child = new TextBlock
{
Text = "Got it, let's go!",
Foreground = new SolidColorBrush(Color.FromRgb(0x0F, 0x0F, 0x0F)),
FontSize = 14,
FontWeight = FontWeights.Bold,
HorizontalAlignment = HorizontalAlignment.Center
}
};
var normalBg = Color.FromRgb(accent.R, accent.G, accent.B);
var hoverBg = Color.FromRgb(
(byte)Math.Min(255, accent.R + 25),
(byte)Math.Min(255, accent.G + 25),
(byte)Math.Min(255, accent.B + 25));
gotItBorder.MouseEnter += (_, _) => gotItBorder.Background = new SolidColorBrush(hoverBg);
gotItBorder.MouseLeave += (_, _) => gotItBorder.Background = new SolidColorBrush(normalBg);
gotItBorder.MouseLeftButtonUp += (_, _) => Close();
root.Children.Add(gotItBorder);
return outer;
}
private static UIElement BuildStep(string icon, string title, string description,
Color iconColor = default)
{
return BuildStepCore(icon, title, description, null, default, null, iconColor);
}
private static UIElement BuildStepWithButton(string icon, string title, string description,
string btnText, Color accent, Action onClick, Color iconColor = default)
{
return BuildStepCore(icon, title, description, btnText, accent, onClick, iconColor);
}
private static UIElement BuildStepCore(string icon, string title, string description,
string? btnText, Color accent, Action? onClick, Color iconColor = default)
{
var row = new DockPanel { Margin = new Thickness(0, 0, 0, 16) };
// Icon — colored circle with text symbol
var iconCircle = new Border
{
Width = 36,
Height = 36,
CornerRadius = new CornerRadius(18),
Background = new SolidColorBrush(iconColor == default
? Color.FromArgb(0x20, 0x00, 0xE6, 0x76)
: Color.FromArgb(0x20, iconColor.R, iconColor.G, iconColor.B)),
VerticalAlignment = VerticalAlignment.Top,
Margin = new Thickness(0, 2, 12, 0),
Child = new TextBlock
{
Text = icon,
FontSize = 16,
Foreground = new SolidColorBrush(iconColor == default
? Color.FromRgb(0x00, 0xE6, 0x76)
: iconColor),
HorizontalAlignment = HorizontalAlignment.Center,
VerticalAlignment = VerticalAlignment.Center,
FontWeight = FontWeights.Bold
}
};
DockPanel.SetDock(iconCircle, Dock.Left);
row.Children.Add(iconCircle);
var textStack = new StackPanel();
textStack.Children.Add(new TextBlock
{
Text = title,
Foreground = new SolidColorBrush(Color.FromRgb(0xE8, 0xE8, 0xE8)),
FontSize = 13,
FontWeight = FontWeights.SemiBold,
Margin = new Thickness(0, 0, 0, 3)
});
textStack.Children.Add(new TextBlock
{
Text = description,
Foreground = new SolidColorBrush(Color.FromRgb(0xB0, 0xB0, 0xB0)),
FontSize = 12,
TextWrapping = TextWrapping.Wrap,
Margin = new Thickness(0, 0, 0, btnText != null ? 8 : 0)
});
if (btnText != null && onClick != null)
{
var btn = new Button
{
Content = btnText,
Background = new SolidColorBrush(Color.FromArgb(0x20,
accent.R, accent.G, accent.B)),
Foreground = new SolidColorBrush(Color.FromRgb(accent.R, accent.G, accent.B)),
BorderBrush = new SolidColorBrush(Color.FromArgb(0x50,
accent.R, accent.G, accent.B)),
BorderThickness = new Thickness(1),
FontSize = 12,
Padding = new Thickness(14, 6, 14, 6),
Cursor = System.Windows.Input.Cursors.Hand,
HorizontalAlignment = HorizontalAlignment.Left
};
btn.Style = CreateOutlineButtonStyle(accent);
btn.Click += (_, _) => onClick();
textStack.Children.Add(btn);
}
row.Children.Add(textStack);
return row;
}
private static Style CreateButtonStyle(System.Windows.Media.Color accent)
{
var style = new Style(typeof(Button));
style.Setters.Add(new Setter(Button.TemplateProperty, CreateBtnTemplate(
Color.FromRgb(accent.R, accent.G, accent.B),
Color.FromRgb(
(byte)Math.Min(255, accent.R + 30),
(byte)Math.Min(255, accent.G + 30),
(byte)Math.Min(255, accent.B + 30)),
Color.FromRgb(0x0F, 0x0F, 0x0F))));
return style;
}
private static Style CreateOutlineButtonStyle(System.Windows.Media.Color accent)
{
var style = new Style(typeof(Button));
style.Setters.Add(new Setter(Button.TemplateProperty, CreateBtnTemplate(
Color.FromArgb(0x20, accent.R, accent.G, accent.B),
Color.FromArgb(0x35, accent.R, accent.G, accent.B),
Color.FromRgb(accent.R, accent.G, accent.B))));
return style;
}
private static System.Windows.Controls.ControlTemplate CreateBtnTemplate(
System.Windows.Media.Color normalBg,
System.Windows.Media.Color hoverBg,
System.Windows.Media.Color fg)
{
var template = new System.Windows.Controls.ControlTemplate(typeof(Button));
var borderFactory = new FrameworkElementFactory(typeof(Border));
borderFactory.SetValue(Border.CornerRadiusProperty, new CornerRadius(6));
borderFactory.SetValue(Border.BackgroundProperty,
new SolidColorBrush(normalBg));
var cpFactory = new FrameworkElementFactory(typeof(ContentPresenter));
cpFactory.SetValue(ContentPresenter.HorizontalAlignmentProperty, HorizontalAlignment.Center);
cpFactory.SetValue(ContentPresenter.VerticalAlignmentProperty, VerticalAlignment.Center);
borderFactory.AppendChild(cpFactory);
template.VisualTree = borderFactory;
// Hover trigger
var trigger = new Trigger { Property = Button.IsMouseOverProperty, Value = true };
trigger.Setters.Add(new Setter(Border.BackgroundProperty,
new SolidColorBrush(hoverBg), "PART_Border"));
// Can't easily target the border by name in simple template — use style triggers instead
var triggerBg = new Trigger { Property = Button.IsMouseOverProperty, Value = true };
triggerBg.Setters.Add(new Setter(Border.BackgroundProperty,
new SolidColorBrush(hoverBg)));
template.Triggers.Add(triggerBg);
return template;
}
}