Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
anoyetta committed Dec 9, 2019
2 parents e67956a + 82d2e29 commit 3ab3c38
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 13 deletions.
11 changes: 8 additions & 3 deletions source/XIVNote/Note.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down Expand Up @@ -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))))
Expand Down Expand Up @@ -407,7 +412,7 @@ private async void ExecuteRefreshCommand()
[Serializable]
public class NoteImage : BindableBase
{
public NoteImage()
public void SetAutoSave()
{
this.PropertyChanged += (_, __) => Notes.Instance.EnqueueSave();
}
Expand Down
17 changes: 11 additions & 6 deletions source/XIVNote/Notes.cs
Original file line number Diff line number Diff line change
Expand Up @@ -78,16 +78,21 @@ public void Load(
this.NoteList.AddRange(data, true);
}
}
}
finally
{

if (!this.NoteList.Any(x => x.IsDefault))
{
this.NoteList.Add(Note.DefaultNoteStyle);
}

this.NoteList.CollectionChanged += (_, __) => this.EnqueueSave();

foreach (var note in this.NoteList)
{
note.SetAutoSave();
}
}
finally
{
this.isLoading = false;
}
}
Expand Down Expand Up @@ -338,13 +343,13 @@ private static void RefreshFFXIVIsActive()
{
try
{
// フォアグラウンドWindowのハンドルを取得する
// フォアグラウンドWindowのハンドルを取得する
var hWnd = NativeMethods.GetForegroundWindow();

// プロセスIDに変換する
// プロセスIDに変換する
NativeMethods.GetWindowThreadProcessId(hWnd, out uint pid);

// フォアウィンドウのファイル名を取得する
// フォアウィンドウのファイル名を取得する
var p = Process.GetProcessById((int)pid);
if (p != null)
{
Expand Down
2 changes: 1 addition & 1 deletion source/XIVNote/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,4 @@
ResourceDictionaryLocation.None,
ResourceDictionaryLocation.SourceAssembly
)]
[assembly: AssemblyVersion("2.1.4.0")]
[assembly: AssemblyVersion("2.1.5.0")]
6 changes: 3 additions & 3 deletions source/XIVNote/ViewModels/WidgetViewModel.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using System;
using System;
using System.Threading.Tasks;
using System.Windows.Threading;
using aframe;
Expand Down Expand Up @@ -75,15 +75,15 @@ private static DispatcherTimer CreateAutoSaveTimer()
{
var timer = new DispatcherTimer(DispatcherPriority.ContextIdle)
{
Interval = TimeSpan.FromSeconds(5),
Interval = TimeSpan.FromSeconds(7),
};

timer.Tick += async (_, __) =>
{
if (IsSaveQueue)
{
IsSaveQueue = false;
await Task.Run(Notes.Instance.Save);
Notes.Instance.EnqueueSave();
}
};

Expand Down

0 comments on commit 3ab3c38

Please sign in to comment.