Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
AonaSuzutsuki committed Feb 23, 2023
2 parents e228db1 + dfbaff5 commit d8736df
Show file tree
Hide file tree
Showing 26 changed files with 253 additions and 70 deletions.
8 changes: 8 additions & 0 deletions CookInformationViewer.sln
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
12 changes: 9 additions & 3 deletions CookInformationViewer/Constants.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

namespace CookInformationViewer
{
public class Constants
public static class Constants
{
public const string Schema = "cookinfo";

Expand All @@ -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
}
}
6 changes: 5 additions & 1 deletion CookInformationViewer/CookInformationViewer.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -25,20 +25,24 @@

<ItemGroup>
<None Remove="Resources\gauge.png" />
<None Remove="Resources\gauge2.png" />
<None Remove="Resources\gauge_overlay.png" />
<None Remove="Resources\gauge_overlay2.png" />
<None Remove="Resources\line.png" />
<None Remove="Resources\no-image.png" />
</ItemGroup>

<ItemGroup>
<Resource Include="Resources\gauge.png" />
<Resource Include="Resources\gauge2.png" />
<Resource Include="Resources\gauge_overlay.png" />
<Resource Include="Resources\gauge_overlay2.png" />
<Resource Include="Resources\line.png" />
<EmbeddedResource Include="Resources\no-image.png" />
</ItemGroup>

<ItemGroup>
<PackageReference Include="CommonCoreLib" Version="1.0.4" />
<PackageReference Include="CommonCoreLib" Version="1.0.6" />
<PackageReference Include="CommonStyleLib" Version="1.0.22" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="6.0.11" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.2" />
Expand Down
12 changes: 12 additions & 0 deletions CookInformationViewer/Models/Db/SqlExecutor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
Expand Down
29 changes: 29 additions & 0 deletions CookInformationViewer/Models/OverlayModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,46 @@
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
{
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();
}
}
}
10 changes: 10 additions & 0 deletions CookInformationViewer/Models/Settings/SettingLoader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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()
Expand All @@ -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);
}
}
}
6 changes: 6 additions & 0 deletions CookInformationViewer/Models/Settings/SettingModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Binary file modified CookInformationViewer/Resources/gauge.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added CookInformationViewer/Resources/gauge2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions CookInformationViewer/Styles/Gauge.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@
<Style x:Key="SmallSizeGauge" TargetType="Image">
<Setter Property="Margin" Value="0,4,0,0" />
<Setter Property="Source" Value="/Resources/line.png" />
<Setter Property="HorizontalAlignment" Value="Left" />
<Setter Property="HorizontalAlignment" Value="Right" />
<Setter Property="Stretch" Value="Fill" />
<Setter Property="Height" Value="5" />
</Style>


<Style x:Key="NormalSizeGauge" TargetType="Image">
<Setter Property="Source" Value="/Resources/line.png" />
<Setter Property="HorizontalAlignment" Value="Left" />
<Setter Property="HorizontalAlignment" Value="Right" />
<Setter Property="Stretch" Value="Fill" />
<Setter Property="Height" Value="10" />
</Style>
Expand Down
20 changes: 20 additions & 0 deletions CookInformationViewer/Styles/Window.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,24 @@
<Setter Property="Foreground" Value="White"/>
</Style>

<Style TargetType="{x:Type Window}" x:Key="NoneCaptionWindowStyle">
<Setter Property="WindowChrome.WindowChrome">
<Setter.Value>
<WindowChrome
CornerRadius="0"
GlassFrameThickness="0"
ResizeBorderThickness="0"
UseAeroCaptionButtons="False"
CaptionHeight="0" />
</Setter.Value>
</Setter>
<Setter Property="SnapsToDevicePixels" Value="True"/>
<Setter Property="UseLayoutRounding" Value="True"/>
<Setter Property="Background" Value="{StaticResource MainColor}"/>
<Setter Property="BorderBrush" Value="{StaticResource AroundBorderColor}"/>
<Setter Property="Opacity" Value="1"></Setter>
<Setter Property="BorderThickness" Value="1"/>
<Setter Property="Foreground" Value="White"/>
</Style>

</ResourceDictionary>
39 changes: 29 additions & 10 deletions CookInformationViewer/ViewModels/MainWindowViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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<RecipeInfo> _historyBack = new();
private readonly Stack<RecipeInfo> _historyForward = new();
Expand All @@ -47,6 +49,8 @@ public class MainWindowViewModel : ViewModelWindowStyleBase

#region Properties

public bool IsDebugMode => Constants.IsDebugMode;

public ReactiveProperty<string> UnderMessageLabelText { get; set; }

public ReactiveProperty<bool> CanGoBack { get; set; }
Expand All @@ -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; }
Expand Down Expand Up @@ -107,6 +112,7 @@ public MainWindowViewModel(MainWindowWindowService windowService, MainWindowMode
SelectedRecipe = new ReactiveProperty<RecipeInfo?>();

OpenSettingCommand = new DelegateCommand(OpenSetting);
OpenDatabaseCommand = new DelegateCommand(OpenDatabase);
OpenSearchWindowCommand = new DelegateCommand(OpenSearchWindow);
UpdateTableCommand = new DelegateCommand(UpdateTable);
OpenUpdateProgramCommand = new DelegateCommand(OpenUpdateProgram);
Expand Down Expand Up @@ -168,6 +174,11 @@ public void OpenSetting()
WindowManageService.ShowDialog<SettingView>(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();
Expand Down Expand Up @@ -216,7 +227,6 @@ public void RecipesListSelectionChanged(RecipeInfo? recipe)

_model.SelectRecipe(recipe);
SelectedRecipe.Value = recipe;
_overlayModel.SelectedRecipe = recipe;

_historyBack.Clear();
_historyForward.Clear();
Expand All @@ -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<Overlay>(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()
Expand Down Expand Up @@ -346,6 +364,7 @@ public override void Dispose()
{
base.Dispose();

_overlayWindowService?.Close();
_model.Dispose();
}

Expand Down
26 changes: 23 additions & 3 deletions CookInformationViewer/ViewModels/OverlayViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ namespace CookInformationViewer.ViewModels
public class OverlayViewModel : ViewModelWindowStyleBase
{
private MainWindowWindowService _mainWindowService;
private OverlayModel _model;

public ReactiveProperty<RecipeInfo?> SelectedRecipe { get; set; }

Expand All @@ -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);
Expand All @@ -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);
Expand Down Expand Up @@ -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;
}

Expand All @@ -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;
}
}
}
Loading

0 comments on commit d8736df

Please sign in to comment.