diff --git a/CookInformationViewer.sln b/CookInformationViewer.sln index eb2de79..1fc41fa 100644 --- a/CookInformationViewer.sln +++ b/CookInformationViewer.sln @@ -7,6 +7,14 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Updater", "Updater\Updater. EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "CookInformationViewer", "CookInformationViewer\CookInformationViewer.csproj", "{A5A55860-D4C1-4369-B652-0B1F3AA47FCE}" EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "UpdateLogs", "UpdateLogs", "{5D998BDD-0DD9-42F9-99E7-4A5DF64CE966}" + ProjectSection(SolutionItems) = preProject + UpdateLogs\notice.en.xml = UpdateLogs\notice.en.xml + UpdateLogs\notice.ja.xml = UpdateLogs\notice.ja.xml + UpdateLogs\updates.en.xml = UpdateLogs\updates.en.xml + UpdateLogs\updates.ja.xml = UpdateLogs\updates.ja.xml + EndProjectSection +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug Log|Any CPU = Debug Log|Any CPU diff --git a/CookInformationViewer/Constants.cs b/CookInformationViewer/Constants.cs index 4285d03..ca8bbaa 100644 --- a/CookInformationViewer/Constants.cs +++ b/CookInformationViewer/Constants.cs @@ -2,7 +2,7 @@ namespace CookInformationViewer { - public class Constants + public static class Constants { public const string Schema = "cookinfo"; @@ -17,12 +17,18 @@ public class Constants public const string DownloadHistoriesTableName = "download_histories"; public const string CookAdditionalsTableName = "cook_additionals"; - public const string DatabaseFileName = "CookInfo.dat"; + public const string DatabaseFileName = "Data\\CookInfo.dat"; - public static string Version => CommonCoreLib.File.Version.GetVersion(); /* + "b";*/ + public static string Version => CommonCoreLib.File.Version.GetVersion() + "b"; public const string UpdateUrlFile = "UpdateUrl.xml"; public static readonly string AppDirectoryPath = AppInfo.GetAppPath(); public static readonly string UpdaterFilePath = AppDirectoryPath + @"\Updater\update.exe"; + +#if DEBUG + public static readonly bool IsDebugMode = true; +#else + public static readonly bool IsDebugMode = false; +#endif } } diff --git a/CookInformationViewer/CookInformationViewer.csproj b/CookInformationViewer/CookInformationViewer.csproj index 3949a69..fd11f3c 100644 --- a/CookInformationViewer/CookInformationViewer.csproj +++ b/CookInformationViewer/CookInformationViewer.csproj @@ -25,20 +25,24 @@ + + + + - + diff --git a/CookInformationViewer/Models/Db/SqlExecutor.cs b/CookInformationViewer/Models/Db/SqlExecutor.cs index 4a07f48..39906fe 100644 --- a/CookInformationViewer/Models/Db/SqlExecutor.cs +++ b/CookInformationViewer/Models/Db/SqlExecutor.cs @@ -23,6 +23,18 @@ public SqlExecutor(string source, bool register = false) File.Delete(source); } + var fileInfo = new FileInfo(source); + if (!fileInfo.Exists) + { + var parent = Path.GetDirectoryName(fileInfo.FullName); + if (string.IsNullOrEmpty(parent)) + throw new DirectoryNotFoundException(fileInfo.FullName); + + var di = new DirectoryInfo(parent); + if (!di.Exists) + di.Create(); + } + _connection = new SqliteConnection($"Data Source={source}"); _connection.Open(); } diff --git a/CookInformationViewer/Models/OverlayModel.cs b/CookInformationViewer/Models/OverlayModel.cs index 444f14c..b0a2f11 100644 --- a/CookInformationViewer/Models/OverlayModel.cs +++ b/CookInformationViewer/Models/OverlayModel.cs @@ -4,11 +4,14 @@ using System.Linq; using System.Text; using System.Threading.Tasks; +using CookInformationViewer.Models.Settings; namespace CookInformationViewer.Models { public class OverlayModel : ModelBase { + private SettingLoader _setting; + private RecipeInfo? _selectedRecipe; public RecipeInfo? SelectedRecipe @@ -16,5 +19,31 @@ public RecipeInfo? SelectedRecipe get => _selectedRecipe; set => SetProperty(ref _selectedRecipe, value); } + + public bool Closed { get; set; } + + public OverlayModel() + { + _setting = SettingLoader.Instance; + + LoadSetting(); + } + + public void LoadSetting() + { + var overlayLeft = _setting.OverlayLeft; + var overlayTop = _setting.OverlayTop; + + Left = overlayLeft; + Top = overlayTop; + } + + public void SaveSetting() + { + _setting.OverlayLeft = Left; + _setting.OverlayTop = Top; + + _setting.Save(); + } } } diff --git a/CookInformationViewer/Models/Settings/SettingLoader.cs b/CookInformationViewer/Models/Settings/SettingLoader.cs index c9ac8be..45bfad4 100644 --- a/CookInformationViewer/Models/Settings/SettingLoader.cs +++ b/CookInformationViewer/Models/Settings/SettingLoader.cs @@ -9,6 +9,9 @@ namespace CookInformationViewer.Models.Settings { public class SettingLoader { + public const double DefaultOverlayLeft = 10; + public const double DefaultOverlayTop = 10; + public static SettingLoader Instance { get; } = new(); private readonly IniLoader _iniLoader; @@ -20,6 +23,9 @@ public class SettingLoader public bool IsCheckDataUpdate { get; set; } public bool IsCheckProgramUpdate { get; set; } + public double OverlayLeft { get; set; } + public double OverlayTop { get; set; } + #endregion private SettingLoader() @@ -33,12 +39,16 @@ public void Load() { IsCheckDataUpdate = _iniLoader.GetValue(MainClassName, nameof(IsCheckDataUpdate), true); IsCheckProgramUpdate = _iniLoader.GetValue(MainClassName, nameof(IsCheckProgramUpdate), true); + OverlayLeft = _iniLoader.GetValue(MainClassName, nameof(OverlayLeft), DefaultOverlayLeft); + OverlayTop = _iniLoader.GetValue(MainClassName, nameof(OverlayTop), DefaultOverlayTop); } public void Save() { _iniLoader.SetValue(MainClassName, nameof(IsCheckDataUpdate), IsCheckDataUpdate); _iniLoader.SetValue(MainClassName, nameof(IsCheckProgramUpdate), IsCheckProgramUpdate); + _iniLoader.SetValue(MainClassName, nameof(OverlayLeft), OverlayLeft); + _iniLoader.SetValue(MainClassName, nameof(OverlayTop), OverlayTop); } } } diff --git a/CookInformationViewer/Models/Settings/SettingModel.cs b/CookInformationViewer/Models/Settings/SettingModel.cs index 3b74d9e..d5c674b 100644 --- a/CookInformationViewer/Models/Settings/SettingModel.cs +++ b/CookInformationViewer/Models/Settings/SettingModel.cs @@ -42,6 +42,12 @@ public SettingModel() IsCheckProgram = _settingLoader.IsCheckProgramUpdate; } + public void ResetOverlayPosition() + { + _settingLoader.OverlayLeft = SettingLoader.DefaultOverlayLeft; + _settingLoader.OverlayTop = SettingLoader.DefaultOverlayTop; + } + public void Save() { _settingLoader.IsCheckDataUpdate = IsCheckAutoData; diff --git a/CookInformationViewer/Resources/gauge.png b/CookInformationViewer/Resources/gauge.png index bfde3bd..e7c9795 100644 Binary files a/CookInformationViewer/Resources/gauge.png and b/CookInformationViewer/Resources/gauge.png differ diff --git a/CookInformationViewer/Resources/gauge2.png b/CookInformationViewer/Resources/gauge2.png new file mode 100644 index 0000000..5c72bd1 Binary files /dev/null and b/CookInformationViewer/Resources/gauge2.png differ diff --git a/CookInformationViewer/Resources/gauge_overlay2.png b/CookInformationViewer/Resources/gauge_overlay2.png new file mode 100644 index 0000000..1d69176 Binary files /dev/null and b/CookInformationViewer/Resources/gauge_overlay2.png differ diff --git a/CookInformationViewer/Styles/Gauge.xaml b/CookInformationViewer/Styles/Gauge.xaml index dc8061e..f725b0f 100644 --- a/CookInformationViewer/Styles/Gauge.xaml +++ b/CookInformationViewer/Styles/Gauge.xaml @@ -4,7 +4,7 @@ @@ -12,7 +12,7 @@ diff --git a/CookInformationViewer/Styles/Window.xaml b/CookInformationViewer/Styles/Window.xaml index 7f0cc73..4a7d919 100644 --- a/CookInformationViewer/Styles/Window.xaml +++ b/CookInformationViewer/Styles/Window.xaml @@ -25,4 +25,24 @@ + + \ No newline at end of file diff --git a/CookInformationViewer/ViewModels/MainWindowViewModel.cs b/CookInformationViewer/ViewModels/MainWindowViewModel.cs index 5a39c08..0a78fa9 100644 --- a/CookInformationViewer/ViewModels/MainWindowViewModel.cs +++ b/CookInformationViewer/ViewModels/MainWindowViewModel.cs @@ -38,7 +38,9 @@ public class MainWindowViewModel : ViewModelWindowStyleBase private readonly MainWindowWindowService _mainWindowService; private readonly MainWindowModel _model; - private readonly OverlayModel _overlayModel = new(); + + private OverlayModel? _overlayModel; + private MainWindowWindowService? _overlayWindowService; private readonly Stack _historyBack = new(); private readonly Stack _historyForward = new(); @@ -47,6 +49,8 @@ public class MainWindowViewModel : ViewModelWindowStyleBase #region Properties + public bool IsDebugMode => Constants.IsDebugMode; + public ReactiveProperty UnderMessageLabelText { get; set; } public ReactiveProperty CanGoBack { get; set; } @@ -66,6 +70,7 @@ public class MainWindowViewModel : ViewModelWindowStyleBase #region Event Properties public ICommand OpenSettingCommand { get; set; } + public ICommand OpenDatabaseCommand { get; set; } public ICommand OpenSearchWindowCommand { get; set; } public ICommand UpdateTableCommand { get; set; } public ICommand OpenUpdateProgramCommand { get; set; } @@ -107,6 +112,7 @@ public MainWindowViewModel(MainWindowWindowService windowService, MainWindowMode SelectedRecipe = new ReactiveProperty(); OpenSettingCommand = new DelegateCommand(OpenSetting); + OpenDatabaseCommand = new DelegateCommand(OpenDatabase); OpenSearchWindowCommand = new DelegateCommand(OpenSearchWindow); UpdateTableCommand = new DelegateCommand(UpdateTable); OpenUpdateProgramCommand = new DelegateCommand(OpenUpdateProgram); @@ -168,6 +174,11 @@ public void OpenSetting() WindowManageService.ShowDialog(vm); } + public void OpenDatabase() + { + using var p = Process.Start("C:\\Valve\\DB Browser for SQLite\\DB Browser for SQLite.exe", Constants.DatabaseFileName); + } + public void OpenSearchWindow() { var model = new SearchWindowModel(); @@ -216,7 +227,6 @@ public void RecipesListSelectionChanged(RecipeInfo? recipe) _model.SelectRecipe(recipe); SelectedRecipe.Value = recipe; - _overlayModel.SelectedRecipe = recipe; _historyBack.Clear(); _historyForward.Clear(); @@ -235,20 +245,28 @@ public void RecipesListSelectionChanged(RecipeInfo? recipe) public void OpenOverlay() { + if (_overlayModel != null && !_overlayModel.Closed) + { + _overlayModel.SelectedRecipe = SelectedRecipe.Value; + + return; + } + var windowService = new MainWindowWindowService(); + var model = new OverlayModel + { + SelectedRecipe = SelectedRecipe.Value + }; + _overlayModel = model; + _overlayWindowService = windowService; + WindowManageService.ShowNonOwner(window => { windowService.GaugeResize = window; - var vm = new OverlayViewModel(windowService, _overlayModel); + windowService.MainWindow = _mainWindowService.MainWindow; + var vm = new OverlayViewModel(windowService, model); return vm; }); - - //if (windowService.GaugeResize == null) - // return; - - //windowService.GaugeResize.SetGaugeLength((double)SelectedRecipe.Value.Item1Amount, 0); - //windowService.GaugeResize.SetGaugeLength((double)SelectedRecipe.Value.Item2Amount, 1); - //windowService.GaugeResize.SetGaugeLength((double)SelectedRecipe.Value.Item3Amount, 2); } public void NavigateBack() @@ -346,6 +364,7 @@ public override void Dispose() { base.Dispose(); + _overlayWindowService?.Close(); _model.Dispose(); } diff --git a/CookInformationViewer/ViewModels/OverlayViewModel.cs b/CookInformationViewer/ViewModels/OverlayViewModel.cs index c165892..d43e875 100644 --- a/CookInformationViewer/ViewModels/OverlayViewModel.cs +++ b/CookInformationViewer/ViewModels/OverlayViewModel.cs @@ -22,6 +22,7 @@ namespace CookInformationViewer.ViewModels public class OverlayViewModel : ViewModelWindowStyleBase { private MainWindowWindowService _mainWindowService; + private OverlayModel _model; public ReactiveProperty SelectedRecipe { get; set; } @@ -36,6 +37,7 @@ public class OverlayViewModel : ViewModelWindowStyleBase public OverlayViewModel(MainWindowWindowService windowService, OverlayModel model) : base(windowService, model) { _mainWindowService = windowService; + _model = model; SelectedRecipe = model.ObserveProperty(x => x.SelectedRecipe).ToReactiveProperty() .AddTo(CompositeDisposable); @@ -44,6 +46,9 @@ public OverlayViewModel(MainWindowWindowService windowService, OverlayModel mode if (model.SelectedRecipe == null || windowService.GaugeResize == null) return; + //windowService.GaugeResize.SetGaugeLength((double)Math.Ceiling((244 * (model.SelectedRecipe.Item1Amount / 100))), 0); + //windowService.GaugeResize.SetGaugeLength((double)Math.Ceiling((244 * (model.SelectedRecipe.Item2Amount / 100))), 1); + //windowService.GaugeResize.SetGaugeLength((double)Math.Ceiling((244 * (model.SelectedRecipe.Item3Amount / 100))), 2); windowService.GaugeResize.SetGaugeLength((double)model.SelectedRecipe.Item1Amount, 0); windowService.GaugeResize.SetGaugeLength((double)model.SelectedRecipe.Item2Amount, 1); windowService.GaugeResize.SetGaugeLength((double)model.SelectedRecipe.Item3Amount, 2); @@ -72,7 +77,7 @@ public void DoTransparent() Opacity.Value = .2; TransparentButtonVisibility.Value = Visibility.Collapsed; WindowBackground.Value = new SolidColorBrush(Colors.Transparent); - WindowManageService.Owner.BorderBrush = new SolidColorBrush(Colors.Transparent); + //WindowManageService.Owner.BorderBrush = new SolidColorBrush(Colors.Transparent); TransparentChecked.Value = true; } @@ -97,9 +102,24 @@ public void ChangeTransparent(bool? arg) else WindowBackground.Value = new SolidColorBrush(Colors.Transparent); - if (WindowManageService.Owner.FindResource("AroundBorderColor") is SolidColorBrush color) - WindowManageService.Owner.BorderBrush = color; + //if (WindowManageService.Owner.FindResource("AroundBorderColor") is SolidColorBrush color) + // WindowManageService.Owner.BorderBrush = color; } } + + protected override void MainWindowCloseBt_Click() + { + _mainWindowService.MainWindow?.WindowFocus(); + + base.MainWindowCloseBt_Click(); + } + + public override void Dispose() + { + base.Dispose(); + + _model.SaveSetting(); + _model.Closed = true; + } } } diff --git a/CookInformationViewer/ViewModels/Settings/SettingViewModel.cs b/CookInformationViewer/ViewModels/Settings/SettingViewModel.cs index d7d44c7..46f9bcc 100644 --- a/CookInformationViewer/ViewModels/Settings/SettingViewModel.cs +++ b/CookInformationViewer/ViewModels/Settings/SettingViewModel.cs @@ -5,6 +5,7 @@ using System.Text.RegularExpressions; using System.Threading.Tasks; using System.Windows.Input; +using CommonStyleLib.ExMessageBox; using CommonStyleLib.Models; using CommonStyleLib.ViewModels; using CommonStyleLib.Views; @@ -33,6 +34,8 @@ public class SettingViewModel : ViewModelWindowStyleBase #region Event Properties + public ICommand ResetOverlayPositionCommand { get; set; } + public ICommand SaveCommand { get; set; } #endregion @@ -44,9 +47,18 @@ public SettingViewModel(IWindowService windowService, SettingModel model) : base IsCheckAutoData = model.ToReactivePropertyAsSynchronized(x => x.IsCheckAutoData).AddTo(CompositeDisposable); IsCheckProgram = model.ToReactivePropertyAsSynchronized(x => x.IsCheckProgram).AddTo(CompositeDisposable); + ResetOverlayPositionCommand = new DelegateCommand(ResetOverlayPosition); SaveCommand = new DelegateCommand(Save); } + public void ResetOverlayPosition() + { + _model.ResetOverlayPosition(); + + WindowManageService.MessageBoxShow("オーバーレイウィンドウの座標をリセットしました。OKを押すと確定されます。", + "リセット完了", ExMessageBoxBase.MessageType.Exclamation); + } + public void Save() { _model.Save(); diff --git a/CookInformationViewer/Views/MainWindow.xaml b/CookInformationViewer/Views/MainWindow.xaml index 2ad0af1..b7856c3 100644 --- a/CookInformationViewer/Views/MainWindow.xaml +++ b/CookInformationViewer/Views/MainWindow.xaml @@ -83,9 +83,7 @@ - - - + @@ -139,7 +137,17 @@ - + + + + + + + + + +