OSDN Git Service

水上爆撃機の改修値を爆撃に反映する
[kancollesniffer/KancolleSniffer.git] / KancolleSniffer / NotificationConfigDialog.cs
1 using System;\r
2 using System.Collections.Generic;\r
3 using System.Windows.Forms;\r
4 \r
5 namespace KancolleSniffer\r
6 {\r
7     public partial class NotificationConfigDialog : Form\r
8     {\r
9         private readonly Dictionary<string, NotificationType> _notifications;\r
10         private readonly Dictionary<NotificationType, CheckBox> _configCheckBoxs;\r
11 \r
12         public NotificationConfigDialog(Dictionary<string, NotificationType> notifications, Dictionary<NotificationType, CheckBox> checkBoxs)\r
13         {\r
14             InitializeComponent();\r
15             _notifications = notifications;\r
16             _configCheckBoxs = checkBoxs;\r
17 \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
22 \r
23             // ReSharper disable once CoVariantArrayConversion\r
24             listBoxNotifications.Items.AddRange(Config.NotificationNames);\r
25         }\r
26 \r
27         private void listBoxNotifications_SelectedIndexChanged(object sender, EventArgs e)\r
28         {\r
29             if (listBoxNotifications.SelectedItem == null)\r
30                 return;\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
36         }\r
37 \r
38         private void checkBox_CheckedChanged(object sender, EventArgs e)\r
39         {\r
40             var checkBox = (CheckBox)sender;\r
41             if (checkBox.Checked)\r
42             {\r
43                 _notifications[(string)listBoxNotifications.SelectedItem] |= (NotificationType)checkBox.Tag;\r
44             }\r
45             else\r
46             {\r
47                 _notifications[(string)listBoxNotifications.SelectedItem] &= ~(NotificationType)checkBox.Tag;\r
48             }\r
49         }\r
50 \r
51         private void NotificationConfigDialog_Load(object sender, EventArgs e)\r
52         {\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
56 \r
57             if (listBoxNotifications.SelectedIndex == -1)\r
58                 listBoxNotifications.SelectedIndex = 0;\r
59         }\r
60     }\r
61 }\r