mirror of
https://github.com/ShareX/ShareX.git
synced 2024-09-30 01:07:21 +13:00
Import / Export implementation complete now
This commit is contained in:
parent
354996ca8a
commit
09df47979b
4 changed files with 42 additions and 32 deletions
|
@ -460,6 +460,7 @@ private void btnExport_Click(object sender, EventArgs e)
|
||||||
TaskEx.Run(() =>
|
TaskEx.Run(() =>
|
||||||
{
|
{
|
||||||
Program.SaveAllSettings();
|
Program.SaveAllSettings();
|
||||||
|
|
||||||
ExportImportManager.Export(sfd.FileName);
|
ExportImportManager.Export(sfd.FileName);
|
||||||
},
|
},
|
||||||
() =>
|
() =>
|
||||||
|
@ -490,6 +491,7 @@ private void btnImport_Click(object sender, EventArgs e)
|
||||||
TaskEx.Run(() =>
|
TaskEx.Run(() =>
|
||||||
{
|
{
|
||||||
ExportImportManager.Import(ofd.FileName);
|
ExportImportManager.Import(ofd.FileName);
|
||||||
|
|
||||||
Program.LoadAllSettings();
|
Program.LoadAllSettings();
|
||||||
},
|
},
|
||||||
() =>
|
() =>
|
||||||
|
@ -503,7 +505,7 @@ private void btnImport_Click(object sender, EventArgs e)
|
||||||
btnImport.Enabled = true;
|
btnImport.Enabled = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
Program.MainForm.UpdateAll();
|
Program.MainForm.UpdateControls();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -57,9 +57,6 @@ public MainForm()
|
||||||
private void MainForm_HandleCreated(object sender, EventArgs e)
|
private void MainForm_HandleCreated(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
UpdateControls();
|
UpdateControls();
|
||||||
InitHotkeys();
|
|
||||||
|
|
||||||
IsReady = true;
|
|
||||||
|
|
||||||
DebugHelper.WriteLine("Startup time: {0} ms", Program.StartTimer.ElapsedMilliseconds);
|
DebugHelper.WriteLine("Startup time: {0} ms", Program.StartTimer.ElapsedMilliseconds);
|
||||||
|
|
||||||
|
@ -173,8 +170,10 @@ private void InitializeControls()
|
||||||
HandleCreated += MainForm_HandleCreated;
|
HandleCreated += MainForm_HandleCreated;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void UpdateControls()
|
public void UpdateControls()
|
||||||
{
|
{
|
||||||
|
IsReady = false;
|
||||||
|
|
||||||
niTray.Visible = Program.Settings.ShowTray;
|
niTray.Visible = Program.Settings.ShowTray;
|
||||||
|
|
||||||
if (Program.Settings.RecentLinksRemember)
|
if (Program.Settings.RecentLinksRemember)
|
||||||
|
@ -192,13 +191,8 @@ private void UpdateControls()
|
||||||
isPositionChanged = true;
|
isPositionChanged = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Adjust the menu width to the items
|
|
||||||
tsMain.Width = tsMain.PreferredSize.Width;
|
tsMain.Width = tsMain.PreferredSize.Width;
|
||||||
|
|
||||||
// Calculate the required height to view the whole menu
|
|
||||||
int height = Size.Height + tsMain.PreferredSize.Height - tsMain.Height;
|
int height = Size.Height + tsMain.PreferredSize.Height - tsMain.Height;
|
||||||
|
|
||||||
// Set the minimum size of the form to prevent menu items from hidding
|
|
||||||
MinimumSize = new Size(MinimumSize.Width, height);
|
MinimumSize = new Size(MinimumSize.Width, height);
|
||||||
|
|
||||||
if (Program.Settings.RememberMainFormSize && !Program.Settings.MainFormSize.IsEmpty)
|
if (Program.Settings.RememberMainFormSize && !Program.Settings.MainFormSize.IsEmpty)
|
||||||
|
@ -214,7 +208,6 @@ private void UpdateControls()
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// Adjust the size to the minimum if not loaded
|
|
||||||
Size = new Size(Size.Width, height);
|
Size = new Size(Size.Width, height);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -244,18 +237,10 @@ private void UpdateControls()
|
||||||
UpdateContextMenu();
|
UpdateContextMenu();
|
||||||
UpdateToggleHotkeyButton();
|
UpdateToggleHotkeyButton();
|
||||||
AfterSettingsJobs();
|
AfterSettingsJobs();
|
||||||
}
|
|
||||||
|
|
||||||
public void UpdateAll()
|
InitHotkeys();
|
||||||
{
|
|
||||||
UpdateControls();
|
|
||||||
|
|
||||||
if (Program.HotkeyManager != null)
|
IsReady = true;
|
||||||
{
|
|
||||||
Program.HotkeyManager.UpdateHotkeys(Program.HotkeysConfig.Hotkeys, true);
|
|
||||||
}
|
|
||||||
|
|
||||||
UpdateWorkflowsMenu();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void AfterShownJobs()
|
private void AfterShownJobs()
|
||||||
|
@ -1598,11 +1583,23 @@ private void InitHotkeys()
|
||||||
},
|
},
|
||||||
() =>
|
() =>
|
||||||
{
|
{
|
||||||
Program.HotkeyManager = new HotkeyManager(this, Program.HotkeysConfig.Hotkeys, !Program.NoHotkeys);
|
if (Program.HotkeyManager == null)
|
||||||
Program.HotkeyManager.HotkeyTrigger += HandleHotkeys;
|
{
|
||||||
|
Program.HotkeyManager = new HotkeyManager(this);
|
||||||
|
Program.HotkeyManager.HotkeyTrigger += HandleHotkeys;
|
||||||
|
}
|
||||||
|
|
||||||
|
Program.HotkeyManager.UpdateHotkeys(Program.HotkeysConfig.Hotkeys, !Program.NoHotkeys);
|
||||||
|
|
||||||
DebugHelper.WriteLine("HotkeyManager started");
|
DebugHelper.WriteLine("HotkeyManager started");
|
||||||
|
|
||||||
Program.WatchFolderManager = new WatchFolderManager();
|
if (Program.WatchFolderManager == null)
|
||||||
|
{
|
||||||
|
Program.WatchFolderManager = new WatchFolderManager();
|
||||||
|
}
|
||||||
|
|
||||||
|
Program.WatchFolderManager.UpdateWatchFolders();
|
||||||
|
|
||||||
DebugHelper.WriteLine("WatchFolderManager started");
|
DebugHelper.WriteLine("WatchFolderManager started");
|
||||||
|
|
||||||
UpdateWorkflowsMenu();
|
UpdateWorkflowsMenu();
|
||||||
|
|
|
@ -46,13 +46,11 @@ public class HotkeyManager
|
||||||
|
|
||||||
private HotkeyForm hotkeyForm;
|
private HotkeyForm hotkeyForm;
|
||||||
|
|
||||||
public HotkeyManager(HotkeyForm form, List<HotkeySettings> hotkeys, bool showFailedHotkeys)
|
public HotkeyManager(HotkeyForm form)
|
||||||
{
|
{
|
||||||
hotkeyForm = form;
|
hotkeyForm = form;
|
||||||
hotkeyForm.HotkeyPress += hotkeyForm_HotkeyPress;
|
hotkeyForm.HotkeyPress += hotkeyForm_HotkeyPress;
|
||||||
hotkeyForm.FormClosed += (sender, e) => hotkeyForm.InvokeSafe(() => UnregisterAllHotkeys(false));
|
hotkeyForm.FormClosed += (sender, e) => hotkeyForm.InvokeSafe(() => UnregisterAllHotkeys(false));
|
||||||
|
|
||||||
UpdateHotkeys(hotkeys, showFailedHotkeys);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void UpdateHotkeys(List<HotkeySettings> hotkeys, bool showFailedHotkeys)
|
public void UpdateHotkeys(List<HotkeySettings> hotkeys, bool showFailedHotkeys)
|
||||||
|
@ -152,11 +150,14 @@ public void UnregisterHotkey(HotkeySettings hotkeySetting, bool removeFromList =
|
||||||
|
|
||||||
public void UnregisterAllHotkeys(bool removeFromList = true, bool temporary = false)
|
public void UnregisterAllHotkeys(bool removeFromList = true, bool temporary = false)
|
||||||
{
|
{
|
||||||
foreach (HotkeySettings hotkeySetting in Hotkeys.ToArray())
|
if (Hotkeys != null)
|
||||||
{
|
{
|
||||||
if (!temporary || (temporary && hotkeySetting.TaskSettings.Job != HotkeyType.DisableHotkeys))
|
foreach (HotkeySettings hotkeySetting in Hotkeys.ToArray())
|
||||||
{
|
{
|
||||||
UnregisterHotkey(hotkeySetting, removeFromList);
|
if (!temporary || (temporary && hotkeySetting.TaskSettings.Job != HotkeyType.DisableHotkeys))
|
||||||
|
{
|
||||||
|
UnregisterHotkey(hotkeySetting, removeFromList);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -33,8 +33,13 @@ public class WatchFolderManager : IDisposable
|
||||||
{
|
{
|
||||||
public List<WatchFolder> WatchFolders { get; private set; }
|
public List<WatchFolder> WatchFolders { get; private set; }
|
||||||
|
|
||||||
public WatchFolderManager()
|
public void UpdateWatchFolders()
|
||||||
{
|
{
|
||||||
|
if (WatchFolders != null)
|
||||||
|
{
|
||||||
|
UnregisterAllWatchFolders();
|
||||||
|
}
|
||||||
|
|
||||||
WatchFolders = new List<WatchFolder>();
|
WatchFolders = new List<WatchFolder>();
|
||||||
|
|
||||||
foreach (WatchFolderSettings defaultWatchFolderSetting in Program.DefaultTaskSettings.WatchFolderList)
|
foreach (WatchFolderSettings defaultWatchFolderSetting in Program.DefaultTaskSettings.WatchFolderList)
|
||||||
|
@ -113,7 +118,7 @@ public void UpdateWatchFolderState(WatchFolderSettings watchFolderSetting)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Dispose()
|
public void UnregisterAllWatchFolders()
|
||||||
{
|
{
|
||||||
if (WatchFolders != null)
|
if (WatchFolders != null)
|
||||||
{
|
{
|
||||||
|
@ -126,5 +131,10 @@ public void Dispose()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void Dispose()
|
||||||
|
{
|
||||||
|
UnregisterAllWatchFolders();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in a new issue