2 using System.Collections.Generic;
\r
4 using System.Windows.Forms;
\r
6 namespace KancolleSniffer
\r
8 public partial class NotificationConfigDialog : Form
\r
10 private readonly Dictionary<string, NotificationSpec> _notifications;
\r
11 private readonly Dictionary<NotificationType, CheckBox> _configCheckBoxs;
\r
12 private readonly ToolTip _tooltip = new ToolTip();
\r
14 public NotificationConfigDialog(Dictionary<string, NotificationSpec> notifications,
\r
15 Dictionary<NotificationType, CheckBox> checkBoxs)
\r
17 InitializeComponent();
\r
18 _notifications = notifications;
\r
19 _configCheckBoxs = checkBoxs;
\r
21 checkBoxFlashWindow.Tag = NotificationType.FlashWindow;
\r
22 checkBoxShowBaloonTip.Tag = NotificationType.ShowBaloonTip;
\r
23 checkBoxPlaySound.Tag = NotificationType.PlaySound;
\r
24 checkBoxPush.Tag = NotificationType.Push;
\r
25 checkBoxRepeat.Tag = NotificationType.Repeat;
\r
26 checkBoxCont.Tag = NotificationType.Cont;
\r
27 checkBoxPreliminary.Tag = NotificationType.Preliminary;
\r
29 // ReSharper disable once CoVariantArrayConversion
\r
30 listBoxNotifications.Items.AddRange(Config.NotificationNames);
\r
33 private void listBoxNotifications_SelectedIndexChanged(object sender, EventArgs e)
\r
35 if (listBoxNotifications.SelectedItem == null)
\r
37 var notification = _notifications[(string)listBoxNotifications.SelectedItem];
\r
38 switch (notification.Name)
\r
43 textBoxPreliminary.Visible = labelPreliminary.Visible = checkBoxPreliminary.Visible =
\r
44 textBoxRepeat.Visible = labelRepeat.Visible = checkBoxRepeat.Visible =
\r
45 checkBoxCont.Visible = false;
\r
48 textBoxRepeat.Visible = labelRepeat.Visible = checkBoxRepeat.Visible = true;
\r
49 checkBoxRepeat.Enabled = _configCheckBoxs[NotificationType.Repeat].Checked;
\r
50 textBoxRepeat.Text = notification.RepeatInterval.ToString();
\r
51 checkBoxCont.Visible = IsContAvailable;
\r
52 textBoxPreliminary.Visible =
\r
53 labelPreliminary.Visible = checkBoxPreliminary.Visible = IspreliminaryAvailable;
\r
54 textBoxPreliminary.Text = notification.PreliminaryPeriod.ToString();
\r
57 checkBoxFlashWindow.Checked = (notification.Flags & NotificationType.FlashWindow) != 0;
\r
58 checkBoxShowBaloonTip.Checked = (notification.Flags & NotificationType.ShowBaloonTip) != 0;
\r
59 checkBoxPlaySound.Checked = (notification.Flags & NotificationType.PlaySound) != 0;
\r
60 checkBoxPush.Checked = (notification.Flags & NotificationType.Push) != 0;
\r
61 checkBoxRepeat.Checked = (notification.Flags & NotificationType.Repeat) != 0;
\r
62 _tooltip.SetToolTip(checkBoxCont,
\r
63 !IsContAvailable ? "" :
\r
64 notification.Name == "遠征終了" ? "再度遠征に出すまでリピートする。" : "再度入渠させるまでリピートする。");
\r
65 checkBoxCont.Checked = (notification.Flags & NotificationType.Cont) != 0;
\r
66 checkBoxPreliminary.Checked = (notification.Flags & NotificationType.Preliminary) != 0;
\r
69 private void checkBox_CheckedChanged(object sender, EventArgs e)
\r
71 var checkBox = (CheckBox)sender;
\r
72 var type = (NotificationType)checkBox.Tag;
\r
73 var spec = _notifications[(string)listBoxNotifications.SelectedItem];
\r
74 spec.Flags = checkBox.Checked ? spec.Flags | type : spec.Flags & ~type;
\r
75 if (type == NotificationType.Repeat)
\r
77 textBoxRepeat.Enabled = labelRepeat.Enabled = checkBoxCont.Enabled =
\r
78 _configCheckBoxs[NotificationType.Repeat].Checked && checkBox.Checked;
\r
80 if (type == NotificationType.Preliminary)
\r
81 textBoxPreliminary.Enabled = labelPreliminary.Enabled = checkBox.Checked;
\r
84 private bool IsContAvailable =>
\r
85 new[] {"遠征終了", "入渠終了"}.Contains((string)listBoxNotifications.SelectedItem);
\r
87 private bool IspreliminaryAvailable =>
\r
88 new[] {"遠征終了", "入渠終了", "建造完了", "泊地修理20分経過", "疲労回復"}.Contains((string)listBoxNotifications.SelectedItem);
\r
90 private void textBoxRepeat_TextChanged(object sender, EventArgs e)
\r
92 _notifications[(string)listBoxNotifications.SelectedItem].RepeatInterval =
\r
93 int.TryParse(textBoxRepeat.Text, out int interval) ? interval : 0;
\r
96 private void NotificationConfigDialog_Load(object sender, EventArgs e)
\r
98 checkBoxFlashWindow.Enabled = _configCheckBoxs[NotificationType.FlashWindow].Checked;
\r
99 checkBoxShowBaloonTip.Enabled = _configCheckBoxs[NotificationType.ShowBaloonTip].Checked;
\r
100 checkBoxPlaySound.Enabled = _configCheckBoxs[NotificationType.PlaySound].Checked;
\r
101 checkBoxRepeat.Enabled = _configCheckBoxs[NotificationType.Repeat].Checked;
\r
102 textBoxRepeat.Enabled = labelRepeat.Enabled = checkBoxCont.Enabled =
\r
103 checkBoxRepeat.Enabled && checkBoxRepeat.Checked;
\r
104 textBoxPreliminary.Enabled = checkBoxPreliminary.Checked;
\r
106 if (listBoxNotifications.SelectedIndex == -1)
\r
107 listBoxNotifications.SelectedIndex = 0;
\r
110 private void textBoxpreliminary_TextChanged(object sender, EventArgs e)
\r
112 _notifications[(string)listBoxNotifications.SelectedItem].PreliminaryPeriod =
\r
113 int.TryParse(textBoxPreliminary.Text, out int preliminary) ? preliminary : 0;
\r