From 9a18fa43c073b3091185ace81398bfd6b9afe18f Mon Sep 17 00:00:00 2001 From: setsumi Date: Tue, 16 Apr 2024 19:46:26 +1000 Subject: [PATCH] remember history window maximized state 2 --- src/syosetuDownloader/HistoryWindow.xaml.cs | 6 +++++- src/syosetuDownloader/MainWindow.xaml.cs | 11 ++++++++++- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/src/syosetuDownloader/HistoryWindow.xaml.cs b/src/syosetuDownloader/HistoryWindow.xaml.cs index 4f8d323..3b25410 100644 --- a/src/syosetuDownloader/HistoryWindow.xaml.cs +++ b/src/syosetuDownloader/HistoryWindow.xaml.cs @@ -284,13 +284,17 @@ private void Window_Closing(object sender, CancelEventArgs e) { _parent.sortInfo = Util.GridViewTool.GetSort(viewHistoryList); _parent.historyMaximized = WindowState == WindowState.Maximized; + if (WindowState == WindowState.Normal) + { + _parent.historyWndSize.Width = Width; + _parent.historyWndSize.Height = Height; + } } private void Window_Loaded(object sender, RoutedEventArgs e) { Util.GridViewTool.SetSort(viewHistoryList, _parent.sortInfo); FocusListView(); - if (_parent.historyMaximized) WindowState = WindowState.Maximized; } } // End of HistoryWindow ======================== diff --git a/src/syosetuDownloader/MainWindow.xaml.cs b/src/syosetuDownloader/MainWindow.xaml.cs index 7c390dd..e03e11c 100644 --- a/src/syosetuDownloader/MainWindow.xaml.cs +++ b/src/syosetuDownloader/MainWindow.xaml.cs @@ -70,6 +70,7 @@ public partial class MainWindow : Window public Util.GridViewTool.SortInfo sortInfo = new Util.GridViewTool.SortInfo(); public bool historyMaximized = false; + public Size historyWndSize = new Size(); public class NovelDrop { @@ -523,6 +524,9 @@ private void btnHistory_Click(object sender, RoutedEventArgs e) { HistoryWindow win = new HistoryWindow(); win.DownloadFolder = DlOptions.DlDir; + if (historyWndSize.Width > 320) win.Width = historyWndSize.Width; + if (historyWndSize.Height > 200) win.Height = historyWndSize.Height; + if (historyMaximized) win.WindowState = WindowState.Maximized; win.ShowDialog(); } @@ -566,9 +570,10 @@ public void LoadConfig() sortInfo.Direction = dir; sortInfo.PropertyName = elem.Attribute("propertyName").Value; sortInfo.ColumnName = elem.Attribute("columnName").Value; + try { historyMaximized = bool.Parse(elem.Attribute("historyMaximized")?.Value); } catch { } + try { historyWndSize = Size.Parse(elem.Attribute("historyWndSize")?.Value); } catch { } try // newly added stuff { - historyMaximized = bool.Parse(elem.Attribute("historyMaximized")?.Value); elem = fileElem.Element("config"); DlOptions.DlDir = elem.Attribute("dlfolder").Value; } @@ -604,6 +609,10 @@ public void SaveConfig() attr.Value = historyMaximized.ToString(); node.Attributes.Append(attr); + attr = doc.CreateAttribute("historyWndSize"); + attr.Value = historyWndSize.ToString(); + node.Attributes.Append(attr); + rootNode.AppendChild(node); node = doc.CreateElement("config");