コミットメタ情報

リビジョン8b36b779b44db8d702da59a97a7465798047379a (tree)
日時2018-05-20 14:16:32
作者Kazuhiro Fujieda <fujieda@user...>
コミッターKazuhiro Fujieda

ログメッセージ

リピートと予告の秒数にマイナスを指定できるのを直す

変更サマリ

差分

--- a/KancolleSniffer/Config.cs
+++ b/KancolleSniffer/Config.cs
@@ -158,6 +158,17 @@ namespace KancolleSniffer
158158 PreliminaryPeriods[Config.NotificationIndex[name]] = value.PreliminaryPeriod;
159159 }
160160 }
161+
162+ public void Normalization()
163+ {
164+ Settings = Settings.Select(s =>
165+ (s & NotificationType.Pushbullet) != 0
166+ ? s ^ NotificationType.Pushbullet | NotificationType.Push
167+ : s)
168+ .ToArray();
169+ RepeatIntervals = RepeatIntervals.Select(v => v < 0 ? 0 : v).ToArray();
170+ PreliminaryPeriods = RepeatIntervals.Select(v => v < 0 ? 0 : v).ToArray();
171+ }
161172 }
162173
163174 public class LocationPerMachine
@@ -247,12 +258,7 @@ namespace KancolleSniffer
247258 config = (Config)serializer.Deserialize(file);
248259 foreach (var property in GetType().GetProperties())
249260 property.SetValue(this, property.GetValue(config, null), null);
250- var ns = Notifications.Settings;
251- for (var i = 0; i < ns.Length; i++)
252- {
253- if ((ns[i] & NotificationType.Pushbullet) != 0)
254- ns[i] = ns[i] ^ NotificationType.Pushbullet | NotificationType.Push;
255- }
261+ Notifications.Normalization();
256262 ComposeNotificationFlags();
257263 if (AlwaysShowResultRank)
258264 {
--- a/KancolleSniffer/NotificationConfigDialog.Designer.cs
+++ b/KancolleSniffer/NotificationConfigDialog.Designer.cs
@@ -157,7 +157,7 @@
157157 this.textBoxPreliminary.Size = new System.Drawing.Size(36, 19);
158158 this.textBoxPreliminary.TabIndex = 12;
159159 this.textBoxPreliminary.TextAlign = System.Windows.Forms.HorizontalAlignment.Right;
160- this.textBoxPreliminary.TextChanged += new System.EventHandler(this.textBoxpreliminary_TextChanged);
160+ this.textBoxPreliminary.TextChanged += new System.EventHandler(this.textBoxPreliminary_TextChanged);
161161 //
162162 // labelPreliminary
163163 //
--- a/KancolleSniffer/NotificationConfigDialog.cs
+++ b/KancolleSniffer/NotificationConfigDialog.cs
@@ -51,7 +51,7 @@ namespace KancolleSniffer
5151 textBoxRepeat.Text = notification.RepeatInterval.ToString();
5252 checkBoxCont.Visible = IsContAvailable;
5353 textBoxPreliminary.Visible =
54- labelPreliminary.Visible = checkBoxPreliminary.Visible = IspreliminaryAvailable;
54+ labelPreliminary.Visible = checkBoxPreliminary.Visible = IsPreliminaryAvailable;
5555 textBoxPreliminary.Text = notification.PreliminaryPeriod.ToString();
5656 break;
5757 }
@@ -85,13 +85,13 @@ namespace KancolleSniffer
8585 private bool IsContAvailable =>
8686 new[] {"遠征終了", "入渠終了"}.Contains((string)listBoxNotifications.SelectedItem);
8787
88- private bool IspreliminaryAvailable =>
88+ private bool IsPreliminaryAvailable =>
8989 new[] {"遠征終了", "入渠終了", "建造完了", "泊地修理20分経過", "疲労回復"}.Contains((string)listBoxNotifications.SelectedItem);
9090
9191 private void textBoxRepeat_TextChanged(object sender, EventArgs e)
9292 {
9393 _notifications[(string)listBoxNotifications.SelectedItem].RepeatInterval =
94- int.TryParse(textBoxRepeat.Text, out int interval) ? interval : 0;
94+ int.TryParse(textBoxRepeat.Text, out var interval) && interval > 0 ? interval : 0;
9595 }
9696
9797 private void NotificationConfigDialog_Load(object sender, EventArgs e)
@@ -104,14 +104,15 @@ namespace KancolleSniffer
104104 checkBoxRepeat.Enabled && checkBoxRepeat.Checked;
105105 textBoxPreliminary.Enabled = checkBoxPreliminary.Checked;
106106
107- if (listBoxNotifications.SelectedIndex == -1)
108- listBoxNotifications.SelectedIndex = 0;
107+ var selected = listBoxNotifications.SelectedIndex;
108+ listBoxNotifications.SelectedIndex = -1;
109+ listBoxNotifications.SelectedIndex = selected == -1 ? 0 : selected;
109110 }
110111
111- private void textBoxpreliminary_TextChanged(object sender, EventArgs e)
112+ private void textBoxPreliminary_TextChanged(object sender, EventArgs e)
112113 {
113114 _notifications[(string)listBoxNotifications.SelectedItem].PreliminaryPeriod =
114- int.TryParse(textBoxPreliminary.Text, out int preliminary) ? preliminary : 0;
115+ int.TryParse(textBoxPreliminary.Text, out var preliminary) && preliminary > 0 ? preliminary : 0;
115116 }
116117
117118 protected override void ScaleControl(SizeF factor, BoundsSpecified specified)
旧リポジトリブラウザで表示