Skip to content

Commit fe16c61

Browse files
committed
feat: Implement dialog button for notifications
1 parent 1ff6eca commit fe16c61

File tree

4 files changed

+53
-2
lines changed

4 files changed

+53
-2
lines changed

Source/Menu/MainForm.cs

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -545,6 +545,11 @@ void testingToolStripMenuItem_Click(object sender, EventArgs e)
545545
}
546546

547547
void buttonOptions_Click(object sender, EventArgs e)
548+
{
549+
ShowOptionsDialog();
550+
}
551+
552+
public void ShowOptionsDialog()
548553
{
549554
SaveOptions();
550555

@@ -562,7 +567,15 @@ void buttonOptions_Click(object sender, EventArgs e)
562567
}
563568
}
564569
}
565-
570+
571+
public void ShowTelemetryDialog()
572+
{
573+
using (var telemetryForm = new TelemetryForm(TelemetryManager))
574+
{
575+
telemetryForm.ShowDialog(this);
576+
}
577+
}
578+
566579
void buttonDownloadContent_Click(object sender, EventArgs e)
567580
{
568581
using (var form = new ContentForm(Settings, BaseDocumentationUrl))

Source/Menu/Notifications/NotificationManager.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -392,6 +392,10 @@ private void AddItemToPage(NotificationPage page, Item item)
392392
Page.NDetailList.Add(new NLinkControl(Page, item.Label, item.Indent, link.Value, MainForm, url));
393393
}
394394
}
395+
else if (item is Dialog dialog)
396+
{
397+
Page.NDetailList.Add(new NDialogControl(Page, item.Label, item.Indent, dialog.Value, MainForm, dialog.Form));
398+
}
395399
else if (item is Update update)
396400
{
397401
Page.NDetailList.Add(new NUpdateControl(Page, item.Label, item.Indent, update.Value, MainForm));

Source/Menu/Notifications/NotificationPage.cs

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,8 @@ private void AddPageCountAndArrows(NotificationManager manager)
8080
Panel.Controls.Add(pageCountControl);
8181
}
8282

83-
public class Arrow : Button {
83+
public class Arrow : Button
84+
{
8485
public Arrow(Panel panel, Image image, bool visible, bool enabled, int indentRight)
8586
{
8687
Margin = new Padding(0);
@@ -182,8 +183,10 @@ public class NButtonControl : NDetail
182183
{
183184
public static int ButtonCount = 0;
184185
public Button Button;
186+
protected MainForm MainForm;
185187
public NButtonControl(Panel panel, string legend, int width, string description, MainForm mainForm)
186188
{
189+
MainForm = mainForm;
187190
var buttonLeft = LeftPaddingIndented;
188191
Button = new Button
189192
{
@@ -244,6 +247,30 @@ public NLinkControl(NotificationPage page, string legend, int width, string desc
244247
ButtonCount++;
245248
}
246249
}
250+
public class NDialogControl : NButtonControl
251+
{
252+
public string Form;
253+
public NDialogControl(NotificationPage page, string legend, int width, string description, MainForm mainForm, string form)
254+
: base(page.Panel, legend, width, description, mainForm)
255+
{
256+
Form = form;
257+
page.ButtonDictionary.Add(ButtonCount, this);
258+
ButtonCount++;
259+
}
260+
261+
public void Show()
262+
{
263+
switch (Form)
264+
{
265+
case "OptionsForm":
266+
MainForm.ShowOptionsDialog();
267+
break;
268+
case "TelemetryForm":
269+
MainForm.ShowTelemetryDialog();
270+
break;
271+
}
272+
}
273+
}
247274
public class NUpdateControl : NButtonControl
248275
{
249276
public NUpdateControl(NotificationPage page, string legend, int width, string description, MainForm mainForm)
@@ -267,6 +294,8 @@ public void DoButton(UpdateManager updateManager, int key)
267294
var button = ButtonDictionary[key];
268295
if (button is NLinkControl)
269296
Process.Start(((NLinkControl)button).Url);
297+
else if (button is NDialogControl dialogControl)
298+
dialogControl.Show();
270299
else if (button is NUpdateControl)
271300
updateManager.Update();
272301
else if (button is NRetryControl)

Source/Menu/Notifications/Notifications.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,11 @@ class Link : Item
6060
public string TestingUrl { get; set; }
6161
public string UnstableUrl { get; set; }
6262
}
63+
class Dialog : Item
64+
{
65+
public string Value { get; set; }
66+
public string Form { get; set; }
67+
}
6368
class Update : Item
6469
{
6570
public string Value { get; set; }

0 commit comments

Comments
 (0)