Merge pull request #55 from ww-rm/dev/wpf

Dev/wpf
This commit is contained in:
ww-rm
2025-06-19 23:22:35 +08:00
committed by GitHub
10 changed files with 39 additions and 18 deletions

View File

@@ -1,5 +1,14 @@
# CHANGELOG # CHANGELOG
## v0.15.2
- 修复首选项文件读取为空时的提示信息
- 工作区参数增加浏览路径
## v0.15.1
- 新版本正式发布
## v0.15.0 ## v0.15.0
### 项目分支变更 ### 项目分支变更

View File

@@ -7,7 +7,7 @@
<TargetFramework>net8.0-windows</TargetFramework> <TargetFramework>net8.0-windows</TargetFramework>
<BaseOutputPath>$(SolutionDir)out</BaseOutputPath> <BaseOutputPath>$(SolutionDir)out</BaseOutputPath>
<IncludeSourceRevisionInInformationalVersion>false</IncludeSourceRevisionInInformationalVersion> <IncludeSourceRevisionInInformationalVersion>false</IncludeSourceRevisionInInformationalVersion>
<Version>0.15.1</Version> <Version>0.15.2</Version>
<UseWPF>true</UseWPF> <UseWPF>true</UseWPF>
</PropertyGroup> </PropertyGroup>

View File

@@ -7,7 +7,7 @@
<TargetFramework>net8.0-windows</TargetFramework> <TargetFramework>net8.0-windows</TargetFramework>
<BaseOutputPath>$(SolutionDir)out</BaseOutputPath> <BaseOutputPath>$(SolutionDir)out</BaseOutputPath>
<IncludeSourceRevisionInInformationalVersion>false</IncludeSourceRevisionInInformationalVersion> <IncludeSourceRevisionInInformationalVersion>false</IncludeSourceRevisionInInformationalVersion>
<Version>0.15.1</Version> <Version>0.15.2</Version>
<UseWPF>true</UseWPF> <UseWPF>true</UseWPF>
</PropertyGroup> </PropertyGroup>

View File

@@ -7,7 +7,7 @@
<TargetFramework>net8.0-windows</TargetFramework> <TargetFramework>net8.0-windows</TargetFramework>
<BaseOutputPath>$(SolutionDir)out</BaseOutputPath> <BaseOutputPath>$(SolutionDir)out</BaseOutputPath>
<IncludeSourceRevisionInInformationalVersion>false</IncludeSourceRevisionInInformationalVersion> <IncludeSourceRevisionInInformationalVersion>false</IncludeSourceRevisionInInformationalVersion>
<Version>0.15.1</Version> <Version>0.15.2</Version>
</PropertyGroup> </PropertyGroup>
<PropertyGroup> <PropertyGroup>

View File

@@ -12,6 +12,7 @@ namespace SpineViewer.Models
{ {
public class WorkspaceModel public class WorkspaceModel
{ {
public string? ExploringDirectory { get; set; }
public RendererWorkspaceConfigModel RendererConfig { get; set; } = new(); public RendererWorkspaceConfigModel RendererConfig { get; set; } = new();
public List<SpineObjectWorkspaceConfigModel> LoadedSpineObjects { get; set; } = []; public List<SpineObjectWorkspaceConfigModel> LoadedSpineObjects { get; set; } = [];
} }

View File

@@ -7,7 +7,7 @@
<TargetFramework>net8.0-windows</TargetFramework> <TargetFramework>net8.0-windows</TargetFramework>
<BaseOutputPath>$(SolutionDir)out</BaseOutputPath> <BaseOutputPath>$(SolutionDir)out</BaseOutputPath>
<IncludeSourceRevisionInInformationalVersion>false</IncludeSourceRevisionInInformationalVersion> <IncludeSourceRevisionInInformationalVersion>false</IncludeSourceRevisionInInformationalVersion>
<Version>0.15.1</Version> <Version>0.15.2</Version>
<OutputType>WinExe</OutputType> <OutputType>WinExe</OutputType>
<UseWPF>true</UseWPF> <UseWPF>true</UseWPF>
</PropertyGroup> </PropertyGroup>

View File

@@ -40,12 +40,15 @@ namespace SpineViewer.Utils
/// <summary> /// <summary>
/// 从文件反序列对象, 不会抛出异常 /// 从文件反序列对象, 不会抛出异常
/// </summary> /// </summary>
public static bool Deserialize<T>(string path, out T obj) public static bool Deserialize<T>(string path, out T obj, bool quietForNotExist = false)
{ {
if (!File.Exists(path)) if (!File.Exists(path))
{ {
_logger.Error("Json file {0} not found", path); if (!quietForNotExist)
MessagePopupService.Error($"Json file {path} not found"); {
_logger.Error("Json file {0} not found", path);
MessagePopupService.Error($"Json file {path} not found");
}
} }
else else
{ {

View File

@@ -39,11 +39,6 @@ namespace SpineViewer.ViewModels.MainWindow
private readonly MainWindowViewModel _vmMain; private readonly MainWindowViewModel _vmMain;
/// <summary>
/// 当前目录路径
/// </summary>
private string? _currentDirectory;
/// <summary> /// <summary>
/// 当前目录下文件项缓存 /// 当前目录下文件项缓存
/// </summary> /// </summary>
@@ -54,12 +49,26 @@ namespace SpineViewer.ViewModels.MainWindow
_vmMain = vmMain; _vmMain = vmMain;
} }
/// <summary>
/// 当前目录路径
/// </summary>
public string? CurrentDirectory
{
get => string.IsNullOrWhiteSpace(_currentDirectory) ? null : _currentDirectory;
set
{
if (!SetProperty(ref _currentDirectory, value)) return;
RefreshItems();
}
}
private string? _currentDirectory;
/// <summary> /// <summary>
/// 筛选字符串 /// 筛选字符串
/// </summary> /// </summary>
public string? FilterString public string? FilterString
{ {
get => _filterString; get => string.IsNullOrWhiteSpace(_filterString) ? null : _filterString;
set set
{ {
if (!SetProperty(ref _filterString, value)) return; if (!SetProperty(ref _filterString, value)) return;
@@ -95,10 +104,7 @@ namespace SpineViewer.ViewModels.MainWindow
public RelayCommand Cmd_ChangeCurrentDirectory => _cmd_ChangeCurrentDirectory ??= new(() => public RelayCommand Cmd_ChangeCurrentDirectory => _cmd_ChangeCurrentDirectory ??= new(() =>
{ {
if (DialogService.ShowOpenFolderDialog(out var selectedPath)) if (DialogService.ShowOpenFolderDialog(out var selectedPath))
{ CurrentDirectory = selectedPath;
_currentDirectory = selectedPath;
RefreshItems();
}
}); });
private RelayCommand? _cmd_ChangeCurrentDirectory; private RelayCommand? _cmd_ChangeCurrentDirectory;

View File

@@ -118,12 +118,14 @@ namespace SpineViewer.ViewModels.MainWindow
{ {
return new() return new()
{ {
ExploringDirectory = _explorerListViewModel.CurrentDirectory,
RendererConfig = _sfmlRendererViewModel.WorkspaceConfig, RendererConfig = _sfmlRendererViewModel.WorkspaceConfig,
LoadedSpineObjects = _spineObjectListViewModel.LoadedSpineObjects LoadedSpineObjects = _spineObjectListViewModel.LoadedSpineObjects
}; };
} }
set set
{ {
_explorerListViewModel.CurrentDirectory = value.ExploringDirectory;
_sfmlRendererViewModel.WorkspaceConfig = value.RendererConfig; _sfmlRendererViewModel.WorkspaceConfig = value.RendererConfig;
_spineObjectListViewModel.LoadedSpineObjects = value.LoadedSpineObjects; _spineObjectListViewModel.LoadedSpineObjects = value.LoadedSpineObjects;
} }

View File

@@ -63,7 +63,7 @@ namespace SpineViewer.ViewModels.MainWindow
/// </summary> /// </summary>
public void LoadPreference() public void LoadPreference()
{ {
if (JsonHelper.Deserialize<PreferenceModel>(PreferenceFilePath, out var obj)) if (JsonHelper.Deserialize<PreferenceModel>(PreferenceFilePath, out var obj, true))
Preference = obj; Preference = obj;
} }