2 using System.Collections.Generic;
\r
3 using System.Windows.Forms;
\r
5 namespace KancolleSniffer
\r
7 public partial class NotificationConfigDialog : Form
\r
9 private readonly Dictionary<string, NotificationType> _notifications;
\r
10 private readonly Dictionary<NotificationType, CheckBox> _configCheckBoxs;
\r
12 public NotificationConfigDialog(Dictionary<string, NotificationType> notifications, Dictionary<NotificationType, CheckBox> checkBoxs)
\r
14 InitializeComponent();
\r
15 _notifications = notifications;
\r
16 _configCheckBoxs = checkBoxs;
\r
18 checkBoxFlashWindow.Tag = NotificationType.FlashWindow;
\r
19 checkBoxShowBaloonTip.Tag = NotificationType.ShowBaloonTip;
\r
20 checkBoxPlaySound.Tag = NotificationType.PlaySound;
\r
21 checkBoxPushbullet.Tag = NotificationType.Pushbullet;
\r
23 // ReSharper disable once CoVariantArrayConversion
\r
24 listBoxNotifications.Items.AddRange(Config.NotificationNames);
\r
27 private void listBoxNotifications_SelectedIndexChanged(object sender, EventArgs e)
\r
29 if (listBoxNotifications.SelectedItem == null)
\r
31 var notification = _notifications[(string)listBoxNotifications.SelectedItem];
\r
32 checkBoxFlashWindow.Checked = (notification & NotificationType.FlashWindow) != 0;
\r
33 checkBoxShowBaloonTip.Checked = (notification & NotificationType.ShowBaloonTip) != 0;
\r
34 checkBoxPlaySound.Checked = (notification & NotificationType.PlaySound) != 0;
\r
35 checkBoxPushbullet.Checked = (notification & NotificationType.Pushbullet) != 0;
\r
38 private void checkBox_CheckedChanged(object sender, EventArgs e)
\r
40 var checkBox = (CheckBox)sender;
\r
41 if (checkBox.Checked)
\r
43 _notifications[(string)listBoxNotifications.SelectedItem] |= (NotificationType)checkBox.Tag;
\r
47 _notifications[(string)listBoxNotifications.SelectedItem] &= ~(NotificationType)checkBox.Tag;
\r
51 private void NotificationConfigDialog_Load(object sender, EventArgs e)
\r
53 checkBoxFlashWindow.Enabled = _configCheckBoxs[NotificationType.FlashWindow].Checked;
\r
54 checkBoxShowBaloonTip.Enabled = _configCheckBoxs[NotificationType.ShowBaloonTip].Checked;
\r
55 checkBoxPlaySound.Enabled = _configCheckBoxs[NotificationType.PlaySound].Checked;
\r
57 if (listBoxNotifications.SelectedIndex == -1)
\r
58 listBoxNotifications.SelectedIndex = 0;
\r