diff --git a/ShareX.HistoryLib/Forms/HistoryForm.cs b/ShareX.HistoryLib/Forms/HistoryForm.cs index 318fba338..3057a146c 100644 --- a/ShareX.HistoryLib/Forms/HistoryForm.cs +++ b/ShareX.HistoryLib/Forms/HistoryForm.cs @@ -36,20 +36,18 @@ namespace ShareX.HistoryLib { public partial class HistoryForm : Form { - public event Action SplitterDistanceChanged; - public string HistoryPath { get; private set; } - public int MaxItemCount { get; set; } + public HistorySettings Settings { get; private set; } private HistoryManager history; private HistoryItemManager him; private HistoryItem[] allHistoryItems; private string defaultTitle; - public HistoryForm(string historyPath, int maxItemCount, int splitterDistance = 0, Action uploadFile = null, Action editImage = null) + public HistoryForm(string historyPath, HistorySettings settings, Action uploadFile = null, Action editImage = null) { HistoryPath = historyPath; - MaxItemCount = maxItemCount; + Settings = settings; InitializeComponent(); Icon = ShareXResources.Icon; @@ -74,10 +72,12 @@ public HistoryForm(string historyPath, int maxItemCount, int splitterDistance = cbFilenameFilterMethod.SelectedIndex = 0; // Contains lvHistory.FillLastColumn(); - if (splitterDistance > 0) + if (Settings.SplitterDistance > 0) { - scMain.SplitterDistance = splitterDistance; + scMain.SplitterDistance = Settings.SplitterDistance; } + + Settings.WindowState.AutoHandleFormState(this); } private void RefreshHistoryItems() @@ -101,9 +101,9 @@ private HistoryItem[] GetHistoryItems() IEnumerable tempHistoryItems = history.GetHistoryItems(); tempHistoryItems = tempHistoryItems.Reverse(); - if (MaxItemCount > 0) + if (Settings.MaxItemCount > 0) { - tempHistoryItems = tempHistoryItems.Take(MaxItemCount); + tempHistoryItems = tempHistoryItems.Take(Settings.MaxItemCount); } return tempHistoryItems.ToArray(); @@ -289,14 +289,6 @@ private void UpdatePictureBox() } } - protected void OnSplitterDistanceChanged(int splitterDistance) - { - if (SplitterDistanceChanged != null) - { - SplitterDistanceChanged(splitterDistance); - } - } - #region Form events private void HistoryForm_Shown(object sender, EventArgs e) @@ -342,7 +334,7 @@ private void HistoryForm_KeyDown(object sender, KeyEventArgs e) private void scMain_SplitterMoved(object sender, SplitterEventArgs e) { - OnSplitterDistanceChanged(scMain.SplitterDistance); + Settings.SplitterDistance = scMain.SplitterDistance; } private void btnApplyFilters_Click(object sender, EventArgs e) diff --git a/ShareX.HistoryLib/HistorySettings.cs b/ShareX.HistoryLib/HistorySettings.cs new file mode 100644 index 000000000..64311751e --- /dev/null +++ b/ShareX.HistoryLib/HistorySettings.cs @@ -0,0 +1,41 @@ +#region License Information (GPL v3) + +/* + ShareX - A program that allows you to take screenshots and share any file type + Copyright (c) 2007-2018 ShareX Team + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License + as published by the Free Software Foundation; either version 2 + of the License, or (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + + Optionally you can also view the license at . +*/ + +#endregion License Information (GPL v3) + +using ShareX.HelpersLib; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ShareX.HistoryLib +{ + public class HistorySettings + { + public WindowState WindowState { get; set; } = new WindowState(); + public int MaxItemCount { get; set; } = 0; + public int SplitterDistance { get; set; } = 550; + } +} \ No newline at end of file diff --git a/ShareX.HistoryLib/ShareX.HistoryLib.csproj b/ShareX.HistoryLib/ShareX.HistoryLib.csproj index 14d77ae96..0903510e2 100644 --- a/ShareX.HistoryLib/ShareX.HistoryLib.csproj +++ b/ShareX.HistoryLib/ShareX.HistoryLib.csproj @@ -99,6 +99,7 @@ ImageHistorySettingsForm.cs + True diff --git a/ShareX/ApplicationConfig.cs b/ShareX/ApplicationConfig.cs index 4ae5a29e6..dc6f64670 100644 --- a/ShareX/ApplicationConfig.cs +++ b/ShareX/ApplicationConfig.cs @@ -123,10 +123,7 @@ public ApplicationConfig() public bool RecentTasksShowInTrayMenu = true; public bool RecentTasksTrayMenuMostRecentFirst = false; - public WindowState HistoryWindowState = new WindowState(); - public int HistoryMaxItemCount = 0; - public int HistorySplitterDistance = 550; - + public HistorySettings HistorySettings = new HistorySettings(); public ImageHistorySettings ImageHistorySettings = new ImageHistorySettings(); #endregion History diff --git a/ShareX/TaskHelpers.cs b/ShareX/TaskHelpers.cs index 25986a703..19132b618 100644 --- a/ShareX/TaskHelpers.cs +++ b/ShareX/TaskHelpers.cs @@ -714,10 +714,8 @@ public static void OpenScreenshotsFolder() public static void OpenHistory() { - HistoryForm historyForm = new HistoryForm(Program.HistoryFilePath, Program.Settings.HistoryMaxItemCount, Program.Settings.HistorySplitterDistance, + HistoryForm historyForm = new HistoryForm(Program.HistoryFilePath, Program.Settings.HistorySettings, filePath => UploadManager.UploadFile(filePath), filePath => AnnotateImageFromFile(filePath)); - historyForm.SplitterDistanceChanged += splitterDistance => Program.Settings.HistorySplitterDistance = splitterDistance; - Program.Settings.HistoryWindowState.AutoHandleFormState(historyForm); historyForm.Show(); }