diff --git a/NotifyEx/Models/HpNotifier.cs b/NotifyEx/Models/HpNotifier.cs index 2218121..7bbf170 100644 --- a/NotifyEx/Models/HpNotifier.cs +++ b/NotifyEx/Models/HpNotifier.cs @@ -10,6 +10,7 @@ using System.Reactive.Linq; using Grabacr07.KanColleWrapper.Models; using NotifyEx.Models.NotifyType; +using NotifyEx.Models.Settings; namespace NotifyEx.Models { @@ -20,17 +21,14 @@ internal class HpNotifier { public static HpNotifier Current = new HpNotifier(); - private static readonly Settings Settings = Settings.Default; - public bool Enabled { - get { return Settings.EnabledLowHpNotifier; } + get { return NotifierSettings.EnabledLowHpNotifier.Value; } set { - if (Settings.EnabledLowHpNotifier != value) + if (NotifierSettings.EnabledLowHpNotifier.Value != value) { - Settings.EnabledLowHpNotifier = value; - Settings.Save(); + NotifierSettings.EnabledLowHpNotifier.Value = value; } } } @@ -40,13 +38,12 @@ public bool Enabled /// public bool EnabledShowDamageControl { - get { return Settings.EnabledShowDamageControl; } + get { return NotifierSettings.EnabledShowDamageControl.Value; } set { - if (Settings.EnabledShowDamageControl != value) + if (NotifierSettings.EnabledShowDamageControl.Value != value) { - Settings.EnabledShowDamageControl = value; - Settings.Save(); + NotifierSettings.EnabledShowDamageControl.Value = value; } } } diff --git a/NotifyEx/Models/Settings/NotifierSettings.cs b/NotifyEx/Models/Settings/NotifierSettings.cs new file mode 100644 index 0000000..03487ce --- /dev/null +++ b/NotifyEx/Models/Settings/NotifierSettings.cs @@ -0,0 +1,76 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Runtime.CompilerServices; +using System.Text; +using System.Threading.Tasks; +using MetroTrilithon.Serialization; + +namespace NotifyEx.Models.Settings +{ + public static class NotifierSettings + { + #region Ship count notifier settings + + public static SerializableProperty EnabledShipNotifier { get; } + = new SerializableProperty(GetKey(), Provider.Roaming, Properties.Settings.Default.EnabledShipNotifier) { AutoSave = true }; + + public static SerializableProperty ShipWarningCount { get; } + = new SerializableProperty(GetKey(), Provider.Roaming, Properties.Settings.Default.WarningShipCount) { AutoSave = true }; + + public static SerializableProperty EnabledEventShipNotifier { get; } + = new SerializableProperty(GetKey(), Provider.Roaming, Properties.Settings.Default.EnabledEventShipNotifier) { AutoSave = true }; + + public static SerializableProperty EventShipWarningCount { get; } + = new SerializableProperty(GetKey(), Provider.Roaming, Properties.Settings.Default.EventWarningShipCount) { AutoSave = true }; + + #endregion + + #region Slot count notifier settings + + public static SerializableProperty EnabledSlotNotifier { get; } + = new SerializableProperty(GetKey(), Provider.Roaming, Properties.Settings.Default.EnabledSlotNotifier) { AutoSave = true }; + + public static SerializableProperty SlotWarningCount { get; } + = new SerializableProperty(GetKey(), Provider.Roaming, Properties.Settings.Default.WarningShipCount) { AutoSave = true }; + + public static SerializableProperty EnabledEventSlotNotifier { get; } + = new SerializableProperty(GetKey(), Provider.Roaming, Properties.Settings.Default.EnabledEventSlotNotifier) { AutoSave = true }; + + public static SerializableProperty EventSlotWarningCount { get; } + = new SerializableProperty(GetKey(), Provider.Roaming, Properties.Settings.Default.EventWarningSlotCount) { AutoSave = true }; + + #endregion + + #region Heavily damaged notifier settings + + public static SerializableProperty EnabledLowHpNotifier { get; } + = new SerializableProperty(GetKey(), Provider.Roaming, Properties.Settings.Default.EnabledLowHpNotifier) { AutoSave = true }; + + public static SerializableProperty EnabledShowDamageControl { get; } + = new SerializableProperty(GetKey(), Provider.Roaming, Properties.Settings.Default.EnabledShowDamageControl) { AutoSave = true }; + + #endregion + + #region Lack of supply notifier + + public static SerializableProperty EnabledSupplyNotifier { get; } + = new SerializableProperty(GetKey(), Provider.Roaming, Properties.Settings.Default.EnabledSupplyNotifier) { AutoSave = true }; + + public static SerializableProperty EnabledSortieSupplyNotifier { get; } + = new SerializableProperty(GetKey(), Provider.Roaming, Properties.Settings.Default.EnabledSortieSupplyNotifier) { AutoSave = true }; + + public static SerializableProperty EnabledExerciseSupplyNotifier { get; } + = new SerializableProperty(GetKey(), Provider.Roaming, Properties.Settings.Default.EnabledExerciseSupplyNotifier) { AutoSave = true }; + + public static SerializableProperty EnabledExpenditionSupplyNotifier { get; } + = new SerializableProperty(GetKey(), Provider.Roaming, Properties.Settings.Default.EnabledExpenditionSupplyNotifier) { AutoSave = true }; + + #endregion + + private static string GetKey([CallerMemberName] string propertyName = "") + { + return $"{nameof(NotifierSettings)}.{propertyName}"; + } + } +} diff --git a/NotifyEx/Models/Settings/Provider.cs b/NotifyEx/Models/Settings/Provider.cs new file mode 100644 index 0000000..2dd67b1 --- /dev/null +++ b/NotifyEx/Models/Settings/Provider.cs @@ -0,0 +1,19 @@ +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using MetroTrilithon.Serialization; + +namespace NotifyEx.Models.Settings +{ + public static class Provider + { + public static string RoamingPath { get; } = Path.Combine(Environment.GetFolderPath( + Environment.SpecialFolder.ApplicationData), + "grabacr.net", "KanColleViewer", "NotifyEx.xaml"); + + public static ISerializationProvider Roaming { get; } = new FileSettingsProvider(RoamingPath); + } +} diff --git a/NotifyEx/Models/ShipNotifier.cs b/NotifyEx/Models/ShipNotifier.cs index 78fb666..2b17b8a 100644 --- a/NotifyEx/Models/ShipNotifier.cs +++ b/NotifyEx/Models/ShipNotifier.cs @@ -9,6 +9,7 @@ using MetroTrilithon.Lifetime; using MetroTrilithon.Mvvm; using NotifyEx.Models.NotifyType; +using NotifyEx.Models.Settings; using NotifyEx.Properties; using StatefulModel; @@ -20,18 +21,16 @@ namespace NotifyEx.Models internal class ShipNotifier : NotificationObject, IWarningCounter, IDisposableHolder { public static ShipNotifier Current { get; } = new ShipNotifier(); - - private static readonly Settings Settings = Settings.Default; + public bool Enabled { - get { return Settings.EnabledShipNotifier; } + get { return NotifierSettings.EnabledShipNotifier.Value; } set { - if (Settings.EnabledShipNotifier != value) + if (NotifierSettings.EnabledShipNotifier.Value != value) { - Settings.EnabledShipNotifier = value; - Settings.Save(); + NotifierSettings.EnabledShipNotifier.Value = value; this.RaisePropertyChanged(); } } @@ -59,13 +58,12 @@ private set public uint NormalWarningCount { - get { return Settings.WarningShipCount; } + get { return NotifierSettings.ShipWarningCount.Value; } set { - if (Settings.WarningShipCount != value) + if (NotifierSettings.ShipWarningCount.Value != value) { - Settings.WarningShipCount = value; - Settings.Save(); + NotifierSettings.ShipWarningCount.Value = value; this.RaisePropertyChanged(); this.RaisePropertyChanged(nameof(this.WarningCount)); } @@ -74,13 +72,12 @@ public uint NormalWarningCount public bool EnabledEvent { - get { return Settings.EnabledEventShipNotifier; } + get { return NotifierSettings.EnabledEventShipNotifier.Value; } set { - if (Settings.EnabledEventShipNotifier != value) + if (NotifierSettings.EnabledEventShipNotifier.Value != value) { - Settings.EnabledEventShipNotifier = value; - Settings.Save(); + NotifierSettings.EnabledEventShipNotifier.Value = value; this.RaisePropertyChanged(); this.RaisePropertyChanged(nameof(this.WarningCount)); } @@ -89,13 +86,12 @@ public bool EnabledEvent public uint EventWarningCount { - get { return Settings.EventWarningShipCount; } + get { return NotifierSettings.EventShipWarningCount.Value; } set { - if (Settings.EventWarningShipCount != value) + if (NotifierSettings.EventShipWarningCount.Value != value) { - Settings.EventWarningShipCount = value; - Settings.Save(); + NotifierSettings.EventShipWarningCount.Value = value; this.RaisePropertyChanged(); this.RaisePropertyChanged(nameof(this.WarningCount)); } diff --git a/NotifyEx/Models/SlotNotifier.cs b/NotifyEx/Models/SlotNotifier.cs index b9fa220..3711777 100644 --- a/NotifyEx/Models/SlotNotifier.cs +++ b/NotifyEx/Models/SlotNotifier.cs @@ -10,6 +10,7 @@ using MetroTrilithon.Lifetime; using MetroTrilithon.Mvvm; using NotifyEx.Models.NotifyType; +using NotifyEx.Models.Settings; using NotifyEx.Properties; using StatefulModel; @@ -19,17 +20,14 @@ internal class SlotNotifier : NotificationObject, IWarningCounter, IDisposableHo { public static SlotNotifier Current { get; } = new SlotNotifier(); - private static readonly Settings Settings = Settings.Default; - public bool Enabled { - get { return Settings.EnabledSlotNotifier; } + get { return NotifierSettings.EnabledSlotNotifier.Value; } set { - if (Settings.EnabledSlotNotifier != value) + if (NotifierSettings.EnabledSlotNotifier.Value != value) { - Settings.EnabledSlotNotifier = value; - Settings.Save(); + NotifierSettings.EnabledSlotNotifier.Value = value; this.RaisePropertyChanged(); } } @@ -38,7 +36,7 @@ public bool Enabled public uint WarningCount => this.EnabledEvent && Util.IsInEvent ? this.EventWarningCount - : Settings.WarningSlotCount; + : this.NormalWarningCount; private uint _remain = uint.MaxValue; @@ -57,13 +55,12 @@ private set public uint NormalWarningCount { - get { return Settings.WarningSlotCount; } + get { return NotifierSettings.SlotWarningCount.Value; } set { - if (Settings.WarningSlotCount != value) + if (NotifierSettings.SlotWarningCount.Value != value) { - Settings.WarningSlotCount = value; - Settings.Save(); + NotifierSettings.SlotWarningCount.Value = value; this.RaisePropertyChanged(); this.RaisePropertyChanged(nameof(this.WarningCount)); } @@ -72,13 +69,12 @@ public uint NormalWarningCount public bool EnabledEvent { - get { return Settings.EnabledEventSlotNotifier; } + get { return NotifierSettings.EnabledEventSlotNotifier.Value; } set { - if (Settings.EnabledEventSlotNotifier != value) + if (NotifierSettings.EnabledEventSlotNotifier.Value != value) { - Settings.EnabledEventSlotNotifier = value; - Settings.Save(); + NotifierSettings.EnabledEventSlotNotifier.Value = value; this.RaisePropertyChanged(); this.RaisePropertyChanged(nameof(this.WarningCount)); } @@ -87,13 +83,12 @@ public bool EnabledEvent public uint EventWarningCount { - get { return Settings.EventWarningSlotCount; } + get { return NotifierSettings.EventSlotWarningCount.Value; } set { - if (Settings.EventWarningSlotCount != value) + if (NotifierSettings.EventSlotWarningCount.Value != value) { - Settings.EventWarningSlotCount = value; - Settings.Save(); + NotifierSettings.EventSlotWarningCount.Value = value; this.RaisePropertyChanged(); this.RaisePropertyChanged(nameof(this.WarningCount)); } diff --git a/NotifyEx/Models/SupplyNotifier.cs b/NotifyEx/Models/SupplyNotifier.cs index bbf5c2c..d5828fd 100644 --- a/NotifyEx/Models/SupplyNotifier.cs +++ b/NotifyEx/Models/SupplyNotifier.cs @@ -7,6 +7,7 @@ using Grabacr07.KanColleWrapper; using Grabacr07.KanColleWrapper.Models; using NotifyEx.Models.NotifyType; +using NotifyEx.Models.Settings; using NotifyEx.Properties; namespace NotifyEx.Models @@ -18,56 +19,50 @@ internal class SupplyNotifier { public static SupplyNotifier Current { get; } = new SupplyNotifier(); - private static readonly Settings Settings = Settings.Default; - public bool Enabled { - get { return Settings.EnabledSupplyNotifier; } + get { return NotifierSettings.EnabledSupplyNotifier.Value; } set { - if (Settings.EnabledSupplyNotifier != value) + if (NotifierSettings.EnabledSupplyNotifier.Value != value) { - Settings.EnabledSupplyNotifier = value; - Settings.Save(); + NotifierSettings.EnabledSupplyNotifier.Value = value; } } } public bool EnabledSortie { - get { return Settings.EnabledSortieSupplyNotifier; } + get { return NotifierSettings.EnabledSortieSupplyNotifier.Value; } set { - if (Settings.EnabledSortieSupplyNotifier != value) + if (NotifierSettings.EnabledSortieSupplyNotifier.Value != value) { - Settings.EnabledSortieSupplyNotifier = value; - Settings.Save(); + NotifierSettings.EnabledSortieSupplyNotifier.Value = value; } } } public bool EnabledExercise { - get { return Settings.EnabledExerciseSupplyNotifier; } + get { return NotifierSettings.EnabledExerciseSupplyNotifier.Value; } set { - if (Settings.EnabledExerciseSupplyNotifier != value) + if (NotifierSettings.EnabledExerciseSupplyNotifier.Value != value) { - Settings.EnabledExerciseSupplyNotifier = value; - Settings.Save(); + NotifierSettings.EnabledExerciseSupplyNotifier.Value = value; } } } public bool EnabledExpendition { - get { return Settings.EnabledExpenditionSupplyNotifier; } + get { return NotifierSettings.EnabledExpenditionSupplyNotifier.Value; } set { - if (Settings.EnabledExpenditionSupplyNotifier != value) + if (NotifierSettings.EnabledExpenditionSupplyNotifier.Value != value) { - Settings.EnabledExpenditionSupplyNotifier = value; - Settings.Save(); + NotifierSettings.EnabledExpenditionSupplyNotifier.Value = value; } } } diff --git a/NotifyEx/NotifyEx.csproj b/NotifyEx/NotifyEx.csproj index 177156b..17ea014 100644 --- a/NotifyEx/NotifyEx.csproj +++ b/NotifyEx/NotifyEx.csproj @@ -54,17 +54,16 @@ ..\packages\KanColleViewer.Controls.1.3.1\lib\net46\KanColleViewer.Controls.dll False - - ..\packages\KanColleViewer.PluginAnalyzer.1.1.0.0\lib\net46\KanColleViewer.PluginAnalyzer.dll + + ..\packages\KanColleViewer.PluginAnalyzer.1.1.1.0\lib\net46\KanColleViewer.PluginAnalyzer.dll False ..\packages\KanColleWrapper.1.4.0\lib\net46\KanColleWrapper.dll False - - ..\packages\LivetCask.1.1.0.0\lib\net45\Livet.dll - True + + ..\packages\LivetCask.1.3.1.0\lib\net45\Livet.dll False @@ -87,7 +86,13 @@ ..\packages\MetroTrilithon.0.1.7\lib\portable-net45+win+wp80+MonoAndroid10+xamarinios10+MonoTouch10\MetroTrilithon.dll False + + ..\packages\MetroTrilithon.Desktop.0.2.3\lib\net46\MetroTrilithon.Desktop.dll + False + + ..\packages\LivetCask.1.3.1.0\lib\net45\Microsoft.Expression.Interactions.dll + True False @@ -118,6 +123,8 @@ False + ..\packages\LivetCask.1.3.1.0\lib\net45\System.Windows.Interactivity.dll + True False @@ -142,6 +149,8 @@ + + @@ -188,8 +197,8 @@ - - + +