mirror of
https://github.com/ShareX/ShareX.git
synced 2024-07-01 04:30:49 +12:00
Save history form splitter distance, on form shown select first history item
This commit is contained in:
parent
7e957014bd
commit
17f6d733d2
1
ShareX.HistoryLib/HistoryForm.Designer.cs
generated
1
ShareX.HistoryLib/HistoryForm.Designer.cs
generated
|
@ -83,6 +83,7 @@ private void InitializeComponent()
|
||||||
this.scMain.Panel2.Controls.Add(this.pbThumbnail);
|
this.scMain.Panel2.Controls.Add(this.pbThumbnail);
|
||||||
this.scMain.Panel2.Controls.Add(this.gbFilters);
|
this.scMain.Panel2.Controls.Add(this.gbFilters);
|
||||||
this.scMain.SplitterColor = System.Drawing.Color.DarkGray;
|
this.scMain.SplitterColor = System.Drawing.Color.DarkGray;
|
||||||
|
this.scMain.SplitterMoved += new System.Windows.Forms.SplitterEventHandler(this.scMain_SplitterMoved);
|
||||||
//
|
//
|
||||||
// lvHistory
|
// lvHistory
|
||||||
//
|
//
|
||||||
|
|
|
@ -36,6 +36,8 @@ namespace ShareX.HistoryLib
|
||||||
{
|
{
|
||||||
public partial class HistoryForm : Form
|
public partial class HistoryForm : Form
|
||||||
{
|
{
|
||||||
|
public event Action<int> SplitterDistanceChanged;
|
||||||
|
|
||||||
public string HistoryPath { get; private set; }
|
public string HistoryPath { get; private set; }
|
||||||
public int MaxItemCount { get; set; }
|
public int MaxItemCount { get; set; }
|
||||||
|
|
||||||
|
@ -43,7 +45,7 @@ public partial class HistoryForm : Form
|
||||||
private HistoryItemManager him;
|
private HistoryItemManager him;
|
||||||
private HistoryItem[] allHistoryItems;
|
private HistoryItem[] allHistoryItems;
|
||||||
|
|
||||||
public HistoryForm(string historyPath, int maxItemCount = -1)
|
public HistoryForm(string historyPath, int splitterDistance = 0, int maxItemCount = -1)
|
||||||
{
|
{
|
||||||
HistoryPath = historyPath;
|
HistoryPath = historyPath;
|
||||||
MaxItemCount = maxItemCount;
|
MaxItemCount = maxItemCount;
|
||||||
|
@ -69,6 +71,11 @@ public HistoryForm(string historyPath, int maxItemCount = -1)
|
||||||
cbTypeFilterSelection.SelectedIndex = 0; // Image
|
cbTypeFilterSelection.SelectedIndex = 0; // Image
|
||||||
cbFilenameFilterCulture.Items[0] = string.Format(Resources.HistoryForm_HistoryForm_Current_culture___0__, CultureInfo.CurrentCulture.Parent.EnglishName);
|
cbFilenameFilterCulture.Items[0] = string.Format(Resources.HistoryForm_HistoryForm_Current_culture___0__, CultureInfo.CurrentCulture.Parent.EnglishName);
|
||||||
lvHistory.FillLastColumn();
|
lvHistory.FillLastColumn();
|
||||||
|
|
||||||
|
if (splitterDistance > 0)
|
||||||
|
{
|
||||||
|
scMain.SplitterDistance = splitterDistance;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void RefreshHistoryItems()
|
private void RefreshHistoryItems()
|
||||||
|
@ -298,12 +305,26 @@ private void UpdatePictureBox()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected void OnSplitterDistanceChanged(int splitterDistance)
|
||||||
|
{
|
||||||
|
if (SplitterDistanceChanged != null)
|
||||||
|
{
|
||||||
|
SplitterDistanceChanged(splitterDistance);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#region Form events
|
#region Form events
|
||||||
|
|
||||||
private void HistoryForm_Shown(object sender, EventArgs e)
|
private void HistoryForm_Shown(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
Refresh();
|
Refresh();
|
||||||
RefreshHistoryItems();
|
RefreshHistoryItems();
|
||||||
|
|
||||||
|
if (lvHistory.Items.Count > 0)
|
||||||
|
{
|
||||||
|
lvHistory.Items[0].Selected = true;
|
||||||
|
}
|
||||||
|
|
||||||
this.ShowActivate();
|
this.ShowActivate();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -323,6 +344,11 @@ private void HistoryForm_KeyDown(object sender, KeyEventArgs e)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void scMain_SplitterMoved(object sender, SplitterEventArgs e)
|
||||||
|
{
|
||||||
|
OnSplitterDistanceChanged(scMain.SplitterDistance);
|
||||||
|
}
|
||||||
|
|
||||||
private void btnApplyFilters_Click(object sender, EventArgs e)
|
private void btnApplyFilters_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
ApplyFiltersAndAdd();
|
ApplyFiltersAndAdd();
|
||||||
|
|
|
@ -913,7 +913,7 @@
|
||||||
<value>984, 641</value>
|
<value>984, 641</value>
|
||||||
</data>
|
</data>
|
||||||
<data name="$this.MinimumSize" type="System.Drawing.Size, System.Drawing">
|
<data name="$this.MinimumSize" type="System.Drawing.Size, System.Drawing">
|
||||||
<value>925, 600</value>
|
<value>500, 500</value>
|
||||||
</data>
|
</data>
|
||||||
<data name="$this.StartPosition" type="System.Windows.Forms.FormStartPosition, System.Windows.Forms">
|
<data name="$this.StartPosition" type="System.Windows.Forms.FormStartPosition, System.Windows.Forms">
|
||||||
<value>CenterScreen</value>
|
<value>CenterScreen</value>
|
||||||
|
|
|
@ -123,6 +123,8 @@ public ApplicationConfig()
|
||||||
public bool RecentTasksTrayMenuMostRecentFirst = false;
|
public bool RecentTasksTrayMenuMostRecentFirst = false;
|
||||||
|
|
||||||
public WindowState HistoryWindowState = new WindowState();
|
public WindowState HistoryWindowState = new WindowState();
|
||||||
|
public int HistorySplitterDistance = 550;
|
||||||
|
|
||||||
public WindowState ImageHistoryWindowState = new WindowState();
|
public WindowState ImageHistoryWindowState = new WindowState();
|
||||||
public int ImageHistoryMaxItemCount = 100;
|
public int ImageHistoryMaxItemCount = 100;
|
||||||
public int ImageHistoryViewMode = 3;
|
public int ImageHistoryViewMode = 3;
|
||||||
|
|
|
@ -479,7 +479,8 @@ public static void OpenScreenshotsFolder()
|
||||||
|
|
||||||
public static void OpenHistory()
|
public static void OpenHistory()
|
||||||
{
|
{
|
||||||
HistoryForm historyForm = new HistoryForm(Program.HistoryFilePath);
|
HistoryForm historyForm = new HistoryForm(Program.HistoryFilePath, Program.Settings.HistorySplitterDistance);
|
||||||
|
historyForm.SplitterDistanceChanged += splitterDistance => Program.Settings.HistorySplitterDistance = splitterDistance;
|
||||||
Program.Settings.HistoryWindowState.AutoHandleFormState(historyForm);
|
Program.Settings.HistoryWindowState.AutoHandleFormState(historyForm);
|
||||||
historyForm.Show();
|
historyForm.Show();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue