修复记忆状态中的长度单位错误

This commit is contained in:
ww-rm
2025-09-30 00:28:05 +08:00
parent b76224c010
commit 8c3be98b54
4 changed files with 38 additions and 19 deletions

View File

@@ -1,6 +1,7 @@
using Microsoft.Win32;
using NLog;
using SpineViewer.Natives;
using SpineViewer.ViewModels.MainWindow;
using SpineViewer.Views;
using System.Collections.Frozen;
using System.Configuration;
@@ -185,7 +186,8 @@ namespace SpineViewer
if (args.Count > 0)
{
Current.Dispatcher.Invoke(() => ((MainWindow)Current.MainWindow).OpenFiles(args));
var vm = (MainWindowViewModel)((MainWindow)Current.MainWindow).DataContext;
Current.Dispatcher.Invoke(() => vm.SpineObjectListViewModel.AddSpineObjectFromFileList(args));
}
}
}

View File

@@ -19,9 +19,16 @@ namespace SpineViewer.Models
public WindowState WindowState { get; set; }
public double RootGridCol0Width { get; set; }
public double RootGridCol2Width { get; set; }
public double ModelListRow0Height { get; set; }
public double ModelListRow2Height { get; set; }
public double ExplorerGridRow0Height { get; set; }
public double ExplorerGridRow2Height { get; set; }
public double RightPanelGridRow0Height { get; set; }
public double RightPanelGridRow2Height { get; set; }
#endregion

View File

@@ -80,7 +80,7 @@
<Grid x:Name="_rootGrid">
<Grid.ColumnDefinitions>
<ColumnDefinition/>
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="2.5*"/>
</Grid.ColumnDefinitions>

View File

@@ -116,10 +116,17 @@ public partial class MainWindow : Window
WindowState = WindowState.Normal;
}
_rootGrid.ColumnDefinitions[0].Width = new(m.RootGridCol0Width);
_modelListGrid.RowDefinitions[0].Height = new(m.ModelListRow0Height);
if (m.ExplorerGridRow0Height > 0) _explorerGrid.RowDefinitions[0].Height = new(m.ExplorerGridRow0Height);
_rightPanelGrid.RowDefinitions[0].Height = new(m.RightPanelGridRow0Height);
_rootGrid.ColumnDefinitions[0].Width = new(m.RootGridCol0Width, GridUnitType.Star);
_rootGrid.ColumnDefinitions[2].Width = new(m.RootGridCol2Width, GridUnitType.Star);
_modelListGrid.RowDefinitions[0].Height = new(m.ModelListRow0Height, GridUnitType.Star);
_modelListGrid.RowDefinitions[2].Height = new(m.ModelListRow2Height, GridUnitType.Star);
_explorerGrid.RowDefinitions[0].Height = new(m.ExplorerGridRow0Height, GridUnitType.Star);
_explorerGrid.RowDefinitions[2].Height = new(m.ExplorerGridRow2Height, GridUnitType.Star);
_rightPanelGrid.RowDefinitions[0].Height = new(m.RightPanelGridRow0Height, GridUnitType.Star);
_rightPanelGrid.RowDefinitions[2].Height = new(m.RightPanelGridRow2Height, GridUnitType.Star);
_vm.SFMLRendererViewModel.SetResolution(m.ResolutionX, m.ResolutionY);
_vm.SFMLRendererViewModel.MaxFps = m.MaxFps;
@@ -140,10 +147,17 @@ public partial class MainWindow : Window
WindowHeight = Height,
WindowState = WindowState,
RootGridCol0Width = _rootGrid.ColumnDefinitions[0].ActualWidth,
ModelListRow0Height = _modelListGrid.RowDefinitions[0].ActualHeight,
ExplorerGridRow0Height = _explorerGrid.RowDefinitions[0].ActualHeight,
RightPanelGridRow0Height = _rightPanelGrid.RowDefinitions[0].ActualHeight,
RootGridCol0Width = _rootGrid.ColumnDefinitions[0].Width.Value,
RootGridCol2Width = _rootGrid.ColumnDefinitions[2].Width.Value,
ModelListRow0Height = _modelListGrid.RowDefinitions[0].Height.Value,
ModelListRow2Height = _modelListGrid.RowDefinitions[2].Height.Value,
ExplorerGridRow0Height = _explorerGrid.RowDefinitions[0].Height.Value,
ExplorerGridRow2Height = _explorerGrid.RowDefinitions[2].Height.Value,
RightPanelGridRow0Height = _rightPanelGrid.RowDefinitions[0].Height.Value,
RightPanelGridRow2Height = _rightPanelGrid.RowDefinitions[2].Height.Value,
ResolutionX = _vm.SFMLRendererViewModel.ResolutionX,
ResolutionY = _vm.SFMLRendererViewModel.ResolutionY,
@@ -157,14 +171,6 @@ public partial class MainWindow : Window
JsonHelper.Serialize(m, LastStateFilePath);
}
/// <summary>
/// 给管道通信提供的打开文件外部调用方法
/// </summary>
public void OpenFiles(IEnumerable<string> filePaths)
{
_vm.SpineObjectListViewModel.AddSpineObjectFromFileList(filePaths);
}
#region MainWindow
private void MainWindow_Loaded(object sender, RoutedEventArgs e)
@@ -676,7 +682,11 @@ public partial class MainWindow : Window
private void DebugMenuItem_Click(object sender, RoutedEventArgs e)
{
#if DEBUG
var a = _rootGrid.ColumnDefinitions[0].Width;
var b = _rootGrid.ColumnDefinitions[1].Width;
var c = _rootGrid.ColumnDefinitions[2].Width;
Debug.WriteLine(a);
Debug.WriteLine(_rootGrid.ColumnDefinitions[0].Width.IsStar);
#endif
}
}