mirror of
https://github.com/ShareX/ShareX.git
synced 2024-10-01 17:56:51 +13:00
Added HistorySettings class
This commit is contained in:
parent
3383e25570
commit
b166e94131
5 changed files with 54 additions and 25 deletions
|
@ -36,20 +36,18 @@ 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 HistorySettings Settings { get; private set; }
|
||||||
|
|
||||||
private HistoryManager history;
|
private HistoryManager history;
|
||||||
private HistoryItemManager him;
|
private HistoryItemManager him;
|
||||||
private HistoryItem[] allHistoryItems;
|
private HistoryItem[] allHistoryItems;
|
||||||
private string defaultTitle;
|
private string defaultTitle;
|
||||||
|
|
||||||
public HistoryForm(string historyPath, int maxItemCount, int splitterDistance = 0, Action<string> uploadFile = null, Action<string> editImage = null)
|
public HistoryForm(string historyPath, HistorySettings settings, Action<string> uploadFile = null, Action<string> editImage = null)
|
||||||
{
|
{
|
||||||
HistoryPath = historyPath;
|
HistoryPath = historyPath;
|
||||||
MaxItemCount = maxItemCount;
|
Settings = settings;
|
||||||
|
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
Icon = ShareXResources.Icon;
|
Icon = ShareXResources.Icon;
|
||||||
|
@ -74,10 +72,12 @@ public HistoryForm(string historyPath, int maxItemCount, int splitterDistance =
|
||||||
cbFilenameFilterMethod.SelectedIndex = 0; // Contains
|
cbFilenameFilterMethod.SelectedIndex = 0; // Contains
|
||||||
lvHistory.FillLastColumn();
|
lvHistory.FillLastColumn();
|
||||||
|
|
||||||
if (splitterDistance > 0)
|
if (Settings.SplitterDistance > 0)
|
||||||
{
|
{
|
||||||
scMain.SplitterDistance = splitterDistance;
|
scMain.SplitterDistance = Settings.SplitterDistance;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Settings.WindowState.AutoHandleFormState(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void RefreshHistoryItems()
|
private void RefreshHistoryItems()
|
||||||
|
@ -101,9 +101,9 @@ private HistoryItem[] GetHistoryItems()
|
||||||
IEnumerable<HistoryItem> tempHistoryItems = history.GetHistoryItems();
|
IEnumerable<HistoryItem> tempHistoryItems = history.GetHistoryItems();
|
||||||
tempHistoryItems = tempHistoryItems.Reverse();
|
tempHistoryItems = tempHistoryItems.Reverse();
|
||||||
|
|
||||||
if (MaxItemCount > 0)
|
if (Settings.MaxItemCount > 0)
|
||||||
{
|
{
|
||||||
tempHistoryItems = tempHistoryItems.Take(MaxItemCount);
|
tempHistoryItems = tempHistoryItems.Take(Settings.MaxItemCount);
|
||||||
}
|
}
|
||||||
|
|
||||||
return tempHistoryItems.ToArray();
|
return tempHistoryItems.ToArray();
|
||||||
|
@ -289,14 +289,6 @@ 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)
|
||||||
|
@ -342,7 +334,7 @@ private void HistoryForm_KeyDown(object sender, KeyEventArgs e)
|
||||||
|
|
||||||
private void scMain_SplitterMoved(object sender, SplitterEventArgs e)
|
private void scMain_SplitterMoved(object sender, SplitterEventArgs e)
|
||||||
{
|
{
|
||||||
OnSplitterDistanceChanged(scMain.SplitterDistance);
|
Settings.SplitterDistance = scMain.SplitterDistance;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void btnApplyFilters_Click(object sender, EventArgs e)
|
private void btnApplyFilters_Click(object sender, EventArgs e)
|
||||||
|
|
41
ShareX.HistoryLib/HistorySettings.cs
Normal file
41
ShareX.HistoryLib/HistorySettings.cs
Normal file
|
@ -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 <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#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;
|
||||||
|
}
|
||||||
|
}
|
|
@ -99,6 +99,7 @@
|
||||||
<Compile Include="Forms\ImageHistorySettingsForm.Designer.cs">
|
<Compile Include="Forms\ImageHistorySettingsForm.Designer.cs">
|
||||||
<DependentUpon>ImageHistorySettingsForm.cs</DependentUpon>
|
<DependentUpon>ImageHistorySettingsForm.cs</DependentUpon>
|
||||||
</Compile>
|
</Compile>
|
||||||
|
<Compile Include="HistorySettings.cs" />
|
||||||
<Compile Include="ImageHistorySettings.cs" />
|
<Compile Include="ImageHistorySettings.cs" />
|
||||||
<Compile Include="Properties\Resources.Designer.cs">
|
<Compile Include="Properties\Resources.Designer.cs">
|
||||||
<AutoGen>True</AutoGen>
|
<AutoGen>True</AutoGen>
|
||||||
|
|
|
@ -123,10 +123,7 @@ public ApplicationConfig()
|
||||||
public bool RecentTasksShowInTrayMenu = true;
|
public bool RecentTasksShowInTrayMenu = true;
|
||||||
public bool RecentTasksTrayMenuMostRecentFirst = false;
|
public bool RecentTasksTrayMenuMostRecentFirst = false;
|
||||||
|
|
||||||
public WindowState HistoryWindowState = new WindowState();
|
public HistorySettings HistorySettings = new HistorySettings();
|
||||||
public int HistoryMaxItemCount = 0;
|
|
||||||
public int HistorySplitterDistance = 550;
|
|
||||||
|
|
||||||
public ImageHistorySettings ImageHistorySettings = new ImageHistorySettings();
|
public ImageHistorySettings ImageHistorySettings = new ImageHistorySettings();
|
||||||
|
|
||||||
#endregion History
|
#endregion History
|
||||||
|
|
|
@ -714,10 +714,8 @@ public static void OpenScreenshotsFolder()
|
||||||
|
|
||||||
public static void OpenHistory()
|
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));
|
filePath => UploadManager.UploadFile(filePath), filePath => AnnotateImageFromFile(filePath));
|
||||||
historyForm.SplitterDistanceChanged += splitterDistance => Program.Settings.HistorySplitterDistance = splitterDistance;
|
|
||||||
Program.Settings.HistoryWindowState.AutoHandleFormState(historyForm);
|
|
||||||
historyForm.Show();
|
historyForm.Show();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue