diff --git a/SpineViewer/App.xaml.cs b/SpineViewer/App.xaml.cs index 73b3e78..dcc6c12 100644 --- a/SpineViewer/App.xaml.cs +++ b/SpineViewer/App.xaml.cs @@ -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)); } } } diff --git a/SpineViewer/Models/LastStateModel.cs b/SpineViewer/Models/LastStateModel.cs index 80bac2f..17eb9d3 100644 --- a/SpineViewer/Models/LastStateModel.cs +++ b/SpineViewer/Models/LastStateModel.cs @@ -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 diff --git a/SpineViewer/Views/MainWindow.xaml b/SpineViewer/Views/MainWindow.xaml index ffde3f7..d33fa03 100644 --- a/SpineViewer/Views/MainWindow.xaml +++ b/SpineViewer/Views/MainWindow.xaml @@ -80,7 +80,7 @@ - + diff --git a/SpineViewer/Views/MainWindow.xaml.cs b/SpineViewer/Views/MainWindow.xaml.cs index c821c24..f0077a4 100644 --- a/SpineViewer/Views/MainWindow.xaml.cs +++ b/SpineViewer/Views/MainWindow.xaml.cs @@ -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); } - /// - /// 给管道通信提供的打开文件外部调用方法 - /// - public void OpenFiles(IEnumerable 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 } } \ No newline at end of file