PreliminaryPeriods[Config.NotificationIndex[name]] = value.PreliminaryPeriod;\r
}\r
}\r
+\r
+ public void Normalization()\r
+ {\r
+ Settings = Settings.Select(s =>\r
+ (s & NotificationType.Pushbullet) != 0\r
+ ? s ^ NotificationType.Pushbullet | NotificationType.Push\r
+ : s)\r
+ .ToArray();\r
+ RepeatIntervals = RepeatIntervals.Select(v => v < 0 ? 0 : v).ToArray();\r
+ PreliminaryPeriods = RepeatIntervals.Select(v => v < 0 ? 0 : v).ToArray();\r
+ }\r
}\r
\r
public class LocationPerMachine\r
config = (Config)serializer.Deserialize(file);\r
foreach (var property in GetType().GetProperties())\r
property.SetValue(this, property.GetValue(config, null), null);\r
- var ns = Notifications.Settings;\r
- for (var i = 0; i < ns.Length; i++)\r
- {\r
- if ((ns[i] & NotificationType.Pushbullet) != 0)\r
- ns[i] = ns[i] ^ NotificationType.Pushbullet | NotificationType.Push;\r
- }\r
+ Notifications.Normalization();\r
ComposeNotificationFlags();\r
if (AlwaysShowResultRank)\r
{\r
textBoxRepeat.Text = notification.RepeatInterval.ToString();\r
checkBoxCont.Visible = IsContAvailable;\r
textBoxPreliminary.Visible =\r
- labelPreliminary.Visible = checkBoxPreliminary.Visible = IspreliminaryAvailable;\r
+ labelPreliminary.Visible = checkBoxPreliminary.Visible = IsPreliminaryAvailable;\r
textBoxPreliminary.Text = notification.PreliminaryPeriod.ToString();\r
break;\r
}\r
private bool IsContAvailable =>\r
new[] {"遠征終了", "入渠終了"}.Contains((string)listBoxNotifications.SelectedItem);\r
\r
- private bool IspreliminaryAvailable =>\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 int interval) ? interval : 0;\r
+ int.TryParse(textBoxRepeat.Text, out var interval) && interval > 0 ? interval : 0;\r
}\r
\r
private void NotificationConfigDialog_Load(object sender, EventArgs e)\r
checkBoxRepeat.Enabled && checkBoxRepeat.Checked;\r
textBoxPreliminary.Enabled = checkBoxPreliminary.Checked;\r
\r
- if (listBoxNotifications.SelectedIndex == -1)\r
- listBoxNotifications.SelectedIndex = 0;\r
+ var selected = listBoxNotifications.SelectedIndex;\r
+ listBoxNotifications.SelectedIndex = -1;\r
+ listBoxNotifications.SelectedIndex = selected == -1 ? 0 : selected;\r
}\r
\r
- private void textBoxpreliminary_TextChanged(object sender, EventArgs e)\r
+ private void textBoxPreliminary_TextChanged(object sender, EventArgs e)\r
{\r
_notifications[(string)listBoxNotifications.SelectedItem].PreliminaryPeriod =\r
- int.TryParse(textBoxPreliminary.Text, out int preliminary) ? preliminary : 0;\r
+ int.TryParse(textBoxPreliminary.Text, out var preliminary) && preliminary > 0 ? preliminary : 0;\r
}\r
\r
protected override void ScaleControl(SizeF factor, BoundsSpecified specified)\r