diff --git a/speed-time/Dialogs/TrackTimeEditor.xaml.cs b/speed-time/Dialogs/TrackTimeEditor.xaml.cs index 2b7fc86..c4fed34 100644 --- a/speed-time/Dialogs/TrackTimeEditor.xaml.cs +++ b/speed-time/Dialogs/TrackTimeEditor.xaml.cs @@ -67,6 +67,11 @@ public TrackTimeEditor(TrackTime? trackTime = null) }; } + public TrackTimeEditor(DateTime startDate): this() + { + SelectedDate = startDate; + } + private void SaveAndClose() { if (string.IsNullOrEmpty(TrackTimeTitle)) diff --git a/speed-time/Model/FileDataService.cs b/speed-time/Model/FileDataService.cs index b788f00..aaa8e39 100644 --- a/speed-time/Model/FileDataService.cs +++ b/speed-time/Model/FileDataService.cs @@ -1,4 +1,5 @@ -using DSaladin.SpeedTime.Dialogs; +using DSaladin.FancyPotato; +using DSaladin.SpeedTime.Dialogs; using DSaladin.SpeedTime.Properties; using System; using System.Collections.Generic; @@ -14,19 +15,14 @@ namespace DSaladin.SpeedTime.Model { internal class FileDataService : IDataService { - private const string PUBLISHER = "DSaladin"; - private const string APPNAME = "speed-time"; - private const string FILENAME = "usersettings.json"; + private const string CONFIG_NAME = "usersettings.json"; public async Task LoadSettings() { - string appDataPath = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData); - string filePath = Path.Combine(appDataPath, PUBLISHER, APPNAME, FILENAME); - SettingsModel? settings = null; try { - FileStream stream = File.OpenRead(filePath); + FileStream stream = File.OpenRead(DSApplication.GetSettingsFilePath(CONFIG_NAME)); settings = await JsonSerializer.DeserializeAsync(stream); stream.Close(); } @@ -44,11 +40,10 @@ public async Task SaveSettings() var stream = new MemoryStream(); await JsonSerializer.SerializeAsync(stream, SettingsModel.Instance); - string appDataPath = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData); - string appFolderPath = Path.Combine(appDataPath, PUBLISHER, APPNAME); - Directory.CreateDirectory(appFolderPath); + string filePath = DSApplication.GetSettingsFilePath(CONFIG_NAME); + Directory.CreateDirectory(Path.GetDirectoryName(filePath)!); - File.WriteAllText(Path.Combine(appFolderPath, FILENAME), Encoding.UTF8.GetString(stream.ToArray())); + File.WriteAllText(filePath, Encoding.UTF8.GetString(stream.ToArray())); stream.Close(); } } diff --git a/speed-time/ViewModel/MainWindowViewModel.cs b/speed-time/ViewModel/MainWindowViewModel.cs index 628c5ac..0a91ac1 100644 --- a/speed-time/ViewModel/MainWindowViewModel.cs +++ b/speed-time/ViewModel/MainWindowViewModel.cs @@ -154,7 +154,7 @@ public MainWindowViewModel() return; IsTrackTimeEditorOpen = true; - TrackTime? newTime = await ShowDialog(new TrackTimeEditor()); + TrackTime? newTime = await ShowDialog(new TrackTimeEditor(CurrentDateTime)); IsTrackTimeEditorOpen = false; if (newTime is not null) diff --git a/speed-time/speed-time.csproj b/speed-time/speed-time.csproj index c625d04..8531e28 100644 --- a/speed-time/speed-time.csproj +++ b/speed-time/speed-time.csproj @@ -19,7 +19,7 @@ README.md Icon.ico LICENSE.txt - 0.14.1 + 0.14.2 True @@ -44,7 +44,7 @@ - +