timer.ElapseTime(1000);\r
}\r
}\r
+\r
+ /// <summary>\r
+ /// リピート中の特定の通知を止める\r
+ /// </summary>\r
+ [TestMethod]\r
+ public void StopSpecificRepeatingNotification()\r
+ {\r
+ var timer = new MockTimer();\r
+ Message result = null;\r
+ var manager =\r
+ new NotificationManager((t, b, n) => { result = new Message {Title = t, Body = b, Name = n}; }, timer);\r
+ var expected1 = new Message {Title = "遠征が終わりました", Body = "防空射撃演習", Name = "遠征終了"};\r
+ var expected2 = new Message {Title = "遠征が終わりました", Body = "海上護衛任務", Name = "遠征終了"};\r
+ while (true)\r
+ {\r
+ switch (timer.Elapsed)\r
+ {\r
+ case 0:\r
+ manager.Enqueue("遠征終了", 1, "防空射撃演習", 10);\r
+ manager.Enqueue("遠征終了", 2, "海上護衛任務", 10);\r
+ PAssert.That(() => expected1.Equals(result));\r
+ break;\r
+ case 2000:\r
+ PAssert.That(() => expected2.Equals(result));\r
+ break;\r
+ case 5000:\r
+ manager.StopRepeat("遠征終了", 1);\r
+ break;\r
+ case 12000:\r
+ PAssert.That(() => expected2.Equals(result));\r
+ return;\r
+ default:\r
+ PAssert.That(() => result == null, timer.Elapsed.ToString());\r
+ break;\r
+\r
+ }\r
+ result = null;\r
+ timer.ElapseTime(1000);\r
+ }\r
+ }\r
}\r
}
\ No newline at end of file
All = (1 << 3) - 1,\r
Pushbullet = 1 << 3,\r
Push = 1 << 4,\r
- Repeat = 1 << 5\r
+ Repeat = 1 << 5,\r
+ Cont = 1 << 6\r
}\r
\r
\r
var old = _config.Notifications[name];\r
var cur = _notificationSettings[name];\r
if (repeatOff || old.RepeatInterval != cur.RepeatInterval ||\r
- (cur.Flags & NotificationType.Repeat) == 0)\r
+ (cur.Flags & NotificationType.Repeat) == 0 ||\r
+ (cur.Flags & NotificationType.Cont) == 0)\r
{\r
RepeatSettingsChanged.Add(name);\r
}\r
PerformZoom();\r
_shipLabels.AdjustAkashiTimers();\r
_sniffer.LoadState();\r
- _sniffer.RepeatingTimerController = new RepeatingTimerController(_notificationManager);\r
+ _sniffer.RepeatingTimerController = new RepeatingTimerController(_notificationManager, _config);\r
}\r
\r
private class RepeatingTimerController : Sniffer.IRepeatingTimerController\r
{\r
private readonly NotificationManager _manager;\r
+ private readonly Config _config;\r
\r
- public RepeatingTimerController(NotificationManager manager)\r
+ public RepeatingTimerController(NotificationManager manager, Config config)\r
{\r
_manager = manager;\r
+ _config = config;\r
}\r
\r
- public void Stop(string key) => _manager.StopRepeat(key);\r
+ public void Stop(string key)\r
+ {\r
+ if ((_config.Notifications[key].Flags & NotificationType.Cont) == 0)\r
+ _manager.StopRepeat(key);\r
+ }\r
+\r
+ public void Stop(string key, int fleet) => _manager.StopRepeat(key, fleet);\r
\r
public void Suspend() => _manager.SuspendRepeat();\r
\r
\r
private void UpdateTimers()\r
{\r
- foreach (var entry in\r
- new[] {labelMission1, labelMission2, labelMission3}.Zip(_sniffer.Missions,\r
- (label, mission) => new {label, mission.Name, mission.Timer}))\r
+ var mission = new[] {labelMission1, labelMission2, labelMission3};\r
+ for (var i = 0; i < mission.Length; i++)\r
{\r
+ var entry = _sniffer.Missions[i];\r
entry.Timer.Update();\r
- SetTimerColor(entry.label, entry.Timer);\r
- entry.label.Text = entry.Timer.ToString(_missionFinishTimeMode);\r
+ SetTimerColor(mission[i], entry.Timer);\r
+ mission[i].Text = entry.Timer.ToString(_missionFinishTimeMode);\r
if (!entry.Timer.NeedRing)\r
continue;\r
- SetNotification("遠征終了", entry.Name);\r
+ SetNotification("遠征終了", i + 1, entry.Name);\r
entry.Timer.NeedRing = false;\r
}\r
for (var i = 0; i < _sniffer.NDock.Length; i++)\r
_shipLabels.SetNDockTimer(i, entry.Timer, _ndockFinishTimeMode);\r
if (!entry.Timer.NeedRing)\r
continue;\r
- SetNotification("入渠終了", entry.Name);\r
+ SetNotification("入渠終了", i, entry.Name);\r
entry.Timer.NeedRing = false;\r
}\r
var kdock = new[] {labelConstruct1, labelConstruct2, labelConstruct3, labelConstruct4};\r
this.checkBoxRepeat = new System.Windows.Forms.CheckBox();\r
this.textBoxRepeat = new System.Windows.Forms.TextBox();\r
this.labelRepeat = new System.Windows.Forms.Label();\r
+ this.checkBoxCont = new System.Windows.Forms.CheckBox();\r
this.SuspendLayout();\r
// \r
// listBoxNotifications\r
// \r
+ this.listBoxNotifications.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) \r
+ | System.Windows.Forms.AnchorStyles.Right)));\r
this.listBoxNotifications.FormattingEnabled = true;\r
this.listBoxNotifications.ItemHeight = 12;\r
this.listBoxNotifications.Location = new System.Drawing.Point(12, 12);\r
this.listBoxNotifications.Name = "listBoxNotifications";\r
- this.listBoxNotifications.Size = new System.Drawing.Size(204, 88);\r
+ this.listBoxNotifications.Size = new System.Drawing.Size(264, 88);\r
this.listBoxNotifications.TabIndex = 0;\r
this.listBoxNotifications.SelectedIndexChanged += new System.EventHandler(this.listBoxNotifications_SelectedIndexChanged);\r
// \r
// \r
// buttonClose\r
// \r
- this.buttonClose.Anchor = System.Windows.Forms.AnchorStyles.Bottom;\r
+ this.buttonClose.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));\r
this.buttonClose.DialogResult = System.Windows.Forms.DialogResult.Cancel;\r
- this.buttonClose.Location = new System.Drawing.Point(141, 157);\r
+ this.buttonClose.Location = new System.Drawing.Point(201, 151);\r
this.buttonClose.Name = "buttonClose";\r
this.buttonClose.Size = new System.Drawing.Size(75, 23);\r
this.buttonClose.TabIndex = 6;\r
// checkBoxPush\r
// \r
this.checkBoxPush.AutoSize = true;\r
- this.checkBoxPush.Location = new System.Drawing.Point(12, 128);\r
+ this.checkBoxPush.Location = new System.Drawing.Point(218, 106);\r
this.checkBoxPush.Name = "checkBoxPush";\r
- this.checkBoxPush.Size = new System.Drawing.Size(82, 16);\r
+ this.checkBoxPush.Size = new System.Drawing.Size(58, 16);\r
this.checkBoxPush.TabIndex = 7;\r
- this.checkBoxPush.Text = "プッシュ通知";\r
+ this.checkBoxPush.Text = "プッシュ";\r
this.checkBoxPush.UseVisualStyleBackColor = true;\r
this.checkBoxPush.CheckedChanged += new System.EventHandler(this.checkBox_CheckedChanged);\r
// \r
// checkBoxRepeat\r
// \r
this.checkBoxRepeat.AutoSize = true;\r
- this.checkBoxRepeat.Location = new System.Drawing.Point(100, 128);\r
+ this.checkBoxRepeat.Location = new System.Drawing.Point(12, 134);\r
this.checkBoxRepeat.Name = "checkBoxRepeat";\r
this.checkBoxRepeat.Size = new System.Drawing.Size(58, 16);\r
this.checkBoxRepeat.TabIndex = 8;\r
// \r
// textBoxRepeat\r
// \r
- this.textBoxRepeat.Location = new System.Drawing.Point(155, 126);\r
+ this.textBoxRepeat.Location = new System.Drawing.Point(67, 132);\r
this.textBoxRepeat.Name = "textBoxRepeat";\r
this.textBoxRepeat.Size = new System.Drawing.Size(26, 19);\r
this.textBoxRepeat.TabIndex = 9;\r
// labelRepeat\r
// \r
this.labelRepeat.AutoSize = true;\r
- this.labelRepeat.Location = new System.Drawing.Point(183, 129);\r
+ this.labelRepeat.Location = new System.Drawing.Point(95, 135);\r
this.labelRepeat.Name = "labelRepeat";\r
this.labelRepeat.Size = new System.Drawing.Size(17, 12);\r
this.labelRepeat.TabIndex = 10;\r
this.labelRepeat.Text = "秒";\r
// \r
+ // checkBoxCont\r
+ // \r
+ this.checkBoxCont.AutoSize = true;\r
+ this.checkBoxCont.Location = new System.Drawing.Point(112, 134);\r
+ this.checkBoxCont.Name = "checkBoxCont";\r
+ this.checkBoxCont.Size = new System.Drawing.Size(48, 16);\r
+ this.checkBoxCont.TabIndex = 11;\r
+ this.checkBoxCont.Text = "継続";\r
+ this.checkBoxCont.UseVisualStyleBackColor = true;\r
+ this.checkBoxCont.CheckedChanged += new System.EventHandler(this.checkBox_CheckedChanged);\r
+ // \r
// NotificationConfigDialog\r
// \r
this.AcceptButton = this.buttonClose;\r
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);\r
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;\r
this.CancelButton = this.buttonClose;\r
- this.ClientSize = new System.Drawing.Size(228, 188);\r
+ this.ClientSize = new System.Drawing.Size(288, 185);\r
+ this.Controls.Add(this.checkBoxCont);\r
this.Controls.Add(this.labelRepeat);\r
this.Controls.Add(this.textBoxRepeat);\r
this.Controls.Add(this.checkBoxRepeat);\r
this.Controls.Add(this.checkBoxShowBaloonTip);\r
this.Controls.Add(this.checkBoxFlashWindow);\r
this.Controls.Add(this.listBoxNotifications);\r
+ this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;\r
this.MaximizeBox = false;\r
this.MinimizeBox = false;\r
this.Name = "NotificationConfigDialog";\r
private System.Windows.Forms.CheckBox checkBoxRepeat;\r
private System.Windows.Forms.TextBox textBoxRepeat;\r
private System.Windows.Forms.Label labelRepeat;\r
+ private System.Windows.Forms.CheckBox checkBoxCont;\r
}\r
}
\ No newline at end of file
{\r
private readonly Dictionary<string, NotificationSpec> _notifications;\r
private readonly Dictionary<NotificationType, CheckBox> _configCheckBoxs;\r
+ private readonly ToolTip _tooltip = new ToolTip();\r
\r
public NotificationConfigDialog(Dictionary<string, NotificationSpec> notifications,\r
Dictionary<NotificationType, CheckBox> checkBoxs)\r
checkBoxPlaySound.Tag = NotificationType.PlaySound;\r
checkBoxPush.Tag = NotificationType.Push;\r
checkBoxRepeat.Tag = NotificationType.Repeat;\r
+ checkBoxCont.Tag = NotificationType.Cont;\r
\r
// ReSharper disable once CoVariantArrayConversion\r
listBoxNotifications.Items.AddRange(Config.NotificationNames);\r
case "艦娘数超過":\r
case "装備数超過":\r
case "大破警告":\r
- checkBoxRepeat.Enabled = checkBoxRepeat.Checked = false;\r
- textBoxRepeat.Text = "";\r
+ textBoxRepeat.Visible = labelRepeat.Visible = checkBoxRepeat.Visible = checkBoxCont.Visible = false;\r
break;\r
default:\r
+ textBoxRepeat.Visible = labelRepeat.Visible = checkBoxRepeat.Visible = true;\r
checkBoxRepeat.Enabled = _configCheckBoxs[NotificationType.Repeat].Checked;\r
textBoxRepeat.Text = notification.RepeatInterval.ToString();\r
+ checkBoxCont.Visible = IsContAvailable;\r
break;\r
}\r
checkBoxFlashWindow.Checked = (notification.Flags & NotificationType.FlashWindow) != 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 ? "" : notification.Name == "遠征終了" ? "再度遠征に出すまでリピートする。" : "再度入渠させるまでリピートする。");\r
+ checkBoxCont.Checked = (notification.Flags & NotificationType.Cont) != 0;\r
}\r
\r
private void checkBox_CheckedChanged(object sender, EventArgs e)\r
spec.Flags = checkBox.Checked ? spec.Flags | type : spec.Flags & ~type;\r
if (type == NotificationType.Repeat)\r
{\r
- textBoxRepeat.Enabled = labelRepeat.Enabled =\r
+ textBoxRepeat.Enabled = labelRepeat.Enabled = checkBoxCont.Enabled =\r
_configCheckBoxs[NotificationType.Repeat].Checked && checkBox.Checked;\r
}\r
}\r
\r
+ private bool IsContAvailable\r
+ {\r
+ get\r
+ {\r
+ var notification = _notifications[(string)listBoxNotifications.SelectedItem];\r
+ return notification.Name == "遠征終了" || notification.Name == "入渠終了";\r
+ }\r
+ }\r
+\r
private void textBoxRepeat_TextChanged(object sender, EventArgs e)\r
{\r
_notifications[(string)listBoxNotifications.SelectedItem].RepeatInterval =\r
checkBoxShowBaloonTip.Enabled = _configCheckBoxs[NotificationType.ShowBaloonTip].Checked;\r
checkBoxPlaySound.Enabled = _configCheckBoxs[NotificationType.PlaySound].Checked;\r
checkBoxRepeat.Enabled = _configCheckBoxs[NotificationType.Repeat].Checked;\r
- textBoxRepeat.Enabled = labelRepeat.Enabled = checkBoxRepeat.Enabled && checkBoxRepeat.Checked;\r
+ textBoxRepeat.Enabled = labelRepeat.Enabled = checkBoxCont.Enabled =\r
+ checkBoxRepeat.Enabled && checkBoxRepeat.Checked;\r
\r
if (listBoxNotifications.SelectedIndex == -1)\r
listBoxNotifications.SelectedIndex = 0;\r
_notificationQueue.StopRepeat(key);\r
}\r
\r
+ public void StopRepeat(string key, int fleet)\r
+ {\r
+ _notificationQueue.StopRepeat(key, fleet);\r
+ }\r
+\r
public void SuspendRepeat()\r
{\r
_notificationQueue.SuspendRepeat();\r
_queue.RemoveAll(n => n.Key.Substring(0, 4) == key.Substring(0, 4) && n.Schedule != default);\r
}\r
\r
+ public void StopRepeat(string key, int fleet)\r
+ {\r
+ _queue.RemoveAll(n =>\r
+ n.Key.Substring(0, 4) == key.Substring(0, 4) && n.Fleet == fleet && n.Schedule != default);\r
+ }\r
+\r
public void SuspendRepeat()\r
{\r
_suspend = true;\r
public interface IRepeatingTimerController\r
{\r
void Stop(string key);\r
+ void Stop(string key, int fleet);\r
void Suspend();\r
void Resume();\r
}\r
_dockInfo.InspectNyukyo(request);\r
_conditionTimer.CheckCond();\r
_akashiTimer.CheckFleet();\r
+ var ndock = HttpUtility.ParseQueryString(request)["api_ndock_id"];\r
+ if (ndock != null && int.TryParse(ndock, out int id))\r
+ RepeatingTimerController?.Stop("入渠終了", id - 1);\r
return Update.Item | Update.Ship;\r
}\r
if (url.EndsWith("api_req_nyukyo/speedchange"))\r
_logger.InspectMapNext(data);\r
return Update.None;\r
}\r
+ if (url.EndsWith("api_req_mission/start"))\r
+ {\r
+ var deck = HttpUtility.ParseQueryString(request)["api_deck_id"];\r
+ if (deck != null && int.TryParse(deck, out int id))\r
+ RepeatingTimerController?.Stop("遠征終了", id - 1);\r
+ return Update.None;\r
+ }\r
if (url.EndsWith("api_req_mission/result"))\r
{\r
_materialInfo.InspectMissionResult(data);\r