using System;\r
using System.Collections.Generic;\r
+using System.Drawing;\r
+using System.Linq;\r
using System.Windows.Forms;\r
+using KancolleSniffer.View;\r
\r
namespace KancolleSniffer\r
{\r
public partial class NotificationConfigDialog : Form\r
{\r
- private readonly Dictionary<string, NotificationType> _notifications;\r
- private readonly Dictionary<NotificationType, CheckBox> _configCheckBoxs;\r
+ private readonly Dictionary<string, NotificationSpec> _notifications;\r
+ private readonly Dictionary<NotificationType, CheckBox> _configCheckBoxes;\r
+ private readonly ResizableToolTip _toolTip = new ResizableToolTip();\r
\r
- public NotificationConfigDialog(Dictionary<string, NotificationType> notifications, Dictionary<NotificationType, CheckBox> checkBoxs)\r
+ public NotificationConfigDialog(Dictionary<string, NotificationSpec> notifications,\r
+ Dictionary<NotificationType, CheckBox> checkBoxes)\r
{\r
InitializeComponent();\r
_notifications = notifications;\r
- _configCheckBoxs = checkBoxs;\r
+ _configCheckBoxes = checkBoxes;\r
\r
checkBoxFlashWindow.Tag = NotificationType.FlashWindow;\r
- checkBoxShowBaloonTip.Tag = NotificationType.ShowBaloonTip;\r
+ checkBoxShowBalloonTip.Tag = NotificationType.ShowBaloonTip;\r
checkBoxPlaySound.Tag = NotificationType.PlaySound;\r
+ checkBoxPush.Tag = NotificationType.Push;\r
+ checkBoxRepeat.Tag = NotificationType.Repeat;\r
+ checkBoxCont.Tag = NotificationType.Cont;\r
+ checkBoxPreliminary.Tag = NotificationType.Preliminary;\r
\r
// ReSharper disable once CoVariantArrayConversion\r
listBoxNotifications.Items.AddRange(Config.NotificationNames);\r
if (listBoxNotifications.SelectedItem == null)\r
return;\r
var notification = _notifications[(string)listBoxNotifications.SelectedItem];\r
- checkBoxFlashWindow.Checked = (notification & NotificationType.FlashWindow) != 0;\r
- checkBoxShowBaloonTip.Checked = (notification & NotificationType.ShowBaloonTip) != 0;\r
- checkBoxPlaySound.Checked = (notification & NotificationType.PlaySound) != 0;\r
+ switch (notification.Name)\r
+ {\r
+ case "艦娘数超過":\r
+ case "装備数超過":\r
+ textBoxPreliminary.Visible = labelPreliminary.Visible = checkBoxPreliminary.Visible =\r
+ textBoxRepeat.Visible = labelRepeat.Visible = checkBoxRepeat.Visible =\r
+ checkBoxCont.Visible = false;\r
+ break;\r
+ default:\r
+ textBoxRepeat.Visible = labelRepeat.Visible = checkBoxRepeat.Visible = true;\r
+ checkBoxRepeat.Enabled = _configCheckBoxes[NotificationType.Repeat].Checked;\r
+ textBoxRepeat.Text = notification.RepeatInterval.ToString();\r
+ checkBoxCont.Visible = IsContAvailable;\r
+ textBoxPreliminary.Visible =\r
+ labelPreliminary.Visible = checkBoxPreliminary.Visible = IsPreliminaryAvailable;\r
+ textBoxPreliminary.Text = notification.PreliminaryPeriod.ToString();\r
+ break;\r
+ }\r
+ checkBoxFlashWindow.Checked = (notification.Flags & NotificationType.FlashWindow) != 0;\r
+ checkBoxShowBalloonTip.Checked = (notification.Flags & NotificationType.ShowBaloonTip) != 0;\r
+ checkBoxPlaySound.Checked = (notification.Flags & NotificationType.PlaySound) != 0;\r
+ checkBoxPush.Checked = (notification.Flags & NotificationType.Push) != 0;\r
+ checkBoxRepeat.Checked = (notification.Flags & NotificationType.Repeat) != 0;\r
+ _toolTip.SetToolTip(checkBoxCont,\r
+ !IsContAvailable ? "" :\r
+ notification.Name == "遠征終了" ? "再度遠征に出すまでリピートする。" : "再度入渠させるまでリピートする。");\r
+ checkBoxCont.Checked = (notification.Flags & NotificationType.Cont) != 0;\r
+ checkBoxPreliminary.Checked = (notification.Flags & NotificationType.Preliminary) != 0;\r
}\r
\r
private void checkBox_CheckedChanged(object sender, EventArgs e)\r
{\r
var checkBox = (CheckBox)sender;\r
- if (checkBox.Checked)\r
- {\r
- _notifications[(string)listBoxNotifications.SelectedItem] |= (NotificationType)checkBox.Tag;\r
- }\r
- else\r
+ var type = (NotificationType)checkBox.Tag;\r
+ var spec = _notifications[(string)listBoxNotifications.SelectedItem];\r
+ spec.Flags = checkBox.Checked ? spec.Flags | type : spec.Flags & ~type;\r
+ if (type == NotificationType.Repeat)\r
{\r
- _notifications[(string)listBoxNotifications.SelectedItem] &= ~(NotificationType)checkBox.Tag;\r
+ textBoxRepeat.Enabled = labelRepeat.Enabled = checkBoxCont.Enabled =\r
+ _configCheckBoxes[NotificationType.Repeat].Checked && checkBox.Checked;\r
}\r
+ if (type == NotificationType.Preliminary)\r
+ textBoxPreliminary.Enabled = labelPreliminary.Enabled = checkBox.Checked;\r
+ }\r
+\r
+ private bool IsContAvailable =>\r
+ new[] {"遠征終了", "入渠終了"}.Contains((string)listBoxNotifications.SelectedItem);\r
+\r
+ private bool IsPreliminaryAvailable =>\r
+ new[] {"遠征終了", "入渠終了", "建造完了", "泊地修理20分経過", "疲労回復"}.Contains((string)listBoxNotifications.SelectedItem);\r
+\r
+ private void textBoxRepeat_TextChanged(object sender, EventArgs e)\r
+ {\r
+ _notifications[(string)listBoxNotifications.SelectedItem].RepeatInterval =\r
+ int.TryParse(textBoxRepeat.Text, out var interval) && interval > 0 ? interval : 0;\r
}\r
\r
private void NotificationConfigDialog_Load(object sender, EventArgs e)\r
{\r
- checkBoxFlashWindow.Enabled = _configCheckBoxs[NotificationType.FlashWindow].Checked;\r
- checkBoxShowBaloonTip.Enabled = _configCheckBoxs[NotificationType.ShowBaloonTip].Checked;\r
- checkBoxPlaySound.Enabled = _configCheckBoxs[NotificationType.PlaySound].Checked;\r
+ checkBoxFlashWindow.Enabled = _configCheckBoxes[NotificationType.FlashWindow].Checked;\r
+ checkBoxShowBalloonTip.Enabled = _configCheckBoxes[NotificationType.ShowBaloonTip].Checked;\r
+ checkBoxPlaySound.Enabled = _configCheckBoxes[NotificationType.PlaySound].Checked;\r
+ checkBoxRepeat.Enabled = _configCheckBoxes[NotificationType.Repeat].Checked;\r
+ textBoxRepeat.Enabled = labelRepeat.Enabled = checkBoxCont.Enabled =\r
+ checkBoxRepeat.Enabled && checkBoxRepeat.Checked;\r
+ textBoxPreliminary.Enabled = checkBoxPreliminary.Checked;\r
+\r
+ var selected = listBoxNotifications.SelectedIndex;\r
+ listBoxNotifications.SelectedIndex = -1;\r
+ listBoxNotifications.SelectedIndex = selected == -1 ? 0 : selected;\r
+ }\r
\r
- if (listBoxNotifications.SelectedIndex == -1)\r
- listBoxNotifications.SelectedIndex = 0;\r
+ private void textBoxPreliminary_TextChanged(object sender, EventArgs e)\r
+ {\r
+ _notifications[(string)listBoxNotifications.SelectedItem].PreliminaryPeriod =\r
+ int.TryParse(textBoxPreliminary.Text, out var preliminary) && preliminary > 0 ? preliminary : 0;\r
+ }\r
+\r
+ protected override void ScaleControl(SizeF factor, BoundsSpecified specified)\r
+ {\r
+ base.ScaleControl(factor, specified);\r
+ if (factor.Height > 1)\r
+ _toolTip.Font = new Font(_toolTip.Font.FontFamily, _toolTip.Font.Size * factor.Height);\r
}\r
}\r
-}\r
+}
\ No newline at end of file