Added remember window state option to history forms

This commit is contained in:
Jaex 2021-08-02 18:21:09 +03:00
parent cc88068309
commit 1e094cae32
7 changed files with 34 additions and 8 deletions

View file

@ -338,6 +338,7 @@ private void InitializeComponent()
this.Controls.Add(this.scMain);
this.KeyPreview = true;
this.Name = "HistoryForm";
this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.HistoryForm_FormClosing);
this.Shown += new System.EventHandler(this.HistoryForm_Shown);
this.KeyDown += new System.Windows.Forms.KeyEventHandler(this.HistoryForm_KeyDown);
this.Resize += new System.EventHandler(this.HistoryForm_Resize);

View file

@ -73,11 +73,6 @@ public HistoryForm(string historyPath, HistorySettings settings, Action<string>
pbThumbnail.Reset();
lvHistory.FillLastColumn();
if (Settings.SplitterDistance > 0)
{
scMain.SplitterDistance = Settings.SplitterDistance;
}
if (Settings.RememberSearchText)
{
tstbSearch.Text = Settings.SearchText;
@ -85,7 +80,15 @@ public HistoryForm(string historyPath, HistorySettings settings, Action<string>
ShareXResources.ApplyTheme(this);
Settings.WindowState.AutoHandleFormState(this);
if (Settings.RememberWindowState)
{
Settings.WindowState.ApplyFormState(this);
if (Settings.SplitterDistance > 0)
{
scMain.SplitterDistance = Settings.SplitterDistance;
}
}
}
private void ResetFilters()
@ -371,6 +374,14 @@ private void HistoryForm_Resize(object sender, EventArgs e)
Refresh();
}
private void HistoryForm_FormClosing(object sender, FormClosingEventArgs e)
{
if (Settings.RememberWindowState)
{
Settings.WindowState.UpdateFormState(this);
}
}
private void HistoryForm_KeyDown(object sender, KeyEventArgs e)
{
switch (e.KeyData)

View file

@ -712,7 +712,7 @@
<value>3, 0</value>
</data>
<data name="tsHistory.Size" type="System.Drawing.Size, System.Drawing">
<value>485, 25</value>
<value>454, 25</value>
</data>
<data name="tsHistory.TabIndex" type="System.Int32, mscorlib">
<value>0</value>

View file

@ -156,6 +156,7 @@ private void InitializeComponent()
this.Controls.Add(this.tscMain);
this.KeyPreview = true;
this.Name = "ImageHistoryForm";
this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.ImageHistoryForm_FormClosing);
this.Shown += new System.EventHandler(this.ImageHistoryForm_Shown);
this.KeyDown += new System.Windows.Forms.KeyEventHandler(this.ImageHistoryForm_KeyDown);
this.tscMain.ContentPanel.ResumeLayout(false);

View file

@ -83,7 +83,10 @@ public ImageHistoryForm(string historyPath, ImageHistorySettings settings, Actio
ShareXResources.ApplyTheme(this);
Settings.WindowState.AutoHandleFormState(this);
if (Settings.RememberWindowState)
{
Settings.WindowState.ApplyFormState(this);
}
}
private void UpdateTitle(int total, int filtered)
@ -168,6 +171,14 @@ private void ImageHistoryForm_Shown(object sender, EventArgs e)
RefreshHistoryItems();
}
private void ImageHistoryForm_FormClosing(object sender, FormClosingEventArgs e)
{
if (Settings.RememberWindowState)
{
Settings.WindowState.UpdateFormState(this);
}
}
private void ImageHistoryForm_KeyDown(object sender, KeyEventArgs e)
{
if (e.KeyCode == Keys.F5)

View file

@ -29,6 +29,7 @@ namespace ShareX.HistoryLib
{
public class HistorySettings
{
public bool RememberWindowState { get; set; } = true;
public WindowState WindowState { get; set; } = new WindowState();
public int SplitterDistance { get; set; } = 550;
public int MaxItemCount { get; set; } = 0;

View file

@ -30,6 +30,7 @@ namespace ShareX.HistoryLib
{
public class ImageHistorySettings
{
public bool RememberWindowState { get; set; } = true;
public WindowState WindowState { get; set; } = new WindowState();
public int ViewMode { get; set; } = 3;
public Size ThumbnailSize { get; set; } = new Size(150, 150);