Skip to content

Commit

Permalink
remember history window maximized state 2
Browse files Browse the repository at this point in the history
  • Loading branch information
setsumi committed Apr 16, 2024
1 parent bbcd578 commit 9a18fa4
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
6 changes: 5 additions & 1 deletion src/syosetuDownloader/HistoryWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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 ========================
Expand Down
11 changes: 10 additions & 1 deletion src/syosetuDownloader/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down Expand Up @@ -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();
}

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

0 comments on commit 9a18fa4

Please sign in to comment.