diff --git a/source/XIVNote/Note.cs b/source/XIVNote/Note.cs index 4ff14c7..3335ceb 100644 --- a/source/XIVNote/Note.cs +++ b/source/XIVNote/Note.cs @@ -15,9 +15,14 @@ namespace XIVNote [Serializable] public partial class Note : BindableBase { - public Note() + public void SetAutoSave() { this.PropertyChanged += (_, __) => Notes.Instance.EnqueueSave(); + + foreach (var image in this.ImageList) + { + image.SetAutoSave(); + } } [XmlIgnore] @@ -325,7 +330,7 @@ private async void ExecuteAddImageCommand() var storeFileName = $"{Guid.NewGuid()}.png"; var storeFilePath = Path.Combine(@".\images", storeFileName); - // PNGŒ`Ž®‚É•ÏŠ·‚µ‚Ä•Û‘¶‚·‚é + // PNGå½¢å¼ã«å¤‰æ›ã—ã¦ä¿å­˜ã™ã‚‹ await Task.Run(() => { using (var ms = new WrappingStream(new MemoryStream(File.ReadAllBytes(fileName)))) @@ -407,7 +412,7 @@ private async void ExecuteRefreshCommand() [Serializable] public class NoteImage : BindableBase { - public NoteImage() + public void SetAutoSave() { this.PropertyChanged += (_, __) => Notes.Instance.EnqueueSave(); } diff --git a/source/XIVNote/Notes.cs b/source/XIVNote/Notes.cs index 77aec32..5a4c889 100644 --- a/source/XIVNote/Notes.cs +++ b/source/XIVNote/Notes.cs @@ -78,9 +78,7 @@ public void Load( this.NoteList.AddRange(data, true); } } - } - finally - { + if (!this.NoteList.Any(x => x.IsDefault)) { this.NoteList.Add(Note.DefaultNoteStyle); @@ -88,6 +86,13 @@ public void Load( this.NoteList.CollectionChanged += (_, __) => this.EnqueueSave(); + foreach (var note in this.NoteList) + { + note.SetAutoSave(); + } + } + finally + { this.isLoading = false; } } @@ -338,13 +343,13 @@ private static void RefreshFFXIVIsActive() { try { - // ƒtƒHƒAƒOƒ‰ƒEƒ“ƒhWindow‚̃nƒ“ƒhƒ‹‚ðŽæ“¾‚·‚é + // フォアグラウンドWindowã®ãƒãƒ³ãƒ‰ãƒ«ã‚’å–å¾—ã™ã‚‹ var hWnd = NativeMethods.GetForegroundWindow(); - // ƒvƒƒZƒXID‚É•ÏŠ·‚·‚é + // プロセスIDã«å¤‰æ›ã™ã‚‹ NativeMethods.GetWindowThreadProcessId(hWnd, out uint pid); - // ƒtƒHƒAƒEƒBƒ“ƒhƒE‚̃tƒ@ƒCƒ‹–¼‚ðŽæ“¾‚·‚é + // フォアウィンドウã®ãƒ•ã‚¡ã‚¤ãƒ«åã‚’å–å¾—ã™ã‚‹ var p = Process.GetProcessById((int)pid); if (p != null) { diff --git a/source/XIVNote/Properties/AssemblyInfo.cs b/source/XIVNote/Properties/AssemblyInfo.cs index e3ae970..a8fb7d0 100644 --- a/source/XIVNote/Properties/AssemblyInfo.cs +++ b/source/XIVNote/Properties/AssemblyInfo.cs @@ -15,4 +15,4 @@ ResourceDictionaryLocation.None, ResourceDictionaryLocation.SourceAssembly )] -[assembly: AssemblyVersion("2.1.4.0")] +[assembly: AssemblyVersion("2.1.5.0")] diff --git a/source/XIVNote/ViewModels/WidgetViewModel.cs b/source/XIVNote/ViewModels/WidgetViewModel.cs index 518800f..2a00f4f 100644 --- a/source/XIVNote/ViewModels/WidgetViewModel.cs +++ b/source/XIVNote/ViewModels/WidgetViewModel.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Threading.Tasks; using System.Windows.Threading; using aframe; @@ -75,7 +75,7 @@ private static DispatcherTimer CreateAutoSaveTimer() { var timer = new DispatcherTimer(DispatcherPriority.ContextIdle) { - Interval = TimeSpan.FromSeconds(5), + Interval = TimeSpan.FromSeconds(7), }; timer.Tick += async (_, __) => @@ -83,7 +83,7 @@ private static DispatcherTimer CreateAutoSaveTimer() if (IsSaveQueue) { IsSaveQueue = false; - await Task.Run(Notes.Instance.Save); + Notes.Instance.EnqueueSave(); } };