2013-11-03 23:53:49 +13:00
|
|
|
|
#region License Information (GPL v3)
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
ShareX - A program that allows you to take screenshots and share any file type
|
2016-01-04 04:16:01 +13:00
|
|
|
|
Copyright (c) 2007-2016 ShareX Team
|
2013-11-03 23:53:49 +13:00
|
|
|
|
|
|
|
|
|
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)
|
|
|
|
|
|
2014-12-11 09:25:20 +13:00
|
|
|
|
using ShareX.HelpersLib;
|
2013-11-03 23:53:49 +13:00
|
|
|
|
using ShareX.Properties;
|
2014-12-11 12:19:28 +13:00
|
|
|
|
using ShareX.ScreenCaptureLib;
|
|
|
|
|
using ShareX.UploadersLib;
|
2013-11-03 23:53:49 +13:00
|
|
|
|
using System;
|
2014-07-05 01:32:47 +12:00
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Diagnostics;
|
2013-11-21 02:36:02 +13:00
|
|
|
|
using System.Drawing;
|
2016-04-24 10:15:35 +12:00
|
|
|
|
using System.IO;
|
2013-11-03 23:53:49 +13:00
|
|
|
|
using System.Linq;
|
2014-11-24 06:06:28 +13:00
|
|
|
|
using System.Text;
|
2013-11-03 23:53:49 +13:00
|
|
|
|
using System.Threading;
|
|
|
|
|
using System.Windows.Forms;
|
|
|
|
|
|
|
|
|
|
namespace ShareX
|
|
|
|
|
{
|
|
|
|
|
public partial class MainForm : HotkeyForm
|
|
|
|
|
{
|
2014-09-13 23:52:12 +12:00
|
|
|
|
public bool IsReady { get; private set; }
|
2013-11-03 23:53:49 +13:00
|
|
|
|
|
2016-03-17 22:25:43 +13:00
|
|
|
|
private bool forceClose, trayMenuSaveSettings = true, firstUpdateCheck = true;
|
2013-11-03 23:53:49 +13:00
|
|
|
|
private UploadInfoManager uim;
|
2014-03-05 02:04:46 +13:00
|
|
|
|
private ToolStripDropDownItem tsmiImageFileUploaders, tsmiTrayImageFileUploaders, tsmiTextFileUploaders, tsmiTrayTextFileUploaders;
|
2015-01-04 03:06:32 +13:00
|
|
|
|
private System.Threading.Timer updateTimer;
|
2015-01-22 07:42:36 +13:00
|
|
|
|
private static readonly object updateTimerLock = new object();
|
2013-11-03 23:53:49 +13:00
|
|
|
|
|
|
|
|
|
public MainForm()
|
|
|
|
|
{
|
2016-02-12 12:28:03 +13:00
|
|
|
|
InitializeControls();
|
2013-11-03 23:53:49 +13:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void MainForm_HandleCreated(object sender, EventArgs e)
|
|
|
|
|
{
|
2016-02-12 12:28:03 +13:00
|
|
|
|
UpdateControls();
|
2013-11-03 23:53:49 +13:00
|
|
|
|
|
|
|
|
|
DebugHelper.WriteLine("Startup time: {0} ms", Program.StartTimer.ElapsedMilliseconds);
|
|
|
|
|
|
2015-09-11 13:18:12 +12:00
|
|
|
|
UseCommandLineArgs(Program.CLI.Commands);
|
|
|
|
|
}
|
|
|
|
|
|
2016-02-12 12:28:03 +13:00
|
|
|
|
private void InitializeControls()
|
2013-11-03 23:53:49 +13:00
|
|
|
|
{
|
|
|
|
|
InitializeComponent();
|
|
|
|
|
|
2016-02-26 09:55:54 +13:00
|
|
|
|
Icon = ShareXResources.Icon;
|
2016-02-11 11:15:05 +13:00
|
|
|
|
niTray.Icon = ShareXResources.Icon;
|
2013-11-03 23:53:49 +13:00
|
|
|
|
Text = Program.Title;
|
|
|
|
|
|
2015-09-24 06:23:25 +12:00
|
|
|
|
tsddbWorkflows.HideImageMargin();
|
|
|
|
|
tsmiTrayWorkflows.HideImageMargin();
|
|
|
|
|
tsmiMonitor.HideImageMargin();
|
|
|
|
|
tsmiTrayMonitor.HideImageMargin();
|
|
|
|
|
tsmiOpen.HideImageMargin();
|
|
|
|
|
tsmiCopy.HideImageMargin();
|
|
|
|
|
tsmiShortenSelectedURL.HideImageMargin();
|
|
|
|
|
tsmiShareSelectedURL.HideImageMargin();
|
|
|
|
|
tsmiTrayRecentItems.HideImageMargin();
|
2014-05-23 12:07:49 +12:00
|
|
|
|
|
2014-05-11 23:47:37 +12:00
|
|
|
|
AddMultiEnumItems<AfterCaptureTasks>(x => Program.DefaultTaskSettings.AfterCaptureJob = Program.DefaultTaskSettings.AfterCaptureJob.Swap(x),
|
2013-11-03 23:53:49 +13:00
|
|
|
|
tsddbAfterCaptureTasks, tsmiTrayAfterCaptureTasks);
|
2014-05-11 23:47:37 +12:00
|
|
|
|
AddMultiEnumItems<AfterUploadTasks>(x => Program.DefaultTaskSettings.AfterUploadJob = Program.DefaultTaskSettings.AfterUploadJob.Swap(x),
|
2013-11-03 23:53:49 +13:00
|
|
|
|
tsddbAfterUploadTasks, tsmiTrayAfterUploadTasks);
|
2014-09-14 02:30:29 +12:00
|
|
|
|
AddEnumItems<ImageDestination>(x =>
|
|
|
|
|
{
|
|
|
|
|
Program.DefaultTaskSettings.ImageDestination = x;
|
2016-02-12 12:28:03 +13:00
|
|
|
|
|
2014-09-14 02:30:29 +12:00
|
|
|
|
if (x == ImageDestination.FileUploader)
|
|
|
|
|
{
|
2014-10-25 13:04:41 +13:00
|
|
|
|
SetEnumChecked(Program.DefaultTaskSettings.ImageFileDestination, tsmiImageFileUploaders, tsmiTrayImageFileUploaders);
|
2014-09-14 02:30:29 +12:00
|
|
|
|
}
|
2016-02-12 12:28:03 +13:00
|
|
|
|
else
|
2014-09-14 02:30:29 +12:00
|
|
|
|
{
|
2014-09-14 19:08:05 +12:00
|
|
|
|
Uncheck(tsmiImageFileUploaders, tsmiTrayImageFileUploaders);
|
2014-09-14 02:30:29 +12:00
|
|
|
|
}
|
|
|
|
|
}, tsmiImageUploaders, tsmiTrayImageUploaders);
|
2014-03-05 02:04:46 +13:00
|
|
|
|
tsmiImageFileUploaders = (ToolStripDropDownItem)tsmiImageUploaders.DropDownItems[tsmiImageUploaders.DropDownItems.Count - 1];
|
|
|
|
|
tsmiTrayImageFileUploaders = (ToolStripDropDownItem)tsmiTrayImageUploaders.DropDownItems[tsmiTrayImageUploaders.DropDownItems.Count - 1];
|
2014-05-23 12:07:49 +12:00
|
|
|
|
AddEnumItems<FileDestination>(x =>
|
|
|
|
|
{
|
|
|
|
|
Program.DefaultTaskSettings.ImageFileDestination = x;
|
|
|
|
|
tsmiImageFileUploaders.PerformClick();
|
|
|
|
|
tsmiTrayImageFileUploaders.PerformClick();
|
|
|
|
|
}, tsmiImageFileUploaders, tsmiTrayImageFileUploaders);
|
2014-09-14 02:35:53 +12:00
|
|
|
|
AddEnumItems<TextDestination>(x =>
|
|
|
|
|
{
|
|
|
|
|
Program.DefaultTaskSettings.TextDestination = x;
|
2016-02-12 12:28:03 +13:00
|
|
|
|
|
2014-09-14 02:35:53 +12:00
|
|
|
|
if (x == TextDestination.FileUploader)
|
|
|
|
|
{
|
2014-10-25 13:04:41 +13:00
|
|
|
|
SetEnumChecked(Program.DefaultTaskSettings.TextFileDestination, tsmiTextFileUploaders, tsmiTrayTextFileUploaders);
|
2014-09-14 02:35:53 +12:00
|
|
|
|
}
|
2016-02-12 12:28:03 +13:00
|
|
|
|
else
|
2014-09-14 02:35:53 +12:00
|
|
|
|
{
|
2014-09-14 19:25:25 +12:00
|
|
|
|
Uncheck(tsmiTextFileUploaders, tsmiTrayTextFileUploaders);
|
2014-09-14 02:35:53 +12:00
|
|
|
|
}
|
|
|
|
|
}, tsmiTextUploaders, tsmiTrayTextUploaders);
|
2014-03-05 02:04:46 +13:00
|
|
|
|
tsmiTextFileUploaders = (ToolStripDropDownItem)tsmiTextUploaders.DropDownItems[tsmiTextUploaders.DropDownItems.Count - 1];
|
|
|
|
|
tsmiTrayTextFileUploaders = (ToolStripDropDownItem)tsmiTrayTextUploaders.DropDownItems[tsmiTrayTextUploaders.DropDownItems.Count - 1];
|
2014-05-23 12:07:49 +12:00
|
|
|
|
AddEnumItems<FileDestination>(x =>
|
|
|
|
|
{
|
|
|
|
|
Program.DefaultTaskSettings.TextFileDestination = x;
|
|
|
|
|
tsmiTextFileUploaders.PerformClick();
|
|
|
|
|
tsmiTrayTextFileUploaders.PerformClick();
|
|
|
|
|
}, tsmiTextFileUploaders, tsmiTrayTextFileUploaders);
|
2014-05-11 23:47:37 +12:00
|
|
|
|
AddEnumItems<FileDestination>(x => Program.DefaultTaskSettings.FileDestination = x, tsmiFileUploaders, tsmiTrayFileUploaders);
|
|
|
|
|
AddEnumItems<UrlShortenerType>(x => Program.DefaultTaskSettings.URLShortenerDestination = x, tsmiURLShorteners, tsmiTrayURLShorteners);
|
2014-07-14 08:59:17 +12:00
|
|
|
|
AddEnumItems<URLSharingServices>(x => Program.DefaultTaskSettings.URLSharingServiceDestination = x, tsmiURLSharingServices, tsmiTrayURLSharingServices);
|
2013-11-03 23:53:49 +13:00
|
|
|
|
|
2014-07-08 04:46:55 +12:00
|
|
|
|
foreach (UrlShortenerType urlShortener in Helpers.GetEnums<UrlShortenerType>())
|
|
|
|
|
{
|
2014-10-25 13:04:41 +13:00
|
|
|
|
ToolStripMenuItem tsmi = new ToolStripMenuItem(urlShortener.GetLocalizedDescription());
|
2014-07-08 04:46:55 +12:00
|
|
|
|
tsmi.Click += (sender, e) => uim.ShortenURL(urlShortener);
|
|
|
|
|
tsmiShortenSelectedURL.DropDownItems.Add(tsmi);
|
|
|
|
|
}
|
|
|
|
|
|
2014-07-14 08:59:17 +12:00
|
|
|
|
foreach (URLSharingServices urlSharingService in Helpers.GetEnums<URLSharingServices>())
|
2014-07-08 04:46:55 +12:00
|
|
|
|
{
|
2014-10-25 13:04:41 +13:00
|
|
|
|
ToolStripMenuItem tsmi = new ToolStripMenuItem(urlSharingService.GetLocalizedDescription());
|
2014-07-14 08:59:17 +12:00
|
|
|
|
tsmi.Click += (sender, e) => uim.ShareURL(urlSharingService);
|
2014-07-08 04:46:55 +12:00
|
|
|
|
tsmiShareSelectedURL.DropDownItems.Add(tsmi);
|
|
|
|
|
}
|
|
|
|
|
|
2013-11-03 23:53:49 +13:00
|
|
|
|
ImageList il = new ImageList();
|
|
|
|
|
il.ColorDepth = ColorDepth.Depth32Bit;
|
|
|
|
|
il.Images.Add(Resources.navigation_090_button);
|
|
|
|
|
il.Images.Add(Resources.cross_button);
|
|
|
|
|
il.Images.Add(Resources.tick_button);
|
|
|
|
|
il.Images.Add(Resources.navigation_000_button);
|
2016-02-23 07:00:22 +13:00
|
|
|
|
il.Images.Add(Resources.clock);
|
2013-11-03 23:53:49 +13:00
|
|
|
|
lvUploads.SmallImageList = il;
|
|
|
|
|
|
|
|
|
|
TaskManager.ListViewControl = lvUploads;
|
|
|
|
|
uim = new UploadInfoManager(lvUploads);
|
2014-06-07 06:51:09 +12:00
|
|
|
|
|
2016-04-25 06:54:51 +12:00
|
|
|
|
// Required for BackColor Transparent to work
|
|
|
|
|
lblMainFormTip.Parent = lvUploads;
|
|
|
|
|
pbTips.Parent = lvUploads;
|
|
|
|
|
|
2016-02-11 11:15:05 +13:00
|
|
|
|
foreach (ToolStripDropDownItem dropDownItem in new ToolStripDropDownItem[]
|
|
|
|
|
{
|
|
|
|
|
tsddbAfterCaptureTasks, tsddbAfterUploadTasks, tsmiImageUploaders, tsmiImageFileUploaders, tsmiTextUploaders, tsmiTextFileUploaders, tsmiFileUploaders,
|
|
|
|
|
tsmiURLShorteners, tsmiURLSharingServices, tsmiTrayAfterCaptureTasks, tsmiTrayAfterUploadTasks, tsmiTrayImageUploaders, tsmiTrayImageFileUploaders,
|
|
|
|
|
tsmiTrayTextUploaders, tsmiTrayTextFileUploaders, tsmiTrayFileUploaders, tsmiTrayURLShorteners, tsmiTrayURLSharingServices
|
|
|
|
|
})
|
|
|
|
|
{
|
|
|
|
|
dropDownItem.DropDown.Closing += (sender, e) => e.Cancel = e.CloseReason == ToolStripDropDownCloseReason.ItemClicked;
|
|
|
|
|
}
|
|
|
|
|
|
2014-06-07 06:51:09 +12:00
|
|
|
|
ExportImportControl.UploadRequested += json => UploadManager.UploadText(json);
|
2016-02-12 12:28:03 +13:00
|
|
|
|
|
|
|
|
|
HandleCreated += MainForm_HandleCreated;
|
|
|
|
|
}
|
|
|
|
|
|
2016-02-12 14:31:11 +13:00
|
|
|
|
public void UpdateControls()
|
2016-02-12 12:28:03 +13:00
|
|
|
|
{
|
2016-02-12 14:31:11 +13:00
|
|
|
|
IsReady = false;
|
|
|
|
|
|
2016-02-12 12:28:03 +13:00
|
|
|
|
niTray.Visible = Program.Settings.ShowTray;
|
|
|
|
|
|
2016-02-27 19:57:40 +13:00
|
|
|
|
TaskManager.RecentManager.InitItems();
|
2016-02-12 12:28:03 +13:00
|
|
|
|
|
|
|
|
|
bool isPositionChanged = false;
|
|
|
|
|
|
|
|
|
|
if (Program.Settings.RememberMainFormPosition && !Program.Settings.MainFormPosition.IsEmpty &&
|
|
|
|
|
CaptureHelpers.GetScreenBounds().IntersectsWith(new Rectangle(Program.Settings.MainFormPosition, Program.Settings.MainFormSize)))
|
|
|
|
|
{
|
|
|
|
|
StartPosition = FormStartPosition.Manual;
|
|
|
|
|
Location = Program.Settings.MainFormPosition;
|
|
|
|
|
isPositionChanged = true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
tsMain.Width = tsMain.PreferredSize.Width;
|
|
|
|
|
int height = Size.Height + tsMain.PreferredSize.Height - tsMain.Height;
|
|
|
|
|
MinimumSize = new Size(MinimumSize.Width, height);
|
|
|
|
|
|
|
|
|
|
if (Program.Settings.RememberMainFormSize && !Program.Settings.MainFormSize.IsEmpty)
|
|
|
|
|
{
|
|
|
|
|
Size = Program.Settings.MainFormSize;
|
|
|
|
|
|
|
|
|
|
if (!isPositionChanged)
|
|
|
|
|
{
|
|
|
|
|
StartPosition = FormStartPosition.Manual;
|
|
|
|
|
Rectangle activeScreen = CaptureHelpers.GetActiveScreenBounds();
|
|
|
|
|
Location = new Point(activeScreen.Width / 2 - Size.Width / 2, activeScreen.Height / 2 - Size.Height / 2);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
Size = new Size(Size.Width, height);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
switch (Program.Settings.ImagePreview)
|
|
|
|
|
{
|
|
|
|
|
case ImagePreviewVisibility.Show:
|
|
|
|
|
tsmiImagePreviewShow.Check();
|
|
|
|
|
break;
|
|
|
|
|
case ImagePreviewVisibility.Hide:
|
|
|
|
|
tsmiImagePreviewHide.Check();
|
|
|
|
|
break;
|
|
|
|
|
case ImagePreviewVisibility.Automatic:
|
|
|
|
|
tsmiImagePreviewAutomatic.Check();
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (Program.Settings.PreviewSplitterDistance > 0)
|
|
|
|
|
{
|
|
|
|
|
scMain.SplitterDistance = Program.Settings.PreviewSplitterDistance;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
TaskbarManager.Enabled = Program.Settings.TaskbarProgressEnabled;
|
|
|
|
|
|
|
|
|
|
UpdateCheckStates();
|
|
|
|
|
UpdateMainWindowLayout();
|
|
|
|
|
UpdateUploaderMenuNames();
|
|
|
|
|
UpdateContextMenu();
|
|
|
|
|
UpdateToggleHotkeyButton();
|
|
|
|
|
AfterSettingsJobs();
|
2016-02-12 13:15:23 +13:00
|
|
|
|
|
2016-02-12 14:31:11 +13:00
|
|
|
|
InitHotkeys();
|
2016-02-12 13:15:23 +13:00
|
|
|
|
|
2016-02-12 14:31:11 +13:00
|
|
|
|
IsReady = true;
|
2016-02-12 13:15:23 +13:00
|
|
|
|
}
|
|
|
|
|
|
2016-02-12 12:28:03 +13:00
|
|
|
|
private void AfterShownJobs()
|
|
|
|
|
{
|
2016-02-25 22:51:57 +13:00
|
|
|
|
if (!Program.Settings.ShowMostRecentTaskFirst && lvUploads.Items.Count > 0)
|
|
|
|
|
{
|
|
|
|
|
lvUploads.Items[lvUploads.Items.Count - 1].EnsureVisible();
|
|
|
|
|
}
|
|
|
|
|
|
2016-02-12 12:28:03 +13:00
|
|
|
|
if (Program.IsFirstTimeConfig)
|
|
|
|
|
{
|
|
|
|
|
using (FirstTimeConfigForm firstTimeConfigForm = new FirstTimeConfigForm())
|
|
|
|
|
{
|
|
|
|
|
firstTimeConfigForm.ShowDialog();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2016-03-10 05:37:54 +13:00
|
|
|
|
this.ForceActivate();
|
2016-02-12 12:28:03 +13:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (Program.Settings != null && Program.Settings.ShowTrayLeftClickTip && niTray.Visible && Program.Settings.TrayLeftClickAction == HotkeyType.RectangleRegion)
|
|
|
|
|
{
|
|
|
|
|
niTray.ShowBalloonTip(5000, "ShareX", Resources.MainForm_AfterShownJobs_You_can_single_left_click_the_ShareX_tray_icon_to_start_region_capture_, ToolTipIcon.Info);
|
|
|
|
|
Program.Settings.ShowTrayLeftClickTip = false;
|
|
|
|
|
}
|
2013-11-03 23:53:49 +13:00
|
|
|
|
}
|
|
|
|
|
|
2014-05-18 14:21:00 +12:00
|
|
|
|
private void UpdateWorkflowsMenu()
|
|
|
|
|
{
|
|
|
|
|
tsddbWorkflows.DropDownItems.Clear();
|
2014-05-18 22:12:12 +12:00
|
|
|
|
tsmiTrayWorkflows.DropDownItems.Clear();
|
2014-05-18 18:21:55 +12:00
|
|
|
|
|
2014-06-07 13:08:34 +12:00
|
|
|
|
foreach (HotkeySettings hotkeySetting in Program.HotkeysConfig.Hotkeys)
|
2014-05-18 14:21:00 +12:00
|
|
|
|
{
|
2014-05-19 06:12:39 +12:00
|
|
|
|
if (hotkeySetting.TaskSettings.Job != HotkeyType.None && (!Program.Settings.WorkflowsOnlyShowEdited || !hotkeySetting.TaskSettings.IsUsingDefaultSettings))
|
2014-05-18 17:08:15 +12:00
|
|
|
|
{
|
2014-05-19 06:12:39 +12:00
|
|
|
|
tsddbWorkflows.DropDownItems.Add(WorkflowMenuItem(hotkeySetting));
|
|
|
|
|
tsmiTrayWorkflows.DropDownItems.Add(WorkflowMenuItem(hotkeySetting));
|
2014-05-18 17:08:15 +12:00
|
|
|
|
}
|
2014-05-19 06:12:39 +12:00
|
|
|
|
}
|
2014-05-18 18:21:55 +12:00
|
|
|
|
|
2014-06-07 13:08:34 +12:00
|
|
|
|
if (tsddbWorkflows.DropDownItems.Count > 0)
|
|
|
|
|
{
|
|
|
|
|
ToolStripSeparator tss = new ToolStripSeparator();
|
|
|
|
|
tsddbWorkflows.DropDownItems.Add(tss);
|
|
|
|
|
}
|
|
|
|
|
|
2014-10-17 22:58:15 +13:00
|
|
|
|
ToolStripMenuItem tsmi = new ToolStripMenuItem(Resources.MainForm_UpdateWorkflowsMenu_You_can_add_workflows_from_hotkey_settings___);
|
2014-06-07 13:08:34 +12:00
|
|
|
|
tsmi.Click += tsbHotkeySettings_Click;
|
|
|
|
|
tsddbWorkflows.DropDownItems.Add(tsmi);
|
|
|
|
|
|
|
|
|
|
tsmiTrayWorkflows.Visible = tsmiTrayWorkflows.DropDownItems.Count > 0;
|
2014-11-24 06:06:28 +13:00
|
|
|
|
|
|
|
|
|
UpdateMainFormTip();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void UpdateMainFormTip()
|
|
|
|
|
{
|
2014-11-24 08:04:14 +13:00
|
|
|
|
TaskManager.UpdateMainFormTip();
|
|
|
|
|
|
2015-04-22 07:31:03 +12:00
|
|
|
|
List<HotkeySettings> hotkeys = Program.HotkeysConfig.Hotkeys.Where(x => x.HotkeyInfo.IsValidHotkey).ToList();
|
|
|
|
|
|
|
|
|
|
if (hotkeys.Count > 0)
|
2014-11-24 06:06:28 +13:00
|
|
|
|
{
|
2016-04-25 03:17:59 +12:00
|
|
|
|
StringBuilder sb = new StringBuilder();
|
|
|
|
|
|
2014-11-28 15:32:10 +13:00
|
|
|
|
sb.AppendLine(Resources.MainForm_UpdateMainFormTip_Currently_configured_hotkeys_);
|
2016-04-25 06:54:51 +12:00
|
|
|
|
sb.AppendLine();
|
2014-11-24 06:06:28 +13:00
|
|
|
|
|
2015-04-22 07:31:03 +12:00
|
|
|
|
foreach (HotkeySettings hotkey in hotkeys)
|
2014-11-24 06:06:28 +13:00
|
|
|
|
{
|
2015-01-17 12:29:52 +13:00
|
|
|
|
sb.AppendFormat("{0} | {1}\r\n", hotkey.HotkeyInfo, hotkey.TaskSettings);
|
2014-11-24 06:06:28 +13:00
|
|
|
|
}
|
|
|
|
|
|
2016-04-25 03:17:59 +12:00
|
|
|
|
lblMainFormTip.Text = sb.ToString().Trim();
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
lblMainFormTip.Text = "";
|
|
|
|
|
}
|
2014-05-18 14:21:00 +12:00
|
|
|
|
}
|
|
|
|
|
|
2014-05-19 06:12:39 +12:00
|
|
|
|
private ToolStripMenuItem WorkflowMenuItem(HotkeySettings hotkeySetting)
|
|
|
|
|
{
|
2015-01-17 12:29:52 +13:00
|
|
|
|
ToolStripMenuItem tsmi = new ToolStripMenuItem(hotkeySetting.TaskSettings.ToString().Replace("&", "&&"));
|
2014-06-07 13:08:34 +12:00
|
|
|
|
if (hotkeySetting.HotkeyInfo.IsValidHotkey)
|
|
|
|
|
{
|
2014-10-19 10:48:47 +13:00
|
|
|
|
tsmi.ShortcutKeyDisplayString = " " + hotkeySetting.HotkeyInfo;
|
2014-06-07 13:08:34 +12:00
|
|
|
|
}
|
|
|
|
|
if (!hotkeySetting.TaskSettings.IsUsingDefaultSettings)
|
|
|
|
|
{
|
|
|
|
|
tsmi.Font = new Font(tsmi.Font, FontStyle.Bold);
|
|
|
|
|
}
|
2014-07-25 07:28:59 +12:00
|
|
|
|
tsmi.Click += (sender, e) => ExecuteJob(hotkeySetting.TaskSettings);
|
2014-05-19 06:12:39 +12:00
|
|
|
|
return tsmi;
|
|
|
|
|
}
|
|
|
|
|
|
2013-11-03 23:53:49 +13:00
|
|
|
|
private void UpdateDestinationStates()
|
|
|
|
|
{
|
|
|
|
|
if (Program.UploadersConfig != null)
|
|
|
|
|
{
|
|
|
|
|
EnableDisableToolStripMenuItems<ImageDestination>(tsmiImageUploaders, tsmiTrayImageUploaders);
|
2014-03-05 02:04:46 +13:00
|
|
|
|
EnableDisableToolStripMenuItems<FileDestination>(tsmiImageFileUploaders, tsmiTrayImageFileUploaders);
|
2013-11-03 23:53:49 +13:00
|
|
|
|
EnableDisableToolStripMenuItems<TextDestination>(tsmiTextUploaders, tsmiTrayTextUploaders);
|
2014-03-05 02:04:46 +13:00
|
|
|
|
EnableDisableToolStripMenuItems<FileDestination>(tsmiTextFileUploaders, tsmiTrayTextFileUploaders);
|
2013-11-03 23:53:49 +13:00
|
|
|
|
EnableDisableToolStripMenuItems<FileDestination>(tsmiFileUploaders, tsmiTrayFileUploaders);
|
|
|
|
|
EnableDisableToolStripMenuItems<UrlShortenerType>(tsmiURLShorteners, tsmiTrayURLShorteners);
|
2014-07-11 13:52:53 +12:00
|
|
|
|
EnableDisableToolStripMenuItems<URLSharingServices>(tsmiURLSharingServices, tsmiTrayURLSharingServices);
|
2013-11-03 23:53:49 +13:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void AddEnumItems<T>(Action<T> selectedEnum, params ToolStripDropDownItem[] parents)
|
|
|
|
|
{
|
2014-10-25 13:18:57 +13:00
|
|
|
|
string[] enums = Helpers.GetLocalizedEnumDescriptions<T>();
|
2013-11-03 23:53:49 +13:00
|
|
|
|
|
|
|
|
|
foreach (ToolStripDropDownItem parent in parents)
|
|
|
|
|
{
|
|
|
|
|
for (int i = 0; i < enums.Length; i++)
|
|
|
|
|
{
|
|
|
|
|
ToolStripMenuItem tsmi = new ToolStripMenuItem(enums[i]);
|
|
|
|
|
|
|
|
|
|
int index = i;
|
|
|
|
|
|
|
|
|
|
tsmi.Click += (sender, e) =>
|
|
|
|
|
{
|
|
|
|
|
foreach (ToolStripDropDownItem parent2 in parents)
|
|
|
|
|
{
|
|
|
|
|
for (int i2 = 0; i2 < enums.Length; i2++)
|
|
|
|
|
{
|
|
|
|
|
ToolStripMenuItem tsmi2 = (ToolStripMenuItem)parent2.DropDownItems[i2];
|
|
|
|
|
tsmi2.Checked = index == i2;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
selectedEnum((T)Enum.ToObject(typeof(T), index));
|
|
|
|
|
|
|
|
|
|
UpdateUploaderMenuNames();
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
parent.DropDownItems.Add(tsmi);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2014-10-25 13:04:41 +13:00
|
|
|
|
public static void Uncheck(params ToolStripDropDownItem[] lists)
|
|
|
|
|
{
|
|
|
|
|
foreach (ToolStripDropDownItem parent in lists)
|
|
|
|
|
{
|
|
|
|
|
foreach (var dropDownItem in parent.DropDownItems)
|
|
|
|
|
{
|
|
|
|
|
((ToolStripMenuItem)dropDownItem).Checked = false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2014-09-14 20:57:24 +12:00
|
|
|
|
private static void SetEnumChecked(Enum value, params ToolStripDropDownItem[] parents)
|
2013-11-03 23:53:49 +13:00
|
|
|
|
{
|
2014-09-14 02:30:29 +12:00
|
|
|
|
if (value == null)
|
2014-10-25 13:04:41 +13:00
|
|
|
|
{
|
2014-09-14 02:30:29 +12:00
|
|
|
|
return;
|
2014-10-25 13:04:41 +13:00
|
|
|
|
}
|
|
|
|
|
|
2013-11-03 23:53:49 +13:00
|
|
|
|
int index = value.GetIndex();
|
|
|
|
|
|
|
|
|
|
foreach (ToolStripDropDownItem parent in parents)
|
|
|
|
|
{
|
|
|
|
|
((ToolStripMenuItem)parent.DropDownItems[index]).Checked = true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void AddMultiEnumItems<T>(Action<T> selectedEnum, params ToolStripDropDownItem[] parents)
|
|
|
|
|
{
|
2014-10-25 13:18:57 +13:00
|
|
|
|
string[] enums = Helpers.GetLocalizedEnumDescriptions<T>().Skip(1).ToArray();
|
2013-11-03 23:53:49 +13:00
|
|
|
|
|
|
|
|
|
foreach (ToolStripDropDownItem parent in parents)
|
|
|
|
|
{
|
2014-10-19 09:29:23 +13:00
|
|
|
|
for (int i = 0; i < enums.Length; i++)
|
2013-11-03 23:53:49 +13:00
|
|
|
|
{
|
|
|
|
|
ToolStripMenuItem tsmi = new ToolStripMenuItem(enums[i]);
|
|
|
|
|
|
|
|
|
|
int index = i;
|
|
|
|
|
|
|
|
|
|
tsmi.Click += (sender, e) =>
|
|
|
|
|
{
|
|
|
|
|
foreach (ToolStripDropDownItem parent2 in parents)
|
|
|
|
|
{
|
|
|
|
|
ToolStripMenuItem tsmi2 = (ToolStripMenuItem)parent2.DropDownItems[index];
|
|
|
|
|
tsmi2.Checked = !tsmi2.Checked;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
selectedEnum((T)Enum.ToObject(typeof(T), 1 << index));
|
|
|
|
|
|
|
|
|
|
UpdateUploaderMenuNames();
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
parent.DropDownItems.Add(tsmi);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void SetMultiEnumChecked(Enum value, params ToolStripDropDownItem[] parents)
|
|
|
|
|
{
|
|
|
|
|
for (int i = 0; i < parents[0].DropDownItems.Count; i++)
|
|
|
|
|
{
|
|
|
|
|
foreach (ToolStripDropDownItem parent in parents)
|
|
|
|
|
{
|
|
|
|
|
ToolStripMenuItem tsmi = (ToolStripMenuItem)parent.DropDownItems[i];
|
|
|
|
|
tsmi.Checked = value.HasFlag(1 << i);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void EnableDisableToolStripMenuItems<T>(params ToolStripDropDownItem[] parents)
|
|
|
|
|
{
|
|
|
|
|
foreach (ToolStripDropDownItem parent in parents)
|
|
|
|
|
{
|
|
|
|
|
for (int i = 0; i < parent.DropDownItems.Count; i++)
|
|
|
|
|
{
|
2016-03-23 15:57:02 +13:00
|
|
|
|
parent.DropDownItems[i].Enabled = UploadersConfigValidator.Validate<T>(i, Program.UploadersConfig);
|
2013-11-03 23:53:49 +13:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2016-02-12 12:28:03 +13:00
|
|
|
|
private void UpdateContextMenu()
|
2013-11-03 23:53:49 +13:00
|
|
|
|
{
|
2014-07-17 18:58:17 +12:00
|
|
|
|
cmsTaskInfo.SuspendLayout();
|
2013-11-03 23:53:49 +13:00
|
|
|
|
|
2014-07-17 18:58:17 +12:00
|
|
|
|
tsmiStopUpload.Visible = tsmiOpen.Visible = tsmiCopy.Visible = tsmiShowErrors.Visible = tsmiShowResponse.Visible = tsmiShowQRCode.Visible = tsmiUploadSelectedFile.Visible =
|
2014-07-28 10:08:37 +12:00
|
|
|
|
tsmiEditSelectedFile.Visible = tsmiDeleteSelectedFile.Visible = tsmiShortenSelectedURL.Visible = tsmiShareSelectedURL.Visible = tsmiClearList.Visible = tssUploadInfo1.Visible = false;
|
2013-11-03 23:53:49 +13:00
|
|
|
|
pbPreview.Reset();
|
|
|
|
|
uim.RefreshSelectedItems();
|
|
|
|
|
|
2014-06-19 07:17:22 +12:00
|
|
|
|
switch (Program.Settings.ImagePreview)
|
|
|
|
|
{
|
|
|
|
|
case ImagePreviewVisibility.Show:
|
|
|
|
|
scMain.Panel2Collapsed = false;
|
|
|
|
|
break;
|
|
|
|
|
case ImagePreviewVisibility.Hide:
|
|
|
|
|
scMain.Panel2Collapsed = true;
|
|
|
|
|
break;
|
|
|
|
|
case ImagePreviewVisibility.Automatic:
|
|
|
|
|
scMain.Panel2Collapsed = !uim.IsItemSelected || (!uim.SelectedItem.IsImageFile && !uim.SelectedItem.IsImageURL);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
2013-11-03 23:53:49 +13:00
|
|
|
|
if (uim.IsItemSelected)
|
|
|
|
|
{
|
2015-09-17 12:39:57 +12:00
|
|
|
|
// Open
|
|
|
|
|
tsmiOpen.Visible = true;
|
|
|
|
|
|
|
|
|
|
tsmiOpenURL.Enabled = uim.SelectedItem.IsURLExist;
|
|
|
|
|
tsmiOpenShortenedURL.Enabled = uim.SelectedItem.IsShortenedURLExist;
|
|
|
|
|
tsmiOpenThumbnailURL.Enabled = uim.SelectedItem.IsThumbnailURLExist;
|
|
|
|
|
tsmiOpenDeletionURL.Enabled = uim.SelectedItem.IsDeletionURLExist;
|
|
|
|
|
|
|
|
|
|
tsmiOpenFile.Enabled = uim.SelectedItem.IsFileExist;
|
|
|
|
|
tsmiOpenFolder.Enabled = uim.SelectedItem.IsFileExist;
|
|
|
|
|
tsmiOpenThumbnailFile.Enabled = uim.SelectedItem.IsThumbnailFileExist;
|
|
|
|
|
|
2013-11-03 23:53:49 +13:00
|
|
|
|
if (GetCurrentTasks().Any(x => x.IsWorking))
|
|
|
|
|
{
|
|
|
|
|
tsmiStopUpload.Visible = true;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2014-05-25 17:53:47 +12:00
|
|
|
|
tsmiShowErrors.Visible = uim.SelectedItem.Info.Result.IsError;
|
2013-11-03 23:53:49 +13:00
|
|
|
|
|
2014-04-05 10:56:30 +13:00
|
|
|
|
// Copy
|
|
|
|
|
tsmiCopy.Visible = true;
|
2013-11-03 23:53:49 +13:00
|
|
|
|
|
2014-04-05 10:56:30 +13:00
|
|
|
|
tsmiCopyURL.Enabled = uim.SelectedItems.Any(x => x.IsURLExist);
|
|
|
|
|
tsmiCopyShortenedURL.Enabled = uim.SelectedItems.Any(x => x.IsShortenedURLExist);
|
|
|
|
|
tsmiCopyThumbnailURL.Enabled = uim.SelectedItems.Any(x => x.IsThumbnailURLExist);
|
|
|
|
|
tsmiCopyDeletionURL.Enabled = uim.SelectedItems.Any(x => x.IsDeletionURLExist);
|
2013-11-03 23:53:49 +13:00
|
|
|
|
|
2014-04-05 10:56:30 +13:00
|
|
|
|
tsmiCopyFile.Enabled = uim.SelectedItem.IsFileExist;
|
|
|
|
|
tsmiCopyImage.Enabled = uim.SelectedItem.IsImageFile;
|
|
|
|
|
tsmiCopyText.Enabled = uim.SelectedItem.IsTextFile;
|
2014-04-23 09:00:41 +12:00
|
|
|
|
tsmiCopyThumbnailFile.Enabled = uim.SelectedItem.IsThumbnailFileExist;
|
|
|
|
|
tsmiCopyThumbnailImage.Enabled = uim.SelectedItem.IsThumbnailFileExist;
|
2013-11-03 23:53:49 +13:00
|
|
|
|
|
2014-04-05 10:56:30 +13:00
|
|
|
|
tsmiCopyHTMLLink.Enabled = uim.SelectedItems.Any(x => x.IsURLExist);
|
|
|
|
|
tsmiCopyHTMLImage.Enabled = uim.SelectedItems.Any(x => x.IsImageURL);
|
|
|
|
|
tsmiCopyHTMLLinkedImage.Enabled = uim.SelectedItems.Any(x => x.IsImageURL && x.IsThumbnailURLExist);
|
2013-11-03 23:53:49 +13:00
|
|
|
|
|
2014-04-05 10:56:30 +13:00
|
|
|
|
tsmiCopyForumLink.Enabled = uim.SelectedItems.Any(x => x.IsURLExist);
|
|
|
|
|
tsmiCopyForumImage.Enabled = uim.SelectedItems.Any(x => x.IsImageURL && x.IsURLExist);
|
|
|
|
|
tsmiCopyForumLinkedImage.Enabled = uim.SelectedItems.Any(x => x.IsImageURL && x.IsThumbnailURLExist);
|
2013-11-03 23:53:49 +13:00
|
|
|
|
|
2014-04-05 10:56:30 +13:00
|
|
|
|
tsmiCopyFilePath.Enabled = uim.SelectedItems.Any(x => x.IsFilePathValid);
|
|
|
|
|
tsmiCopyFileName.Enabled = uim.SelectedItems.Any(x => x.IsFilePathValid);
|
|
|
|
|
tsmiCopyFileNameWithExtension.Enabled = uim.SelectedItems.Any(x => x.IsFilePathValid);
|
|
|
|
|
tsmiCopyFolder.Enabled = uim.SelectedItems.Any(x => x.IsFilePathValid);
|
2013-11-03 23:53:49 +13:00
|
|
|
|
|
2014-04-05 10:56:30 +13:00
|
|
|
|
CleanCustomClipboardFormats();
|
2013-11-03 23:53:49 +13:00
|
|
|
|
|
2014-04-05 10:56:30 +13:00
|
|
|
|
if (Program.Settings.ClipboardContentFormats != null && Program.Settings.ClipboardContentFormats.Count > 0)
|
|
|
|
|
{
|
|
|
|
|
tssCopy5.Visible = true;
|
|
|
|
|
|
|
|
|
|
foreach (ClipboardFormat cf in Program.Settings.ClipboardContentFormats)
|
|
|
|
|
{
|
|
|
|
|
ToolStripMenuItem tsmiClipboardFormat = new ToolStripMenuItem(cf.Description);
|
|
|
|
|
tsmiClipboardFormat.Tag = cf;
|
|
|
|
|
tsmiClipboardFormat.Click += tsmiClipboardFormat_Click;
|
|
|
|
|
tsmiCopy.DropDownItems.Add(tsmiClipboardFormat);
|
2013-11-03 23:53:49 +13:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
tsmiUploadSelectedFile.Visible = uim.SelectedItem.IsFileExist;
|
2014-07-17 18:58:17 +12:00
|
|
|
|
tsmiEditSelectedFile.Visible = uim.SelectedItem.IsImageFile;
|
2014-07-28 10:08:37 +12:00
|
|
|
|
tsmiDeleteSelectedFile.Visible = uim.SelectedItem.IsFileExist;
|
2014-07-08 04:46:55 +12:00
|
|
|
|
tsmiShortenSelectedURL.Visible = uim.SelectedItem.IsURLExist;
|
|
|
|
|
tsmiShareSelectedURL.Visible = uim.SelectedItem.IsURLExist;
|
|
|
|
|
tsmiShowQRCode.Visible = uim.SelectedItem.IsURLExist;
|
|
|
|
|
tsmiShowResponse.Visible = !string.IsNullOrEmpty(uim.SelectedItem.Info.Result.Response);
|
2013-11-03 23:53:49 +13:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!scMain.Panel2Collapsed)
|
|
|
|
|
{
|
|
|
|
|
if (uim.SelectedItem.IsImageFile)
|
|
|
|
|
{
|
|
|
|
|
pbPreview.LoadImageFromFileAsync(uim.SelectedItem.Info.FilePath);
|
|
|
|
|
}
|
|
|
|
|
else if (uim.SelectedItem.IsImageURL)
|
|
|
|
|
{
|
|
|
|
|
pbPreview.LoadImageFromURLAsync(uim.SelectedItem.Info.Result.URL);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
tsmiClearList.Visible = tssUploadInfo1.Visible = lvUploads.Items.Count > 0;
|
|
|
|
|
|
2014-07-17 18:58:17 +12:00
|
|
|
|
cmsTaskInfo.ResumeLayout();
|
2014-06-19 07:17:22 +12:00
|
|
|
|
Refresh();
|
2013-11-03 23:53:49 +13:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void CleanCustomClipboardFormats()
|
|
|
|
|
{
|
|
|
|
|
tssCopy5.Visible = false;
|
|
|
|
|
|
|
|
|
|
int tssCopy5Index = tsmiCopy.DropDownItems.IndexOf(tssCopy5);
|
|
|
|
|
|
|
|
|
|
while (tssCopy5Index < tsmiCopy.DropDownItems.Count - 1)
|
|
|
|
|
{
|
|
|
|
|
using (ToolStripItem tsi = tsmiCopy.DropDownItems[tsmiCopy.DropDownItems.Count - 1])
|
|
|
|
|
{
|
|
|
|
|
tsmiCopy.DropDownItems.Remove(tsi);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void AfterSettingsJobs()
|
|
|
|
|
{
|
2016-04-15 13:06:08 +12:00
|
|
|
|
if (Program.Settings.TrayTextMoreInfo)
|
|
|
|
|
{
|
|
|
|
|
niTray.Text = $"{Program.Title} ({Program.Build})";
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
niTray.Text = "ShareX";
|
|
|
|
|
}
|
|
|
|
|
|
2015-01-12 22:14:59 +13:00
|
|
|
|
HelpersOptions.CurrentProxy = Program.Settings.ProxySettings;
|
2016-03-14 14:10:19 +13:00
|
|
|
|
HelpersOptions.AcceptInvalidSSLCertificates = Program.Settings.AcceptInvalidSSLCertificates;
|
2016-01-01 21:23:56 +13:00
|
|
|
|
HelpersOptions.UseAlternativeCopyImage = !Program.Settings.UseDefaultClipboardCopyImage;
|
|
|
|
|
HelpersOptions.UseAlternativeGetImage = !Program.Settings.UseDefaultClipboardGetImage;
|
2015-11-11 22:14:39 +13:00
|
|
|
|
HelpersOptions.DefaultCopyImageFillBackground = Program.Settings.DefaultClipboardCopyImageFillBackground;
|
2015-01-12 22:14:59 +13:00
|
|
|
|
HelpersOptions.BrowserPath = Program.Settings.BrowserPath;
|
2016-02-24 07:05:44 +13:00
|
|
|
|
TaskManager.RecentManager.MaxCount = Program.Settings.RecentTasksMaxCount;
|
2016-02-11 11:15:05 +13:00
|
|
|
|
|
|
|
|
|
ConfigureAutoUpdate();
|
2013-11-03 23:53:49 +13:00
|
|
|
|
}
|
|
|
|
|
|
2016-02-12 12:28:03 +13:00
|
|
|
|
public void UpdateCheckStates()
|
2013-11-03 23:53:49 +13:00
|
|
|
|
{
|
2014-05-11 23:47:37 +12:00
|
|
|
|
SetMultiEnumChecked(Program.DefaultTaskSettings.AfterCaptureJob, tsddbAfterCaptureTasks, tsmiTrayAfterCaptureTasks);
|
|
|
|
|
SetMultiEnumChecked(Program.DefaultTaskSettings.AfterUploadJob, tsddbAfterUploadTasks, tsmiTrayAfterUploadTasks);
|
|
|
|
|
SetEnumChecked(Program.DefaultTaskSettings.ImageDestination, tsmiImageUploaders, tsmiTrayImageUploaders);
|
2016-02-12 12:28:03 +13:00
|
|
|
|
SetImageFileDestinationChecked(Program.DefaultTaskSettings.ImageDestination, Program.DefaultTaskSettings.ImageFileDestination, tsmiImageFileUploaders, tsmiTrayImageFileUploaders);
|
2014-05-11 23:47:37 +12:00
|
|
|
|
SetEnumChecked(Program.DefaultTaskSettings.TextDestination, tsmiTextUploaders, tsmiTrayTextUploaders);
|
2016-02-12 12:28:03 +13:00
|
|
|
|
SetTextFileDestinationChecked(Program.DefaultTaskSettings.TextDestination, Program.DefaultTaskSettings.TextFileDestination, tsmiTextFileUploaders, tsmiTrayTextFileUploaders);
|
2014-05-11 23:47:37 +12:00
|
|
|
|
SetEnumChecked(Program.DefaultTaskSettings.FileDestination, tsmiFileUploaders, tsmiTrayFileUploaders);
|
|
|
|
|
SetEnumChecked(Program.DefaultTaskSettings.URLShortenerDestination, tsmiURLShorteners, tsmiTrayURLShorteners);
|
2014-07-14 08:59:17 +12:00
|
|
|
|
SetEnumChecked(Program.DefaultTaskSettings.URLSharingServiceDestination, tsmiURLSharingServices, tsmiTrayURLSharingServices);
|
2013-11-03 23:53:49 +13:00
|
|
|
|
}
|
|
|
|
|
|
2016-02-12 12:28:03 +13:00
|
|
|
|
public static void SetTextFileDestinationChecked(TextDestination textDestination, FileDestination textFileDestination, params ToolStripDropDownItem[] lists)
|
2014-09-14 19:25:25 +12:00
|
|
|
|
{
|
2014-09-14 20:57:24 +12:00
|
|
|
|
if (textDestination == TextDestination.FileUploader)
|
2014-09-14 19:25:25 +12:00
|
|
|
|
{
|
2014-09-14 20:57:24 +12:00
|
|
|
|
SetEnumChecked(textFileDestination, lists);
|
2014-09-14 19:25:25 +12:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2014-09-14 20:57:24 +12:00
|
|
|
|
Uncheck(lists);
|
2014-09-14 19:25:25 +12:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2016-02-12 12:28:03 +13:00
|
|
|
|
public static void SetImageFileDestinationChecked(ImageDestination imageDestination, FileDestination imageFileDestination, params ToolStripDropDownItem[] lists)
|
2014-09-14 19:25:25 +12:00
|
|
|
|
{
|
2014-09-14 20:57:24 +12:00
|
|
|
|
if (imageDestination == ImageDestination.FileUploader)
|
2014-09-14 19:25:25 +12:00
|
|
|
|
{
|
2014-09-14 20:57:24 +12:00
|
|
|
|
SetEnumChecked(imageFileDestination, lists);
|
2014-09-14 19:25:25 +12:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2014-09-14 20:57:24 +12:00
|
|
|
|
Uncheck(lists);
|
2014-09-14 19:25:25 +12:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2013-11-03 23:53:49 +13:00
|
|
|
|
private void UpdateUploaderMenuNames()
|
|
|
|
|
{
|
2014-05-11 23:47:37 +12:00
|
|
|
|
string imageUploader = Program.DefaultTaskSettings.ImageDestination == ImageDestination.FileUploader ?
|
2014-10-25 13:04:41 +13:00
|
|
|
|
Program.DefaultTaskSettings.ImageFileDestination.GetLocalizedDescription() : Program.DefaultTaskSettings.ImageDestination.GetLocalizedDescription();
|
2014-10-17 22:58:15 +13:00
|
|
|
|
tsmiImageUploaders.Text = tsmiTrayImageUploaders.Text = string.Format(Resources.TaskSettingsForm_UpdateUploaderMenuNames_Image_uploader___0_, imageUploader);
|
2013-11-03 23:53:49 +13:00
|
|
|
|
|
2014-05-11 23:47:37 +12:00
|
|
|
|
string textUploader = Program.DefaultTaskSettings.TextDestination == TextDestination.FileUploader ?
|
2014-10-25 13:04:41 +13:00
|
|
|
|
Program.DefaultTaskSettings.TextFileDestination.GetLocalizedDescription() : Program.DefaultTaskSettings.TextDestination.GetLocalizedDescription();
|
2014-10-17 22:58:15 +13:00
|
|
|
|
tsmiTextUploaders.Text = tsmiTrayTextUploaders.Text = string.Format(Resources.TaskSettingsForm_UpdateUploaderMenuNames_Text_uploader___0_, textUploader);
|
2013-11-03 23:53:49 +13:00
|
|
|
|
|
2014-10-17 22:58:15 +13:00
|
|
|
|
tsmiFileUploaders.Text = tsmiTrayFileUploaders.Text = string.Format(Resources.TaskSettingsForm_UpdateUploaderMenuNames_File_uploader___0_,
|
2014-10-25 13:04:41 +13:00
|
|
|
|
Program.DefaultTaskSettings.FileDestination.GetLocalizedDescription());
|
2013-11-03 23:53:49 +13:00
|
|
|
|
|
2014-10-17 22:58:15 +13:00
|
|
|
|
tsmiURLShorteners.Text = tsmiTrayURLShorteners.Text = string.Format(Resources.TaskSettingsForm_UpdateUploaderMenuNames_URL_shortener___0_,
|
2014-10-25 13:04:41 +13:00
|
|
|
|
Program.DefaultTaskSettings.URLShortenerDestination.GetLocalizedDescription());
|
2013-11-03 23:53:49 +13:00
|
|
|
|
|
2014-10-17 22:58:15 +13:00
|
|
|
|
tsmiURLSharingServices.Text = tsmiTrayURLSharingServices.Text = string.Format(Resources.TaskSettingsForm_UpdateUploaderMenuNames_URL_sharing_service___0_,
|
2014-10-25 13:04:41 +13:00
|
|
|
|
Program.DefaultTaskSettings.URLSharingServiceDestination.GetLocalizedDescription());
|
2013-11-03 23:53:49 +13:00
|
|
|
|
}
|
|
|
|
|
|
2015-01-22 07:42:36 +13:00
|
|
|
|
private void ConfigureAutoUpdate()
|
2013-12-04 21:54:32 +13:00
|
|
|
|
{
|
2015-09-10 08:58:31 +12:00
|
|
|
|
#if RELEASE
|
2015-01-22 07:42:36 +13:00
|
|
|
|
lock (updateTimerLock)
|
2013-12-04 21:54:32 +13:00
|
|
|
|
{
|
2016-01-08 06:48:59 +13:00
|
|
|
|
if (!Program.IsPortableApps && Program.Settings.AutoCheckUpdate)
|
2015-01-22 07:42:36 +13:00
|
|
|
|
{
|
|
|
|
|
if (updateTimer == null)
|
|
|
|
|
{
|
2016-01-17 04:41:04 +13:00
|
|
|
|
updateTimer = new System.Threading.Timer(state => CheckUpdate(), null, TimeSpan.Zero, TimeSpan.FromHours(1));
|
2015-01-22 07:42:36 +13:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else if (updateTimer != null)
|
|
|
|
|
{
|
|
|
|
|
updateTimer.Dispose();
|
|
|
|
|
updateTimer = null;
|
|
|
|
|
}
|
2013-12-04 21:54:32 +13:00
|
|
|
|
}
|
2015-01-22 07:42:36 +13:00
|
|
|
|
#endif
|
2013-12-04 21:54:32 +13:00
|
|
|
|
}
|
|
|
|
|
|
2013-11-03 23:53:49 +13:00
|
|
|
|
private void CheckUpdate()
|
|
|
|
|
{
|
2015-04-18 00:27:18 +12:00
|
|
|
|
if (!UpdateMessageBox.DontShow && !UpdateMessageBox.IsOpen)
|
2015-01-04 03:06:32 +13:00
|
|
|
|
{
|
|
|
|
|
UpdateChecker updateChecker = TaskHelpers.CheckUpdate();
|
2016-01-17 04:41:04 +13:00
|
|
|
|
|
|
|
|
|
if (UpdateMessageBox.Start(updateChecker, firstUpdateCheck) == DialogResult.No)
|
|
|
|
|
{
|
|
|
|
|
TimeSpan interval = TimeSpan.FromHours(24);
|
|
|
|
|
updateTimer.Change(interval, interval);
|
|
|
|
|
}
|
|
|
|
|
|
2015-01-09 21:19:44 +13:00
|
|
|
|
firstUpdateCheck = false;
|
2015-01-04 03:06:32 +13:00
|
|
|
|
}
|
2013-11-03 23:53:49 +13:00
|
|
|
|
}
|
|
|
|
|
|
2014-11-07 00:27:23 +13:00
|
|
|
|
public void UseCommandLineArgs(List<CLICommand> commands)
|
2013-11-03 23:53:49 +13:00
|
|
|
|
{
|
2015-09-20 20:01:36 +12:00
|
|
|
|
TaskSettings taskSettings = FindCLITask(commands);
|
|
|
|
|
|
2014-11-07 00:27:23 +13:00
|
|
|
|
foreach (CLICommand command in commands)
|
2013-11-03 23:53:49 +13:00
|
|
|
|
{
|
2014-11-07 00:27:23 +13:00
|
|
|
|
DebugHelper.WriteLine("CommandLine: " + command.Command);
|
|
|
|
|
|
2014-12-21 04:37:54 +13:00
|
|
|
|
if (command.IsCommand && (CheckCLIHotkey(command) || CheckCLIWorkflow(command)))
|
2013-11-03 23:53:49 +13:00
|
|
|
|
{
|
2014-12-21 04:37:54 +13:00
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
|
2015-08-01 07:35:21 +12:00
|
|
|
|
if (URLHelpers.IsValidURLRegex(command.Command))
|
|
|
|
|
{
|
2015-09-20 20:01:36 +12:00
|
|
|
|
UploadManager.DownloadAndUploadFile(command.Command, taskSettings);
|
2015-08-01 07:35:21 +12:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2015-09-20 20:01:36 +12:00
|
|
|
|
UploadManager.UploadFile(command.Command, taskSettings);
|
2015-08-01 07:35:21 +12:00
|
|
|
|
}
|
2014-12-21 04:37:54 +13:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private bool CheckCLIHotkey(CLICommand command)
|
|
|
|
|
{
|
|
|
|
|
foreach (HotkeyType job in Helpers.GetEnums<HotkeyType>())
|
|
|
|
|
{
|
2015-09-20 20:01:36 +12:00
|
|
|
|
if (command.CheckCommand(job.ToString()))
|
2014-12-21 04:37:54 +13:00
|
|
|
|
{
|
|
|
|
|
ExecuteJob(job);
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private bool CheckCLIWorkflow(CLICommand command)
|
|
|
|
|
{
|
2015-09-20 20:01:36 +12:00
|
|
|
|
if (Program.HotkeysConfig != null && command.CheckCommand("workflow") && !string.IsNullOrEmpty(command.Parameter))
|
2014-12-21 04:37:54 +13:00
|
|
|
|
{
|
|
|
|
|
foreach (HotkeySettings hotkeySetting in Program.HotkeysConfig.Hotkeys)
|
|
|
|
|
{
|
|
|
|
|
if (hotkeySetting.TaskSettings.Job != HotkeyType.None)
|
2013-11-03 23:53:49 +13:00
|
|
|
|
{
|
2015-01-17 12:29:52 +13:00
|
|
|
|
if (command.Parameter == hotkeySetting.TaskSettings.ToString())
|
2014-07-25 05:30:16 +12:00
|
|
|
|
{
|
2014-12-21 04:37:54 +13:00
|
|
|
|
ExecuteJob(hotkeySetting.TaskSettings);
|
|
|
|
|
return true;
|
2014-07-25 05:30:16 +12:00
|
|
|
|
}
|
2013-11-03 23:53:49 +13:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2014-12-21 04:37:54 +13:00
|
|
|
|
|
|
|
|
|
return false;
|
2013-11-03 23:53:49 +13:00
|
|
|
|
}
|
|
|
|
|
|
2015-09-20 20:01:36 +12:00
|
|
|
|
private TaskSettings FindCLITask(List<CLICommand> commands)
|
|
|
|
|
{
|
|
|
|
|
if (Program.HotkeysConfig != null)
|
|
|
|
|
{
|
|
|
|
|
CLICommand command = commands.FirstOrDefault(x => x.CheckCommand("task") && !string.IsNullOrEmpty(x.Parameter));
|
|
|
|
|
|
|
|
|
|
if (command != null)
|
|
|
|
|
{
|
|
|
|
|
foreach (HotkeySettings hotkeySetting in Program.HotkeysConfig.Hotkeys)
|
|
|
|
|
{
|
|
|
|
|
if (command.Parameter == hotkeySetting.TaskSettings.ToString())
|
|
|
|
|
{
|
|
|
|
|
return hotkeySetting.TaskSettings;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
|
2015-08-31 18:03:03 +12:00
|
|
|
|
private WorkerTask[] GetCurrentTasks()
|
2013-11-03 23:53:49 +13:00
|
|
|
|
{
|
|
|
|
|
if (lvUploads.SelectedItems.Count > 0)
|
|
|
|
|
{
|
2015-08-31 18:03:03 +12:00
|
|
|
|
return lvUploads.SelectedItems.Cast<ListViewItem>().Select(x => x.Tag as WorkerTask).Where(x => x != null).ToArray();
|
2013-11-03 23:53:49 +13:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private TaskInfo GetCurrentUploadInfo()
|
|
|
|
|
{
|
2015-08-31 18:03:03 +12:00
|
|
|
|
WorkerTask[] tasks = GetCurrentTasks();
|
2013-11-03 23:53:49 +13:00
|
|
|
|
|
|
|
|
|
if (tasks != null && tasks.Length > 0)
|
|
|
|
|
{
|
2016-04-24 10:15:35 +12:00
|
|
|
|
return tasks[0].Info;
|
2013-11-03 23:53:49 +13:00
|
|
|
|
}
|
|
|
|
|
|
2016-04-24 10:15:35 +12:00
|
|
|
|
return null;
|
2013-11-03 23:53:49 +13:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void RemoveSelectedItems()
|
|
|
|
|
{
|
2015-08-31 18:03:03 +12:00
|
|
|
|
lvUploads.SelectedItems.Cast<ListViewItem>().Select(x => x.Tag as WorkerTask).Where(x => x != null && !x.IsWorking).ForEach(TaskManager.Remove);
|
2013-11-03 23:53:49 +13:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void RemoveAllItems()
|
|
|
|
|
{
|
2015-08-31 18:03:03 +12:00
|
|
|
|
lvUploads.Items.Cast<ListViewItem>().Select(x => x.Tag as WorkerTask).Where(x => x != null && !x.IsWorking).ForEach(TaskManager.Remove);
|
2013-11-03 23:53:49 +13:00
|
|
|
|
}
|
|
|
|
|
|
2016-02-12 12:28:03 +13:00
|
|
|
|
private void UpdateMainWindowLayout()
|
2013-11-03 23:53:49 +13:00
|
|
|
|
{
|
|
|
|
|
if (Program.Settings.ShowMenu)
|
|
|
|
|
{
|
2014-10-17 22:58:15 +13:00
|
|
|
|
tsmiHideMenu.Text = Resources.MainForm_UpdateMenu_Hide_menu;
|
2013-11-03 23:53:49 +13:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2014-10-17 22:58:15 +13:00
|
|
|
|
tsmiHideMenu.Text = Resources.MainForm_UpdateMenu_Show_menu;
|
2013-11-03 23:53:49 +13:00
|
|
|
|
}
|
|
|
|
|
|
2015-01-06 14:50:28 +13:00
|
|
|
|
tsMain.Visible = lblSplitter.Visible = Program.Settings.ShowMenu;
|
2016-01-30 00:54:35 +13:00
|
|
|
|
|
|
|
|
|
if (Program.Settings.ShowColumns)
|
|
|
|
|
{
|
2016-03-24 10:51:38 +13:00
|
|
|
|
tsmiHideColumns.Text = Resources.MainForm_UpdateMainWindowLayout_Hide_columns;
|
2016-01-30 00:54:35 +13:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2016-03-24 10:51:38 +13:00
|
|
|
|
tsmiHideColumns.Text = Resources.MainForm_UpdateMainWindowLayout_Show_columns;
|
2016-01-30 00:54:35 +13:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
lvUploads.HeaderStyle = Program.Settings.ShowColumns ? ColumnHeaderStyle.Nonclickable : ColumnHeaderStyle.None;
|
|
|
|
|
|
2013-11-03 23:53:49 +13:00
|
|
|
|
Refresh();
|
|
|
|
|
}
|
|
|
|
|
|
2015-07-19 06:49:34 +12:00
|
|
|
|
public void UpdateToggleHotkeyButton()
|
|
|
|
|
{
|
|
|
|
|
if (Program.Settings.DisableHotkeys)
|
|
|
|
|
{
|
2015-08-12 05:33:30 +12:00
|
|
|
|
tsmiTrayToggleHotkeys.Text = Resources.MainForm_UpdateToggleHotkeyButton_Enable_hotkeys;
|
2015-07-19 06:49:34 +12:00
|
|
|
|
tsmiTrayToggleHotkeys.Image = Resources.keyboard__plus;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2015-08-12 05:33:30 +12:00
|
|
|
|
tsmiTrayToggleHotkeys.Text = Resources.MainForm_UpdateToggleHotkeyButton_Disable_hotkeys;
|
2015-07-19 06:49:34 +12:00
|
|
|
|
tsmiTrayToggleHotkeys.Image = Resources.keyboard__minus;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2013-11-03 23:53:49 +13:00
|
|
|
|
#region Form events
|
|
|
|
|
|
|
|
|
|
protected override void SetVisibleCore(bool value)
|
|
|
|
|
{
|
2014-02-17 09:27:15 +13:00
|
|
|
|
if (value && !IsHandleCreated && (Program.IsSilentRun || Program.Settings.SilentRun) && Program.Settings.ShowTray)
|
2013-11-03 23:53:49 +13:00
|
|
|
|
{
|
|
|
|
|
CreateHandle();
|
|
|
|
|
value = false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
base.SetVisibleCore(value);
|
|
|
|
|
}
|
|
|
|
|
|
2015-12-06 12:56:01 +13:00
|
|
|
|
protected override bool ProcessCmdKey(ref Message msg, Keys keyData)
|
|
|
|
|
{
|
|
|
|
|
if (keyData == Keys.Escape)
|
|
|
|
|
{
|
|
|
|
|
Close();
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return base.ProcessCmdKey(ref msg, keyData);
|
|
|
|
|
}
|
|
|
|
|
|
2013-11-03 23:53:49 +13:00
|
|
|
|
private void MainForm_Shown(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
AfterShownJobs();
|
|
|
|
|
}
|
|
|
|
|
|
2015-02-18 21:20:52 +13:00
|
|
|
|
private void MainForm_VisibleChanged(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
if (Visible)
|
|
|
|
|
{
|
|
|
|
|
tsmiDonate.StartAnimation();
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
tsmiDonate.StopAnimation();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2013-11-03 23:53:49 +13:00
|
|
|
|
private void MainForm_Resize(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
Refresh();
|
2014-07-28 11:57:28 +12:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void MainForm_LocationChanged(object sender, EventArgs e)
|
|
|
|
|
{
|
2014-09-13 23:52:12 +12:00
|
|
|
|
if (IsReady && WindowState == FormWindowState.Normal)
|
2014-07-28 11:57:28 +12:00
|
|
|
|
{
|
|
|
|
|
Program.Settings.MainFormPosition = Location;
|
|
|
|
|
}
|
|
|
|
|
}
|
2014-06-15 11:38:38 +12:00
|
|
|
|
|
2014-07-28 11:57:28 +12:00
|
|
|
|
private void MainForm_SizeChanged(object sender, EventArgs e)
|
|
|
|
|
{
|
2014-09-13 23:52:12 +12:00
|
|
|
|
if (IsReady && WindowState == FormWindowState.Normal)
|
2014-06-15 11:38:38 +12:00
|
|
|
|
{
|
|
|
|
|
Program.Settings.MainFormSize = Size;
|
|
|
|
|
}
|
2013-11-03 23:53:49 +13:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void MainForm_FormClosing(object sender, FormClosingEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
if (e.CloseReason == CloseReason.UserClosing && Program.Settings.ShowTray && !forceClose)
|
|
|
|
|
{
|
|
|
|
|
e.Cancel = true;
|
|
|
|
|
Hide();
|
2016-02-11 10:14:23 +13:00
|
|
|
|
Program.SaveAllSettingsAsync();
|
2013-11-03 23:53:49 +13:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void MainForm_FormClosed(object sender, FormClosedEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
TaskManager.StopAllTasks();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void MainForm_DragEnter(object sender, DragEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
if (e.Data.GetDataPresent(DataFormats.FileDrop, false) ||
|
|
|
|
|
e.Data.GetDataPresent(DataFormats.Bitmap, false) ||
|
|
|
|
|
e.Data.GetDataPresent(DataFormats.Text, false))
|
|
|
|
|
{
|
|
|
|
|
e.Effect = DragDropEffects.Copy;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
e.Effect = DragDropEffects.None;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void MainForm_DragDrop(object sender, DragEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
UploadManager.DragDropUpload(e.Data);
|
|
|
|
|
}
|
|
|
|
|
|
2014-07-05 02:23:53 +12:00
|
|
|
|
private void tsbFileUpload_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
UploadManager.UploadFile();
|
|
|
|
|
}
|
|
|
|
|
|
2014-08-14 00:33:14 +12:00
|
|
|
|
private void tsmiUploadFolder_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
UploadManager.UploadFolder();
|
|
|
|
|
}
|
|
|
|
|
|
2013-11-03 23:53:49 +13:00
|
|
|
|
private void tsbClipboardUpload_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
2014-05-12 17:04:25 +12:00
|
|
|
|
UploadManager.ClipboardUploadMainWindow();
|
2013-11-03 23:53:49 +13:00
|
|
|
|
}
|
|
|
|
|
|
2014-07-05 02:23:53 +12:00
|
|
|
|
private void tsmiUploadURL_Click(object sender, EventArgs e)
|
2013-11-03 23:53:49 +13:00
|
|
|
|
{
|
2014-07-05 02:23:53 +12:00
|
|
|
|
UploadManager.UploadURL();
|
2013-11-03 23:53:49 +13:00
|
|
|
|
}
|
|
|
|
|
|
2014-04-06 14:10:34 +12:00
|
|
|
|
private void tsbDragDropUpload_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
2014-05-03 05:56:51 +12:00
|
|
|
|
TaskHelpers.OpenDropWindow();
|
2014-04-06 14:10:34 +12:00
|
|
|
|
}
|
|
|
|
|
|
2015-01-26 20:24:26 +13:00
|
|
|
|
private void tsmiColorPicker_Click(object sender, EventArgs e)
|
2014-07-20 08:08:45 +12:00
|
|
|
|
{
|
2015-01-26 20:24:26 +13:00
|
|
|
|
TaskHelpers.OpenColorPicker();
|
2014-07-20 08:08:45 +12:00
|
|
|
|
}
|
|
|
|
|
|
2015-01-26 20:24:26 +13:00
|
|
|
|
private void tsmiScreenColorPicker_Click(object sender, EventArgs e)
|
2015-01-25 19:51:24 +13:00
|
|
|
|
{
|
2015-01-26 20:24:26 +13:00
|
|
|
|
TaskHelpers.OpenScreenColorPicker();
|
2014-07-20 08:08:45 +12:00
|
|
|
|
}
|
|
|
|
|
|
2015-08-25 04:38:35 +12:00
|
|
|
|
private void tsmiImageEditor_Click(object sender, EventArgs e)
|
2014-07-20 08:08:45 +12:00
|
|
|
|
{
|
2015-08-25 04:38:35 +12:00
|
|
|
|
TaskHelpers.OpenImageEditor();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void tsmiImageEffects_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
TaskHelpers.OpenImageEffects();
|
2014-07-20 08:08:45 +12:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void tsmiHashCheck_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
TaskHelpers.OpenHashCheck();
|
|
|
|
|
}
|
|
|
|
|
|
2015-08-25 04:38:35 +12:00
|
|
|
|
private void tsmiDNSChanger_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
TaskHelpers.OpenDNSChanger();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void tsmiQRCode_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
TaskHelpers.OpenQRCode();
|
|
|
|
|
}
|
|
|
|
|
|
2015-01-26 20:24:26 +13:00
|
|
|
|
private void tsmiRuler_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
TaskHelpers.OpenRuler();
|
|
|
|
|
}
|
|
|
|
|
|
2015-02-17 02:31:19 +13:00
|
|
|
|
private void tsmiAutomate_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
2015-02-18 22:29:36 +13:00
|
|
|
|
TaskHelpers.OpenAutomate();
|
2015-02-17 02:31:19 +13:00
|
|
|
|
}
|
|
|
|
|
|
2014-07-20 08:08:45 +12:00
|
|
|
|
private void tsmiIndexFolder_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
2016-02-03 01:58:34 +13:00
|
|
|
|
TaskHelpers.OpenDirectoryIndexer();
|
2014-07-20 08:08:45 +12:00
|
|
|
|
}
|
|
|
|
|
|
2015-10-01 01:44:19 +13:00
|
|
|
|
private void tsmiImageCombiner_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
TaskHelpers.OpenImageCombiner();
|
|
|
|
|
}
|
2015-10-01 12:48:33 +13:00
|
|
|
|
|
2015-08-04 23:47:34 +12:00
|
|
|
|
private void tsmiVideoThumbnailer_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
TaskHelpers.OpenVideoThumbnailer();
|
|
|
|
|
}
|
|
|
|
|
|
2015-08-25 04:38:35 +12:00
|
|
|
|
private void tsmiFTPClient_Click(object sender, EventArgs e)
|
2014-07-20 08:08:45 +12:00
|
|
|
|
{
|
2015-08-25 04:38:35 +12:00
|
|
|
|
TaskHelpers.OpenFTPClient();
|
2014-07-20 08:08:45 +12:00
|
|
|
|
}
|
|
|
|
|
|
2015-08-25 04:38:35 +12:00
|
|
|
|
private void tsmiTweetMessage_Click(object sender, EventArgs e)
|
2014-07-20 08:08:45 +12:00
|
|
|
|
{
|
2015-08-25 04:38:35 +12:00
|
|
|
|
TaskHelpers.TweetMessage();
|
2014-07-20 08:08:45 +12:00
|
|
|
|
}
|
|
|
|
|
|
2015-08-25 04:38:35 +12:00
|
|
|
|
private void tsmiMonitorTest_Click(object sender, EventArgs e)
|
2014-07-20 08:08:45 +12:00
|
|
|
|
{
|
2015-08-25 04:38:35 +12:00
|
|
|
|
TaskHelpers.OpenMonitorTest();
|
2014-07-20 08:08:45 +12:00
|
|
|
|
}
|
|
|
|
|
|
2013-11-03 23:53:49 +13:00
|
|
|
|
private void tsddbDestinations_DropDownOpened(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
UpdateDestinationStates();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void tsmiShowDebugLog_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
new DebugForm(DebugHelper.Logger).Show();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void tsmiTestImageUpload_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
2014-08-16 01:25:43 +12:00
|
|
|
|
UploadManager.UploadImage(ShareXResources.Logo);
|
2013-11-03 23:53:49 +13:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void tsmiTestTextUpload_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
2014-10-17 22:58:15 +13:00
|
|
|
|
UploadManager.UploadText(Resources.MainForm_tsmiTestTextUpload_Click_Text_upload_test);
|
2013-11-03 23:53:49 +13:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void tsmiTestFileUpload_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
2014-09-26 15:06:40 +12:00
|
|
|
|
UploadManager.UploadImage(ShareXResources.Logo, ImageDestination.FileUploader, Program.DefaultTaskSettings.FileDestination);
|
2013-11-03 23:53:49 +13:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void tsmiTestURLShortener_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
UploadManager.ShortenURL(Links.URL_WEBSITE);
|
|
|
|
|
}
|
|
|
|
|
|
2014-07-20 08:08:45 +12:00
|
|
|
|
private void tsmiTestURLSharing_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
UploadManager.ShareURL(Links.URL_WEBSITE);
|
|
|
|
|
}
|
|
|
|
|
|
2014-08-08 14:10:49 +12:00
|
|
|
|
private void tsmiScreenRecordingFFmpeg_Click(object sender, EventArgs e)
|
2013-11-03 23:53:49 +13:00
|
|
|
|
{
|
2015-06-22 18:56:18 +12:00
|
|
|
|
TaskHelpers.StartScreenRecording(ScreenRecordOutput.FFmpeg, ScreenRecordStartMethod.Region);
|
2014-08-08 14:10:49 +12:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void tsmiScreenRecordingGIF_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
2015-06-22 18:56:18 +12:00
|
|
|
|
TaskHelpers.StartScreenRecording(ScreenRecordOutput.GIF, ScreenRecordStartMethod.Region);
|
2013-11-03 23:53:49 +13:00
|
|
|
|
}
|
|
|
|
|
|
2015-09-25 20:12:03 +12:00
|
|
|
|
private void tsmiScrollingCapture_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
TaskHelpers.OpenScrollingCapture();
|
|
|
|
|
}
|
|
|
|
|
|
2013-11-03 23:53:49 +13:00
|
|
|
|
private void tsmiAutoCapture_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
2014-05-03 05:56:51 +12:00
|
|
|
|
TaskHelpers.OpenAutoCapture();
|
2013-11-03 23:53:49 +13:00
|
|
|
|
}
|
|
|
|
|
|
2015-06-26 20:10:27 +12:00
|
|
|
|
private void tsmiWebpageCapture_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
TaskHelpers.OpenWebpageCapture();
|
|
|
|
|
}
|
|
|
|
|
|
2013-11-03 23:53:49 +13:00
|
|
|
|
private void tsbApplicationSettings_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
2014-01-09 14:16:48 +13:00
|
|
|
|
using (ApplicationSettingsForm settingsForm = new ApplicationSettingsForm())
|
2013-11-03 23:53:49 +13:00
|
|
|
|
{
|
|
|
|
|
settingsForm.ShowDialog();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
AfterSettingsJobs();
|
2014-05-18 22:12:12 +12:00
|
|
|
|
UpdateWorkflowsMenu();
|
2013-12-12 07:36:23 +13:00
|
|
|
|
Program.Settings.SaveAsync(Program.ApplicationConfigFilePath);
|
2014-04-16 02:04:34 +12:00
|
|
|
|
Program.ConfigureUploadersConfigWatcher();
|
2013-11-03 23:53:49 +13:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void tsbTaskSettings_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
using (TaskSettingsForm taskSettingsForm = new TaskSettingsForm(Program.DefaultTaskSettings, true))
|
|
|
|
|
{
|
|
|
|
|
taskSettingsForm.ShowDialog();
|
|
|
|
|
}
|
|
|
|
|
|
2013-12-12 07:36:23 +13:00
|
|
|
|
Program.Settings.SaveAsync(Program.ApplicationConfigFilePath);
|
2013-11-03 23:53:49 +13:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void tsbHotkeySettings_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
2015-11-12 19:44:29 +13:00
|
|
|
|
if (Program.HotkeyManager != null)
|
2013-11-03 23:53:49 +13:00
|
|
|
|
{
|
2015-11-12 19:44:29 +13:00
|
|
|
|
using (HotkeySettingsForm hotkeySettingsForm = new HotkeySettingsForm(Program.HotkeyManager))
|
|
|
|
|
{
|
|
|
|
|
hotkeySettingsForm.ShowDialog();
|
|
|
|
|
}
|
2013-11-03 23:53:49 +13:00
|
|
|
|
|
2015-11-12 19:44:29 +13:00
|
|
|
|
UpdateWorkflowsMenu();
|
|
|
|
|
Program.HotkeysConfig.SaveAsync(Program.HotkeysConfigFilePath);
|
2013-11-03 23:53:49 +13:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2015-07-19 06:49:34 +12:00
|
|
|
|
private void tsmiTrayToggleHotkeys_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
TaskHelpers.ToggleHotkeys();
|
|
|
|
|
}
|
|
|
|
|
|
2013-11-03 23:53:49 +13:00
|
|
|
|
private void tsbDestinationSettings_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
if (Program.UploadersConfig == null)
|
|
|
|
|
{
|
|
|
|
|
Program.UploaderSettingsResetEvent.WaitOne();
|
|
|
|
|
}
|
|
|
|
|
|
2014-02-15 05:54:10 +13:00
|
|
|
|
using (UploadersConfigForm uploadersConfigForm = new UploadersConfigForm(Program.UploadersConfig))
|
2013-11-03 23:53:49 +13:00
|
|
|
|
{
|
|
|
|
|
uploadersConfigForm.ShowDialog();
|
|
|
|
|
}
|
|
|
|
|
|
2014-04-16 02:04:34 +12:00
|
|
|
|
Program.UploadersConfigSaveAsync();
|
2013-11-03 23:53:49 +13:00
|
|
|
|
}
|
2014-06-17 22:30:49 +12:00
|
|
|
|
|
2013-11-03 23:53:49 +13:00
|
|
|
|
private void tsbScreenshotsFolder_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
2014-09-02 10:21:16 +12:00
|
|
|
|
TaskHelpers.OpenScreenshotsFolder();
|
2013-11-03 23:53:49 +13:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void tsbHistory_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
2016-02-22 08:50:49 +13:00
|
|
|
|
TaskHelpers.OpenHistory();
|
2013-11-03 23:53:49 +13:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void tsbImageHistory_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
2016-03-03 23:05:59 +13:00
|
|
|
|
TaskHelpers.OpenImageHistory();
|
2013-11-03 23:53:49 +13:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void tsbAbout_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
using (AboutForm aboutForm = new AboutForm())
|
|
|
|
|
{
|
|
|
|
|
aboutForm.ShowDialog();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void tsbDonate_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
2014-06-28 12:22:56 +12:00
|
|
|
|
URLHelpers.OpenURL(Links.URL_DONATE);
|
2013-11-03 23:53:49 +13:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void lblDragAndDropTip_MouseUp(object sender, MouseEventArgs e)
|
|
|
|
|
{
|
2015-07-08 20:42:12 +12:00
|
|
|
|
if (e.Button == MouseButtons.Left)
|
|
|
|
|
{
|
|
|
|
|
lvUploads.Focus();
|
|
|
|
|
}
|
|
|
|
|
else if (e.Button == MouseButtons.Right)
|
2013-11-03 23:53:49 +13:00
|
|
|
|
{
|
2016-02-12 12:28:03 +13:00
|
|
|
|
UpdateContextMenu();
|
2014-09-02 00:57:37 +12:00
|
|
|
|
cmsTaskInfo.Show((Control)sender, e.X + 1, e.Y + 1);
|
2013-11-03 23:53:49 +13:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void lvUploads_SelectedIndexChanged(object sender, EventArgs e)
|
|
|
|
|
{
|
2016-02-12 12:28:03 +13:00
|
|
|
|
UpdateContextMenu();
|
2013-11-03 23:53:49 +13:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void lvUploads_MouseUp(object sender, MouseEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
if (e.Button == MouseButtons.Right)
|
|
|
|
|
{
|
2016-02-12 12:28:03 +13:00
|
|
|
|
UpdateContextMenu();
|
2014-07-17 18:58:17 +12:00
|
|
|
|
cmsTaskInfo.Show(lvUploads, e.X + 1, e.Y + 1);
|
2013-11-03 23:53:49 +13:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void lvUploads_MouseDoubleClick(object sender, MouseEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
if (e.Button == MouseButtons.Left)
|
|
|
|
|
{
|
|
|
|
|
uim.TryOpen();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void scMain_SplitterMoved(object sender, SplitterEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
Program.Settings.PreviewSplitterDistance = scMain.SplitterDistance;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void lvUploads_KeyDown(object sender, KeyEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
switch (e.KeyData)
|
|
|
|
|
{
|
|
|
|
|
default:
|
|
|
|
|
return;
|
|
|
|
|
case Keys.Enter:
|
|
|
|
|
uim.TryOpen();
|
|
|
|
|
break;
|
|
|
|
|
case Keys.Control | Keys.Enter:
|
|
|
|
|
uim.OpenFile();
|
|
|
|
|
break;
|
|
|
|
|
case Keys.Control | Keys.C:
|
2015-04-25 03:43:18 +12:00
|
|
|
|
uim.TryCopy();
|
|
|
|
|
break;
|
|
|
|
|
case Keys.Control | Keys.Shift | Keys.C:
|
|
|
|
|
uim.CopyFilePath();
|
2013-11-03 23:53:49 +13:00
|
|
|
|
break;
|
2016-04-25 06:54:51 +12:00
|
|
|
|
case Keys.Control | Keys.X:
|
|
|
|
|
uim.TryCopy();
|
|
|
|
|
RemoveSelectedItems();
|
|
|
|
|
break;
|
2013-11-03 23:53:49 +13:00
|
|
|
|
case Keys.Control | Keys.V:
|
2014-05-12 17:04:25 +12:00
|
|
|
|
UploadManager.ClipboardUploadMainWindow();
|
2013-11-03 23:53:49 +13:00
|
|
|
|
break;
|
|
|
|
|
case Keys.Delete:
|
|
|
|
|
RemoveSelectedItems();
|
2015-08-02 16:28:54 +12:00
|
|
|
|
break;
|
|
|
|
|
case Keys.Shift | Keys.Delete:
|
|
|
|
|
uim.DeleteFiles();
|
|
|
|
|
RemoveSelectedItems();
|
2013-11-03 23:53:49 +13:00
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
e.Handled = true;
|
|
|
|
|
}
|
|
|
|
|
|
2016-04-24 10:15:35 +12:00
|
|
|
|
private void lvUploads_ItemDrag(object sender, ItemDragEventArgs e)
|
|
|
|
|
{
|
2016-04-25 02:43:57 +12:00
|
|
|
|
TaskInfo[] taskInfos = GetCurrentTasks().Select(x => x.Info).Where(x => x != null).ToArray();
|
2016-04-24 10:15:35 +12:00
|
|
|
|
|
2016-04-25 02:15:02 +12:00
|
|
|
|
if (taskInfos.Length > 0)
|
2016-04-24 10:15:35 +12:00
|
|
|
|
{
|
2016-04-25 02:43:57 +12:00
|
|
|
|
IDataObject dataObject = null;
|
2016-04-24 11:16:08 +12:00
|
|
|
|
|
2016-04-25 02:43:57 +12:00
|
|
|
|
if (ModifierKeys.HasFlag(Keys.Control))
|
|
|
|
|
{
|
|
|
|
|
string[] urls = taskInfos.Select(x => x.ToString()).Where(x => !string.IsNullOrEmpty(x)).ToArray();
|
|
|
|
|
|
|
|
|
|
if (urls.Length > 0)
|
|
|
|
|
{
|
|
|
|
|
dataObject = new DataObject(DataFormats.Text, string.Join(Environment.NewLine, urls));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
string[] files = taskInfos.Select(x => x.FilePath).Where(x => !string.IsNullOrEmpty(x) && File.Exists(x)).ToArray();
|
|
|
|
|
|
|
|
|
|
if (files.Length > 0)
|
|
|
|
|
{
|
|
|
|
|
dataObject = new DataObject(DataFormats.FileDrop, files);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (dataObject != null)
|
|
|
|
|
{
|
|
|
|
|
AllowDrop = false;
|
|
|
|
|
|
|
|
|
|
lvUploads.DoDragDrop(dataObject, DragDropEffects.Copy);
|
|
|
|
|
}
|
2016-04-24 10:15:35 +12:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void lvUploads_QueryContinueDrag(object sender, QueryContinueDragEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
if (e.Action != DragAction.Continue)
|
|
|
|
|
{
|
|
|
|
|
AllowDrop = true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2016-04-25 06:54:51 +12:00
|
|
|
|
private void pbTips_MouseEnter(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
pTips.Visible = true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void pbTips_MouseLeave(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
pTips.Visible = false;
|
|
|
|
|
}
|
|
|
|
|
|
2013-11-03 23:53:49 +13:00
|
|
|
|
#region Tray events
|
|
|
|
|
|
2015-08-10 09:06:46 +12:00
|
|
|
|
private void timerTraySingleClick_Tick(object sender, EventArgs e)
|
2013-11-03 23:53:49 +13:00
|
|
|
|
{
|
2015-08-10 09:06:46 +12:00
|
|
|
|
timerTraySingleClick.Stop();
|
|
|
|
|
ExecuteJob(Program.Settings.TrayLeftClickAction);
|
2013-11-03 23:53:49 +13:00
|
|
|
|
}
|
|
|
|
|
|
2015-08-10 09:06:46 +12:00
|
|
|
|
private void niTray_MouseClick(object sender, MouseEventArgs e)
|
2013-11-03 23:53:49 +13:00
|
|
|
|
{
|
2014-07-25 07:28:59 +12:00
|
|
|
|
switch (e.Button)
|
2013-11-03 23:53:49 +13:00
|
|
|
|
{
|
2015-08-10 09:06:46 +12:00
|
|
|
|
case MouseButtons.Left:
|
2016-04-07 04:46:55 +12:00
|
|
|
|
if (Program.Settings.TrayLeftDoubleClickAction == HotkeyType.None)
|
|
|
|
|
{
|
|
|
|
|
ExecuteJob(Program.Settings.TrayLeftClickAction);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
timerTraySingleClick.Interval = (int)(SystemInformation.DoubleClickTime * 1.1);
|
|
|
|
|
timerTraySingleClick.Start();
|
|
|
|
|
}
|
2015-08-10 09:06:46 +12:00
|
|
|
|
break;
|
2014-07-25 07:28:59 +12:00
|
|
|
|
case MouseButtons.Middle:
|
|
|
|
|
ExecuteJob(Program.Settings.TrayMiddleClickAction);
|
|
|
|
|
break;
|
2013-11-03 23:53:49 +13:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2015-08-10 09:06:46 +12:00
|
|
|
|
private void niTray_MouseDoubleClick(object sender, MouseEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
if (e.Button == MouseButtons.Left)
|
|
|
|
|
{
|
|
|
|
|
timerTraySingleClick.Stop();
|
2016-04-07 04:41:25 +12:00
|
|
|
|
ExecuteJob(Program.Settings.TrayLeftDoubleClickAction);
|
2015-08-10 09:06:46 +12:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2013-11-03 23:53:49 +13:00
|
|
|
|
private void niTray_BalloonTipClicked(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
string url = niTray.Tag as string;
|
|
|
|
|
|
|
|
|
|
if (!string.IsNullOrEmpty(url))
|
|
|
|
|
{
|
2014-06-28 12:22:56 +12:00
|
|
|
|
URLHelpers.OpenURL(url);
|
2013-11-03 23:53:49 +13:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2014-02-18 11:53:53 +13:00
|
|
|
|
private void tsmiTrayShow_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
2016-03-10 05:37:54 +13:00
|
|
|
|
this.ForceActivate();
|
2014-02-18 11:53:53 +13:00
|
|
|
|
}
|
|
|
|
|
|
2016-03-06 03:40:40 +13:00
|
|
|
|
private void tsmiTrayExit_MouseDown(object sender, MouseEventArgs e)
|
2013-11-03 23:53:49 +13:00
|
|
|
|
{
|
2016-03-17 22:25:43 +13:00
|
|
|
|
trayMenuSaveSettings = false;
|
2013-11-03 23:53:49 +13:00
|
|
|
|
}
|
|
|
|
|
|
2016-03-06 03:40:40 +13:00
|
|
|
|
private void cmsTray_Closed(object sender, ToolStripDropDownClosedEventArgs e)
|
|
|
|
|
{
|
2016-03-17 22:25:43 +13:00
|
|
|
|
if (trayMenuSaveSettings)
|
2016-03-06 03:40:40 +13:00
|
|
|
|
{
|
|
|
|
|
Program.SaveAllSettingsAsync();
|
|
|
|
|
}
|
2016-03-17 22:25:43 +13:00
|
|
|
|
|
|
|
|
|
trayMenuSaveSettings = true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void tsmiTrayExit_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
forceClose = true;
|
|
|
|
|
Close();
|
2016-03-06 03:40:40 +13:00
|
|
|
|
}
|
|
|
|
|
|
2013-11-03 23:53:49 +13:00
|
|
|
|
#endregion Tray events
|
|
|
|
|
|
|
|
|
|
#region UploadInfoMenu events
|
|
|
|
|
|
2014-07-17 18:58:17 +12:00
|
|
|
|
private void tsmiShowErrors_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
uim.ShowErrors();
|
|
|
|
|
}
|
|
|
|
|
|
2013-11-03 23:53:49 +13:00
|
|
|
|
private void tsmiStopUpload_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
if (lvUploads.SelectedItems.Count > 0)
|
|
|
|
|
{
|
2015-08-31 18:03:03 +12:00
|
|
|
|
foreach (WorkerTask task in GetCurrentTasks())
|
2013-11-03 23:53:49 +13:00
|
|
|
|
{
|
|
|
|
|
task.Stop();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void tsmiOpenURL_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
uim.OpenURL();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void tsmiOpenShortenedURL_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
uim.OpenShortenedURL();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void tsmiOpenThumbnailURL_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
uim.OpenThumbnailURL();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void tsmiOpenDeletionURL_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
uim.OpenDeletionURL();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void tsmiOpenFile_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
uim.OpenFile();
|
|
|
|
|
}
|
|
|
|
|
|
2014-04-23 09:00:41 +12:00
|
|
|
|
private void tsmiOpenThumbnailFile_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
uim.OpenThumbnailFile();
|
|
|
|
|
}
|
|
|
|
|
|
2013-11-03 23:53:49 +13:00
|
|
|
|
private void tsmiOpenFolder_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
uim.OpenFolder();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void tsmiCopyURL_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
uim.CopyURL();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void tsmiCopyShortenedURL_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
uim.CopyShortenedURL();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void tsmiCopyThumbnailURL_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
uim.CopyThumbnailURL();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void tsmiCopyDeletionURL_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
uim.CopyDeletionURL();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void tsmiCopyFile_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
uim.CopyFile();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void tsmiCopyImage_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
uim.CopyImage();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void tsmiCopyText_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
uim.CopyText();
|
|
|
|
|
}
|
|
|
|
|
|
2014-04-23 09:00:41 +12:00
|
|
|
|
private void tsmiCopyThumbnailFile_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
uim.CopyThumbnailFile();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void tsmiCopyThumbnailImage_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
uim.CopyThumbnailImage();
|
|
|
|
|
}
|
|
|
|
|
|
2013-11-03 23:53:49 +13:00
|
|
|
|
private void tsmiCopyHTMLLink_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
uim.CopyHTMLLink();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void tsmiCopyHTMLImage_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
uim.CopyHTMLImage();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void tsmiCopyHTMLLinkedImage_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
uim.CopyHTMLLinkedImage();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void tsmiCopyForumLink_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
uim.CopyForumLink();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void tsmiCopyForumImage_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
uim.CopyForumImage();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void tsmiCopyForumLinkedImage_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
uim.CopyForumLinkedImage();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void tsmiCopyFilePath_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
uim.CopyFilePath();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void tsmiCopyFileName_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
uim.CopyFileName();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void tsmiCopyFileNameWithExtension_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
uim.CopyFileNameWithExtension();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void tsmiCopyFolder_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
uim.CopyFolder();
|
|
|
|
|
}
|
|
|
|
|
|
2015-01-22 07:42:36 +13:00
|
|
|
|
private void tsmiClipboardFormat_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
ToolStripMenuItem tsmiClipboardFormat = sender as ToolStripMenuItem;
|
|
|
|
|
ClipboardFormat cf = tsmiClipboardFormat.Tag as ClipboardFormat;
|
|
|
|
|
uim.CopyCustomFormat(cf.Format);
|
|
|
|
|
}
|
|
|
|
|
|
2014-07-17 18:58:17 +12:00
|
|
|
|
private void tsmiUploadSelectedFile_Click(object sender, EventArgs e)
|
2013-11-03 23:53:49 +13:00
|
|
|
|
{
|
2014-07-17 18:58:17 +12:00
|
|
|
|
uim.Upload();
|
2013-11-03 23:53:49 +13:00
|
|
|
|
}
|
|
|
|
|
|
2014-07-27 23:02:08 +12:00
|
|
|
|
private void tsmiDeleteSelectedFile_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
2014-10-17 22:58:15 +13:00
|
|
|
|
if (MessageBox.Show(Resources.MainForm_tsmiDeleteSelectedFile_Click_Do_you_really_want_to_delete_this_file_,
|
|
|
|
|
"ShareX - " + Resources.MainForm_tsmiDeleteSelectedFile_Click_File_delete_confirmation, MessageBoxButtons.YesNo) == DialogResult.Yes)
|
2014-07-28 09:34:17 +12:00
|
|
|
|
{
|
2015-05-14 10:16:17 +12:00
|
|
|
|
uim.DeleteFiles();
|
2014-07-28 09:34:17 +12:00
|
|
|
|
RemoveSelectedItems();
|
|
|
|
|
}
|
2014-07-27 23:02:08 +12:00
|
|
|
|
}
|
|
|
|
|
|
2014-07-17 18:58:17 +12:00
|
|
|
|
private void tsmiEditSelectedFile_Click(object sender, EventArgs e)
|
2013-11-03 23:53:49 +13:00
|
|
|
|
{
|
2014-07-17 18:58:17 +12:00
|
|
|
|
uim.EditImage();
|
2013-11-03 23:53:49 +13:00
|
|
|
|
}
|
|
|
|
|
|
2014-05-21 09:25:06 +12:00
|
|
|
|
private void tsmiShowQRCode_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
uim.ShowQRCode();
|
|
|
|
|
}
|
|
|
|
|
|
2014-07-17 18:58:17 +12:00
|
|
|
|
private void tsmiShowResponse_Click(object sender, EventArgs e)
|
2014-07-17 08:43:20 +12:00
|
|
|
|
{
|
2014-07-17 18:58:17 +12:00
|
|
|
|
uim.ShowResponse();
|
2014-07-17 08:43:20 +12:00
|
|
|
|
}
|
|
|
|
|
|
2013-11-03 23:53:49 +13:00
|
|
|
|
private void tsmiClearList_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
RemoveAllItems();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void tsmiHideMenu_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
Program.Settings.ShowMenu = !Program.Settings.ShowMenu;
|
2016-02-12 12:28:03 +13:00
|
|
|
|
UpdateMainWindowLayout();
|
2013-11-03 23:53:49 +13:00
|
|
|
|
}
|
|
|
|
|
|
2016-01-30 00:54:35 +13:00
|
|
|
|
private void tsmiHideColumns_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
Program.Settings.ShowColumns = !Program.Settings.ShowColumns;
|
2016-02-12 12:28:03 +13:00
|
|
|
|
UpdateMainWindowLayout();
|
2016-01-30 00:54:35 +13:00
|
|
|
|
}
|
|
|
|
|
|
2014-06-19 07:17:22 +12:00
|
|
|
|
private void tsmiImagePreviewShow_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
Program.Settings.ImagePreview = ImagePreviewVisibility.Show;
|
|
|
|
|
tsmiImagePreviewShow.Check();
|
2016-02-12 12:28:03 +13:00
|
|
|
|
UpdateContextMenu();
|
2014-06-19 07:17:22 +12:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void tsmiImagePreviewHide_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
Program.Settings.ImagePreview = ImagePreviewVisibility.Hide;
|
|
|
|
|
tsmiImagePreviewHide.Check();
|
2016-02-12 12:28:03 +13:00
|
|
|
|
UpdateContextMenu();
|
2014-06-19 07:17:22 +12:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void tsmiImagePreviewAutomatic_Click(object sender, EventArgs e)
|
2013-11-03 23:53:49 +13:00
|
|
|
|
{
|
2014-06-19 07:17:22 +12:00
|
|
|
|
Program.Settings.ImagePreview = ImagePreviewVisibility.Automatic;
|
|
|
|
|
tsmiImagePreviewAutomatic.Check();
|
2016-02-12 12:28:03 +13:00
|
|
|
|
UpdateContextMenu();
|
2013-11-03 23:53:49 +13:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#endregion UploadInfoMenu events
|
|
|
|
|
|
|
|
|
|
#endregion Form events
|
2014-07-05 01:32:47 +12:00
|
|
|
|
|
|
|
|
|
#region Hotkey/Capture codes and form events
|
|
|
|
|
|
|
|
|
|
private delegate Image ScreenCaptureDelegate();
|
|
|
|
|
|
2015-04-02 00:12:21 +13:00
|
|
|
|
private enum LastRegionCaptureType { Surface, Light, Transparent, Annotate }
|
2014-07-10 11:59:03 +12:00
|
|
|
|
|
|
|
|
|
private LastRegionCaptureType lastRegionCaptureType = LastRegionCaptureType.Surface;
|
2014-07-05 01:32:47 +12:00
|
|
|
|
|
|
|
|
|
private void InitHotkeys()
|
|
|
|
|
{
|
|
|
|
|
TaskEx.Run(() =>
|
|
|
|
|
{
|
|
|
|
|
if (Program.HotkeysConfig == null)
|
|
|
|
|
{
|
|
|
|
|
Program.HotkeySettingsResetEvent.WaitOne();
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
() =>
|
|
|
|
|
{
|
2016-02-12 14:31:11 +13:00
|
|
|
|
if (Program.HotkeyManager == null)
|
|
|
|
|
{
|
|
|
|
|
Program.HotkeyManager = new HotkeyManager(this);
|
|
|
|
|
Program.HotkeyManager.HotkeyTrigger += HandleHotkeys;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Program.HotkeyManager.UpdateHotkeys(Program.HotkeysConfig.Hotkeys, !Program.NoHotkeys);
|
|
|
|
|
|
2014-07-05 01:32:47 +12:00
|
|
|
|
DebugHelper.WriteLine("HotkeyManager started");
|
|
|
|
|
|
2016-02-12 14:31:11 +13:00
|
|
|
|
if (Program.WatchFolderManager == null)
|
|
|
|
|
{
|
|
|
|
|
Program.WatchFolderManager = new WatchFolderManager();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Program.WatchFolderManager.UpdateWatchFolders();
|
|
|
|
|
|
2014-07-05 01:32:47 +12:00
|
|
|
|
DebugHelper.WriteLine("WatchFolderManager started");
|
|
|
|
|
|
|
|
|
|
UpdateWorkflowsMenu();
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void HandleHotkeys(HotkeySettings hotkeySetting)
|
|
|
|
|
{
|
|
|
|
|
DebugHelper.WriteLine("Hotkey triggered: " + hotkeySetting);
|
|
|
|
|
|
2014-07-25 07:28:59 +12:00
|
|
|
|
if (hotkeySetting.TaskSettings.Job != HotkeyType.None)
|
|
|
|
|
{
|
2015-11-01 07:26:12 +13:00
|
|
|
|
ExecuteJob(hotkeySetting.TaskSettings);
|
2014-07-25 07:28:59 +12:00
|
|
|
|
}
|
2014-07-05 01:32:47 +12:00
|
|
|
|
}
|
|
|
|
|
|
2014-07-25 05:30:16 +12:00
|
|
|
|
private void ExecuteJob(HotkeyType job)
|
|
|
|
|
{
|
2014-07-25 07:28:59 +12:00
|
|
|
|
ExecuteJob(Program.DefaultTaskSettings, job);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void ExecuteJob(TaskSettings taskSettings)
|
|
|
|
|
{
|
|
|
|
|
ExecuteJob(taskSettings, taskSettings.Job);
|
2014-07-25 05:30:16 +12:00
|
|
|
|
}
|
|
|
|
|
|
2014-07-25 07:28:59 +12:00
|
|
|
|
private void ExecuteJob(TaskSettings taskSettings, HotkeyType job)
|
2014-07-05 01:32:47 +12:00
|
|
|
|
{
|
2016-02-25 23:16:44 +13:00
|
|
|
|
DebugHelper.WriteLine("Executing: " + job.GetLocalizedDescription());
|
|
|
|
|
|
2014-07-05 01:32:47 +12:00
|
|
|
|
TaskSettings safeTaskSettings = TaskSettings.GetSafeTaskSettings(taskSettings);
|
|
|
|
|
|
2014-07-25 07:28:59 +12:00
|
|
|
|
switch (job)
|
2014-07-05 01:32:47 +12:00
|
|
|
|
{
|
2015-06-22 19:26:30 +12:00
|
|
|
|
// Upload
|
2014-07-05 02:23:53 +12:00
|
|
|
|
case HotkeyType.FileUpload:
|
|
|
|
|
UploadManager.UploadFile(safeTaskSettings);
|
2014-07-05 01:32:47 +12:00
|
|
|
|
break;
|
2014-08-14 00:33:14 +12:00
|
|
|
|
case HotkeyType.FolderUpload:
|
|
|
|
|
UploadManager.UploadFolder(safeTaskSettings);
|
|
|
|
|
break;
|
2014-07-05 01:32:47 +12:00
|
|
|
|
case HotkeyType.ClipboardUpload:
|
|
|
|
|
UploadManager.ClipboardUpload(safeTaskSettings);
|
|
|
|
|
break;
|
|
|
|
|
case HotkeyType.ClipboardUploadWithContentViewer:
|
|
|
|
|
UploadManager.ClipboardUploadWithContentViewer(safeTaskSettings);
|
|
|
|
|
break;
|
2014-07-05 02:23:53 +12:00
|
|
|
|
case HotkeyType.UploadURL:
|
|
|
|
|
UploadManager.UploadURL(safeTaskSettings);
|
2014-07-05 01:32:47 +12:00
|
|
|
|
break;
|
|
|
|
|
case HotkeyType.DragDropUpload:
|
2015-07-16 00:02:27 +12:00
|
|
|
|
TaskHelpers.OpenDropWindow(safeTaskSettings);
|
2014-07-05 01:32:47 +12:00
|
|
|
|
break;
|
2014-07-05 02:23:53 +12:00
|
|
|
|
case HotkeyType.StopUploads:
|
|
|
|
|
TaskManager.StopAllTasks();
|
|
|
|
|
break;
|
2015-06-22 19:26:30 +12:00
|
|
|
|
// Screen capture
|
2014-07-05 01:32:47 +12:00
|
|
|
|
case HotkeyType.PrintScreen:
|
|
|
|
|
CaptureScreenshot(CaptureType.Screen, safeTaskSettings, false);
|
|
|
|
|
break;
|
|
|
|
|
case HotkeyType.ActiveWindow:
|
|
|
|
|
CaptureScreenshot(CaptureType.ActiveWindow, safeTaskSettings, false);
|
|
|
|
|
break;
|
|
|
|
|
case HotkeyType.ActiveMonitor:
|
|
|
|
|
CaptureScreenshot(CaptureType.ActiveMonitor, safeTaskSettings, false);
|
|
|
|
|
break;
|
|
|
|
|
case HotkeyType.RectangleRegion:
|
|
|
|
|
CaptureScreenshot(CaptureType.Rectangle, safeTaskSettings, false);
|
|
|
|
|
break;
|
2014-07-10 08:57:26 +12:00
|
|
|
|
case HotkeyType.RectangleAnnotate:
|
|
|
|
|
CaptureRectangleAnnotate(safeTaskSettings, false);
|
|
|
|
|
break;
|
2014-07-05 01:32:47 +12:00
|
|
|
|
case HotkeyType.RectangleLight:
|
2014-07-10 07:30:18 +12:00
|
|
|
|
CaptureRectangleLight(safeTaskSettings, false);
|
2014-07-05 01:32:47 +12:00
|
|
|
|
break;
|
2015-04-02 00:12:21 +13:00
|
|
|
|
case HotkeyType.RectangleTransparent:
|
|
|
|
|
CaptureRectangleTransparent(safeTaskSettings, false);
|
|
|
|
|
break;
|
2014-07-05 01:32:47 +12:00
|
|
|
|
case HotkeyType.PolygonRegion:
|
|
|
|
|
CaptureScreenshot(CaptureType.Polygon, safeTaskSettings, false);
|
|
|
|
|
break;
|
|
|
|
|
case HotkeyType.FreeHandRegion:
|
|
|
|
|
CaptureScreenshot(CaptureType.Freehand, safeTaskSettings, false);
|
|
|
|
|
break;
|
2015-04-27 07:52:01 +12:00
|
|
|
|
case HotkeyType.CustomRegion:
|
|
|
|
|
CaptureScreenshot(CaptureType.CustomRegion, safeTaskSettings, false);
|
|
|
|
|
break;
|
2014-07-05 01:32:47 +12:00
|
|
|
|
case HotkeyType.LastRegion:
|
|
|
|
|
CaptureScreenshot(CaptureType.LastRegion, safeTaskSettings, false);
|
|
|
|
|
break;
|
2015-09-27 20:55:42 +13:00
|
|
|
|
case HotkeyType.ScrollingCapture:
|
|
|
|
|
TaskHelpers.OpenScrollingCapture(safeTaskSettings, true);
|
|
|
|
|
break;
|
2015-06-28 01:03:15 +12:00
|
|
|
|
case HotkeyType.CaptureWebpage:
|
|
|
|
|
TaskHelpers.OpenWebpageCapture(safeTaskSettings);
|
|
|
|
|
break;
|
|
|
|
|
case HotkeyType.AutoCapture:
|
|
|
|
|
TaskHelpers.OpenAutoCapture();
|
|
|
|
|
break;
|
|
|
|
|
case HotkeyType.StartAutoCapture:
|
|
|
|
|
TaskHelpers.StartAutoCapture();
|
|
|
|
|
break;
|
2015-06-22 19:26:30 +12:00
|
|
|
|
// Screen record
|
2014-07-05 01:32:47 +12:00
|
|
|
|
case HotkeyType.ScreenRecorder:
|
2015-06-22 18:56:18 +12:00
|
|
|
|
TaskHelpers.StartScreenRecording(ScreenRecordOutput.FFmpeg, ScreenRecordStartMethod.Region, safeTaskSettings);
|
|
|
|
|
break;
|
|
|
|
|
case HotkeyType.ScreenRecorderActiveWindow:
|
|
|
|
|
TaskHelpers.StartScreenRecording(ScreenRecordOutput.FFmpeg, ScreenRecordStartMethod.ActiveWindow, safeTaskSettings);
|
2014-12-11 08:33:47 +13:00
|
|
|
|
break;
|
2016-04-22 06:53:29 +12:00
|
|
|
|
case HotkeyType.ScreenRecorderCustomRegion:
|
|
|
|
|
TaskHelpers.StartScreenRecording(ScreenRecordOutput.FFmpeg, ScreenRecordStartMethod.CustomRegion, safeTaskSettings);
|
|
|
|
|
break;
|
2014-12-11 08:33:47 +13:00
|
|
|
|
case HotkeyType.StartScreenRecorder:
|
2015-06-22 18:56:18 +12:00
|
|
|
|
TaskHelpers.StartScreenRecording(ScreenRecordOutput.FFmpeg, ScreenRecordStartMethod.LastRegion, safeTaskSettings);
|
2015-01-30 19:50:10 +13:00
|
|
|
|
break;
|
|
|
|
|
case HotkeyType.ScreenRecorderGIF:
|
2015-06-22 18:56:18 +12:00
|
|
|
|
TaskHelpers.StartScreenRecording(ScreenRecordOutput.GIF, ScreenRecordStartMethod.Region, safeTaskSettings);
|
|
|
|
|
break;
|
|
|
|
|
case HotkeyType.ScreenRecorderGIFActiveWindow:
|
|
|
|
|
TaskHelpers.StartScreenRecording(ScreenRecordOutput.GIF, ScreenRecordStartMethod.ActiveWindow, safeTaskSettings);
|
2015-01-30 19:50:10 +13:00
|
|
|
|
break;
|
2016-04-22 06:53:29 +12:00
|
|
|
|
case HotkeyType.ScreenRecorderGIFCustomRegion:
|
|
|
|
|
TaskHelpers.StartScreenRecording(ScreenRecordOutput.GIF, ScreenRecordStartMethod.CustomRegion, safeTaskSettings);
|
|
|
|
|
break;
|
2015-01-30 19:50:10 +13:00
|
|
|
|
case HotkeyType.StartScreenRecorderGIF:
|
2015-06-22 18:56:18 +12:00
|
|
|
|
TaskHelpers.StartScreenRecording(ScreenRecordOutput.GIF, ScreenRecordStartMethod.LastRegion, safeTaskSettings);
|
2014-07-05 01:32:47 +12:00
|
|
|
|
break;
|
2015-06-22 19:26:30 +12:00
|
|
|
|
// Tools
|
2015-01-26 20:24:26 +13:00
|
|
|
|
case HotkeyType.ColorPicker:
|
|
|
|
|
TaskHelpers.OpenColorPicker();
|
|
|
|
|
break;
|
2014-07-05 01:32:47 +12:00
|
|
|
|
case HotkeyType.ScreenColorPicker:
|
2015-03-26 21:00:02 +13:00
|
|
|
|
TaskHelpers.OpenScreenColorPicker(safeTaskSettings);
|
2014-07-05 01:32:47 +12:00
|
|
|
|
break;
|
2015-06-22 19:26:30 +12:00
|
|
|
|
case HotkeyType.ImageEditor:
|
|
|
|
|
TaskHelpers.OpenImageEditor();
|
2014-07-05 01:32:47 +12:00
|
|
|
|
break;
|
2015-06-22 19:26:30 +12:00
|
|
|
|
case HotkeyType.ImageEffects:
|
|
|
|
|
TaskHelpers.OpenImageEffects();
|
2014-07-05 01:32:47 +12:00
|
|
|
|
break;
|
|
|
|
|
case HotkeyType.HashCheck:
|
|
|
|
|
TaskHelpers.OpenHashCheck();
|
|
|
|
|
break;
|
2015-06-22 19:26:30 +12:00
|
|
|
|
case HotkeyType.DNSChanger:
|
|
|
|
|
TaskHelpers.OpenDNSChanger();
|
2014-07-05 01:32:47 +12:00
|
|
|
|
break;
|
|
|
|
|
case HotkeyType.QRCode:
|
|
|
|
|
TaskHelpers.OpenQRCode();
|
|
|
|
|
break;
|
2015-06-22 19:26:30 +12:00
|
|
|
|
case HotkeyType.Ruler:
|
|
|
|
|
TaskHelpers.OpenRuler();
|
2014-07-05 01:32:47 +12:00
|
|
|
|
break;
|
2015-02-18 01:51:19 +13:00
|
|
|
|
case HotkeyType.Automate:
|
2015-02-18 22:29:36 +13:00
|
|
|
|
TaskHelpers.StartAutomate();
|
2015-02-18 01:51:19 +13:00
|
|
|
|
break;
|
2015-06-22 19:26:30 +12:00
|
|
|
|
case HotkeyType.IndexFolder:
|
2016-02-03 01:58:34 +13:00
|
|
|
|
UploadManager.IndexFolder();
|
2015-06-22 19:26:30 +12:00
|
|
|
|
break;
|
2015-10-01 12:48:33 +13:00
|
|
|
|
case HotkeyType.ImageCombiner:
|
|
|
|
|
TaskHelpers.OpenImageCombiner(safeTaskSettings);
|
|
|
|
|
break;
|
|
|
|
|
case HotkeyType.VideoThumbnailer:
|
|
|
|
|
TaskHelpers.OpenVideoThumbnailer(safeTaskSettings);
|
|
|
|
|
break;
|
2015-06-22 19:26:30 +12:00
|
|
|
|
case HotkeyType.FTPClient:
|
|
|
|
|
TaskHelpers.OpenFTPClient();
|
|
|
|
|
break;
|
|
|
|
|
case HotkeyType.TweetMessage:
|
|
|
|
|
TaskHelpers.TweetMessage();
|
|
|
|
|
break;
|
|
|
|
|
case HotkeyType.MonitorTest:
|
|
|
|
|
TaskHelpers.OpenMonitorTest();
|
|
|
|
|
break;
|
|
|
|
|
// Other
|
2016-02-22 08:50:49 +13:00
|
|
|
|
case HotkeyType.DisableHotkeys:
|
|
|
|
|
TaskHelpers.ToggleHotkeys();
|
|
|
|
|
break;
|
2016-04-07 04:15:25 +12:00
|
|
|
|
case HotkeyType.OpenMainWindow:
|
|
|
|
|
this.ForceActivate();
|
|
|
|
|
break;
|
2015-06-22 18:56:18 +12:00
|
|
|
|
case HotkeyType.OpenScreenshotsFolder:
|
|
|
|
|
TaskHelpers.OpenScreenshotsFolder();
|
|
|
|
|
break;
|
2016-02-22 08:50:49 +13:00
|
|
|
|
case HotkeyType.OpenHistory:
|
|
|
|
|
TaskHelpers.OpenHistory();
|
2015-11-01 07:26:12 +13:00
|
|
|
|
break;
|
2016-03-03 23:05:59 +13:00
|
|
|
|
case HotkeyType.OpenImageHistory:
|
|
|
|
|
TaskHelpers.OpenImageHistory();
|
|
|
|
|
break;
|
2014-07-05 01:32:47 +12:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void CaptureScreenshot(CaptureType captureType, TaskSettings taskSettings = null, bool autoHideForm = true)
|
|
|
|
|
{
|
|
|
|
|
if (taskSettings == null) taskSettings = TaskSettings.GetDefaultTaskSettings();
|
|
|
|
|
|
|
|
|
|
switch (captureType)
|
|
|
|
|
{
|
|
|
|
|
case CaptureType.Screen:
|
|
|
|
|
DoCapture(Screenshot.CaptureFullscreen, CaptureType.Screen, taskSettings, autoHideForm);
|
|
|
|
|
break;
|
|
|
|
|
case CaptureType.ActiveWindow:
|
|
|
|
|
CaptureActiveWindow(taskSettings, autoHideForm);
|
|
|
|
|
break;
|
|
|
|
|
case CaptureType.ActiveMonitor:
|
|
|
|
|
DoCapture(Screenshot.CaptureActiveMonitor, CaptureType.ActiveMonitor, taskSettings, autoHideForm);
|
|
|
|
|
break;
|
|
|
|
|
case CaptureType.Rectangle:
|
|
|
|
|
case CaptureType.Polygon:
|
|
|
|
|
case CaptureType.Freehand:
|
|
|
|
|
CaptureRegion(captureType, taskSettings, autoHideForm);
|
|
|
|
|
break;
|
2015-04-27 07:52:01 +12:00
|
|
|
|
case CaptureType.CustomRegion:
|
|
|
|
|
CaptureCustomRegion(taskSettings, autoHideForm);
|
|
|
|
|
break;
|
2014-07-05 01:32:47 +12:00
|
|
|
|
case CaptureType.LastRegion:
|
|
|
|
|
CaptureLastRegion(taskSettings, autoHideForm);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void DoCapture(ScreenCaptureDelegate capture, CaptureType captureType, TaskSettings taskSettings = null, bool autoHideForm = true)
|
|
|
|
|
{
|
|
|
|
|
if (taskSettings == null) taskSettings = TaskSettings.GetDefaultTaskSettings();
|
|
|
|
|
|
|
|
|
|
if (taskSettings.CaptureSettings.IsDelayScreenshot && taskSettings.CaptureSettings.DelayScreenshot > 0)
|
|
|
|
|
{
|
|
|
|
|
TaskEx.Run(() =>
|
|
|
|
|
{
|
|
|
|
|
int sleep = (int)(taskSettings.CaptureSettings.DelayScreenshot * 1000);
|
|
|
|
|
Thread.Sleep(sleep);
|
|
|
|
|
},
|
|
|
|
|
() =>
|
|
|
|
|
{
|
|
|
|
|
DoCaptureWork(capture, captureType, taskSettings, autoHideForm);
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
DoCaptureWork(capture, captureType, taskSettings, autoHideForm);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void DoCaptureWork(ScreenCaptureDelegate capture, CaptureType captureType, TaskSettings taskSettings, bool autoHideForm = true)
|
|
|
|
|
{
|
|
|
|
|
if (autoHideForm)
|
|
|
|
|
{
|
|
|
|
|
Hide();
|
|
|
|
|
Thread.Sleep(250);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Image img = null;
|
|
|
|
|
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
Screenshot.CaptureCursor = taskSettings.CaptureSettings.ShowCursor;
|
|
|
|
|
Screenshot.CaptureShadow = taskSettings.CaptureSettings.CaptureShadow;
|
|
|
|
|
Screenshot.ShadowOffset = taskSettings.CaptureSettings.CaptureShadowOffset;
|
|
|
|
|
Screenshot.CaptureClientArea = taskSettings.CaptureSettings.CaptureClientArea;
|
|
|
|
|
Screenshot.AutoHideTaskbar = taskSettings.CaptureSettings.CaptureAutoHideTaskbar;
|
|
|
|
|
|
|
|
|
|
img = capture();
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
DebugHelper.WriteException(ex);
|
|
|
|
|
}
|
|
|
|
|
finally
|
|
|
|
|
{
|
|
|
|
|
if (autoHideForm)
|
|
|
|
|
{
|
2016-03-10 05:37:54 +13:00
|
|
|
|
this.ForceActivate();
|
2014-07-05 01:32:47 +12:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
AfterCapture(img, captureType, taskSettings);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void AfterCapture(Image img, CaptureType captureType, TaskSettings taskSettings)
|
|
|
|
|
{
|
|
|
|
|
if (img != null)
|
|
|
|
|
{
|
|
|
|
|
if (taskSettings.GeneralSettings.PlaySoundAfterCapture)
|
|
|
|
|
{
|
2015-08-16 20:34:46 +12:00
|
|
|
|
TaskHelpers.PlayCaptureSound(taskSettings);
|
2014-07-05 01:32:47 +12:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (taskSettings.ImageSettings.ImageEffectOnlyRegionCapture && !IsRegionCapture(captureType))
|
|
|
|
|
{
|
|
|
|
|
taskSettings.AfterCaptureJob = taskSettings.AfterCaptureJob.Remove(AfterCaptureTasks.AddImageEffects);
|
|
|
|
|
}
|
|
|
|
|
|
2016-02-07 05:41:05 +13:00
|
|
|
|
if (taskSettings.AfterCaptureJob.HasFlag(AfterCaptureTasks.ShowQuickTaskMenu))
|
|
|
|
|
{
|
|
|
|
|
QuickTaskMenu quickTaskMenu = new QuickTaskMenu();
|
|
|
|
|
quickTaskMenu.TaskInfoSelected += taskInfo =>
|
|
|
|
|
{
|
2016-02-25 22:35:52 +13:00
|
|
|
|
if (taskInfo == null)
|
|
|
|
|
{
|
|
|
|
|
AfterCaptureRunTask(img, taskSettings);
|
|
|
|
|
}
|
|
|
|
|
else if (taskInfo.IsValid)
|
2016-02-07 07:10:01 +13:00
|
|
|
|
{
|
|
|
|
|
taskSettings.AfterCaptureJob = taskInfo.AfterCaptureTasks;
|
|
|
|
|
taskSettings.AfterUploadJob = taskInfo.AfterUploadTasks;
|
|
|
|
|
AfterCaptureRunTask(img, taskSettings);
|
|
|
|
|
}
|
2016-02-07 05:41:05 +13:00
|
|
|
|
};
|
|
|
|
|
quickTaskMenu.ShowMenu();
|
|
|
|
|
}
|
|
|
|
|
else
|
2014-07-05 01:32:47 +12:00
|
|
|
|
{
|
2016-02-07 05:41:05 +13:00
|
|
|
|
AfterCaptureRunTask(img, taskSettings);
|
2014-07-05 01:32:47 +12:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2016-02-07 05:41:05 +13:00
|
|
|
|
private void AfterCaptureRunTask(Image img, TaskSettings taskSettings)
|
|
|
|
|
{
|
|
|
|
|
string customFileName;
|
|
|
|
|
|
|
|
|
|
if (TaskHelpers.ShowAfterCaptureForm(taskSettings, out customFileName, img))
|
|
|
|
|
{
|
|
|
|
|
UploadManager.RunImageTask(img, taskSettings, customFileName);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2014-07-05 01:32:47 +12:00
|
|
|
|
private bool IsRegionCapture(CaptureType captureType)
|
|
|
|
|
{
|
2016-01-05 13:42:51 +13:00
|
|
|
|
return captureType.HasFlagAny(CaptureType.Rectangle, CaptureType.Polygon, CaptureType.Freehand, CaptureType.LastRegion);
|
2014-07-05 01:32:47 +12:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void CaptureActiveWindow(TaskSettings taskSettings, bool autoHideForm = true)
|
|
|
|
|
{
|
|
|
|
|
DoCapture(() =>
|
|
|
|
|
{
|
|
|
|
|
Image img;
|
|
|
|
|
string activeWindowTitle = NativeMethods.GetForegroundWindowText();
|
|
|
|
|
string activeProcessName = null;
|
|
|
|
|
|
|
|
|
|
using (Process process = NativeMethods.GetForegroundWindowProcess())
|
|
|
|
|
{
|
|
|
|
|
if (process != null)
|
|
|
|
|
{
|
|
|
|
|
activeProcessName = process.ProcessName;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (taskSettings.CaptureSettings.CaptureTransparent && !taskSettings.CaptureSettings.CaptureClientArea)
|
|
|
|
|
{
|
|
|
|
|
img = Screenshot.CaptureActiveWindowTransparent();
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
img = Screenshot.CaptureActiveWindow();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
img.Tag = new ImageTag
|
|
|
|
|
{
|
2015-12-18 01:00:20 +13:00
|
|
|
|
WindowTitle = activeWindowTitle,
|
|
|
|
|
ProcessName = activeProcessName
|
2014-07-05 01:32:47 +12:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
return img;
|
|
|
|
|
}, CaptureType.ActiveWindow, taskSettings, autoHideForm);
|
|
|
|
|
}
|
|
|
|
|
|
2015-04-27 07:52:01 +12:00
|
|
|
|
private void CaptureCustomRegion(TaskSettings taskSettings, bool autoHideForm)
|
2015-04-16 11:54:10 +12:00
|
|
|
|
{
|
|
|
|
|
DoCapture(() =>
|
|
|
|
|
{
|
2015-04-27 07:52:01 +12:00
|
|
|
|
Rectangle regionBounds = taskSettings.CaptureSettings.CaptureCustomRegion;
|
2015-04-16 11:54:10 +12:00
|
|
|
|
Image img = Screenshot.CaptureRectangle(regionBounds);
|
|
|
|
|
|
|
|
|
|
return img;
|
2015-04-27 07:52:01 +12:00
|
|
|
|
}, CaptureType.CustomRegion, taskSettings, autoHideForm);
|
2015-04-16 11:54:10 +12:00
|
|
|
|
}
|
|
|
|
|
|
2014-07-05 01:32:47 +12:00
|
|
|
|
private void CaptureWindow(IntPtr handle, TaskSettings taskSettings = null, bool autoHideForm = true)
|
|
|
|
|
{
|
|
|
|
|
if (taskSettings == null) taskSettings = TaskSettings.GetDefaultTaskSettings();
|
|
|
|
|
|
|
|
|
|
autoHideForm = autoHideForm && handle != Handle;
|
|
|
|
|
|
|
|
|
|
DoCapture(() =>
|
|
|
|
|
{
|
|
|
|
|
if (NativeMethods.IsIconic(handle))
|
|
|
|
|
{
|
|
|
|
|
NativeMethods.RestoreWindow(handle);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
NativeMethods.SetForegroundWindow(handle);
|
|
|
|
|
Thread.Sleep(250);
|
|
|
|
|
|
|
|
|
|
if (taskSettings.CaptureSettings.CaptureTransparent && !taskSettings.CaptureSettings.CaptureClientArea)
|
|
|
|
|
{
|
|
|
|
|
return Screenshot.CaptureWindowTransparent(handle);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return Screenshot.CaptureWindow(handle);
|
|
|
|
|
}, CaptureType.Window, taskSettings, autoHideForm);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void CaptureRegion(CaptureType captureType, TaskSettings taskSettings, bool autoHideForm = true)
|
|
|
|
|
{
|
|
|
|
|
Surface surface;
|
|
|
|
|
|
|
|
|
|
switch (captureType)
|
|
|
|
|
{
|
|
|
|
|
default:
|
|
|
|
|
case CaptureType.Rectangle:
|
2016-01-06 04:06:02 +13:00
|
|
|
|
surface = new RectangleRegion();
|
2014-07-05 01:32:47 +12:00
|
|
|
|
break;
|
|
|
|
|
case CaptureType.Polygon:
|
|
|
|
|
surface = new PolygonRegion();
|
|
|
|
|
break;
|
|
|
|
|
case CaptureType.Freehand:
|
|
|
|
|
surface = new FreeHandRegion();
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
DoCapture(() =>
|
|
|
|
|
{
|
|
|
|
|
Image img = null;
|
|
|
|
|
Image screenshot = Screenshot.CaptureFullscreen();
|
|
|
|
|
|
|
|
|
|
try
|
|
|
|
|
{
|
2015-08-31 22:44:23 +12:00
|
|
|
|
surface.Config = taskSettings.CaptureSettingsReference.SurfaceOptions;
|
2014-07-05 01:32:47 +12:00
|
|
|
|
surface.SurfaceImage = screenshot;
|
|
|
|
|
surface.Prepare();
|
|
|
|
|
surface.ShowDialog();
|
|
|
|
|
|
|
|
|
|
if (surface.Result == SurfaceResult.Region)
|
|
|
|
|
{
|
2015-05-06 09:33:19 +12:00
|
|
|
|
using (screenshot)
|
|
|
|
|
{
|
|
|
|
|
img = surface.GetRegionImage();
|
2015-12-18 01:00:20 +13:00
|
|
|
|
|
2015-12-20 04:04:28 +13:00
|
|
|
|
if (taskSettings.UploadSettings.RegionCaptureUseWindowPattern)
|
2015-12-18 01:00:20 +13:00
|
|
|
|
{
|
2015-12-20 04:04:28 +13:00
|
|
|
|
WindowInfo windowInfo = surface.GetWindowInfo();
|
|
|
|
|
|
|
|
|
|
if (windowInfo != null)
|
2015-12-18 01:00:20 +13:00
|
|
|
|
{
|
2015-12-20 04:04:28 +13:00
|
|
|
|
img.Tag = new ImageTag
|
|
|
|
|
{
|
|
|
|
|
WindowTitle = windowInfo.Text,
|
|
|
|
|
ProcessName = windowInfo.ProcessName
|
|
|
|
|
};
|
|
|
|
|
}
|
2015-12-18 01:00:20 +13:00
|
|
|
|
}
|
2015-05-06 09:33:19 +12:00
|
|
|
|
}
|
2014-07-05 01:32:47 +12:00
|
|
|
|
}
|
|
|
|
|
else if (surface.Result == SurfaceResult.Fullscreen)
|
|
|
|
|
{
|
|
|
|
|
img = screenshot;
|
|
|
|
|
}
|
2015-05-06 09:33:19 +12:00
|
|
|
|
else if (surface.Result == SurfaceResult.Monitor)
|
|
|
|
|
{
|
|
|
|
|
Screen[] screens = Screen.AllScreens;
|
|
|
|
|
|
2015-05-06 09:42:53 +12:00
|
|
|
|
if (surface.MonitorIndex < screens.Length)
|
2015-05-06 09:33:19 +12:00
|
|
|
|
{
|
2015-05-06 09:42:53 +12:00
|
|
|
|
Screen screen = screens[surface.MonitorIndex];
|
2015-05-06 09:33:19 +12:00
|
|
|
|
Rectangle screenRect = CaptureHelpers.ScreenToClient(screen.Bounds);
|
|
|
|
|
|
|
|
|
|
using (screenshot)
|
|
|
|
|
{
|
|
|
|
|
img = ImageHelpers.CropImage(screenshot, screenRect);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2015-05-07 04:42:13 +12:00
|
|
|
|
else if (surface.Result == SurfaceResult.ActiveMonitor)
|
|
|
|
|
{
|
|
|
|
|
Rectangle activeScreenRect = CaptureHelpers.GetActiveScreenBounds0Based();
|
|
|
|
|
|
|
|
|
|
using (screenshot)
|
|
|
|
|
{
|
|
|
|
|
img = ImageHelpers.CropImage(screenshot, activeScreenRect);
|
|
|
|
|
}
|
|
|
|
|
}
|
2014-07-05 01:32:47 +12:00
|
|
|
|
|
|
|
|
|
if (img != null)
|
|
|
|
|
{
|
2014-07-10 11:59:03 +12:00
|
|
|
|
lastRegionCaptureType = LastRegionCaptureType.Surface;
|
2014-07-05 01:32:47 +12:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
finally
|
|
|
|
|
{
|
|
|
|
|
surface.Dispose();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return img;
|
|
|
|
|
}, captureType, taskSettings, autoHideForm);
|
|
|
|
|
}
|
|
|
|
|
|
2014-07-10 07:30:18 +12:00
|
|
|
|
private void CaptureRectangleAnnotate(TaskSettings taskSettings = null, bool autoHideForm = true)
|
|
|
|
|
{
|
|
|
|
|
if (taskSettings == null) taskSettings = TaskSettings.GetDefaultTaskSettings();
|
|
|
|
|
|
|
|
|
|
DoCapture(() =>
|
|
|
|
|
{
|
|
|
|
|
Image img = null;
|
|
|
|
|
|
2015-08-31 22:44:23 +12:00
|
|
|
|
using (RectangleAnnotate rectangleAnnotate = new RectangleAnnotate(taskSettings.CaptureSettingsReference.RectangleAnnotateOptions))
|
2014-07-10 07:30:18 +12:00
|
|
|
|
{
|
|
|
|
|
if (rectangleAnnotate.ShowDialog() == DialogResult.OK)
|
|
|
|
|
{
|
|
|
|
|
img = rectangleAnnotate.GetAreaImage();
|
|
|
|
|
|
|
|
|
|
if (img != null)
|
|
|
|
|
{
|
2014-07-10 11:59:03 +12:00
|
|
|
|
lastRegionCaptureType = LastRegionCaptureType.Annotate;
|
2014-07-10 07:30:18 +12:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return img;
|
|
|
|
|
}, CaptureType.Rectangle, taskSettings, autoHideForm);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void CaptureRectangleLight(TaskSettings taskSettings = null, bool autoHideForm = true)
|
2014-07-05 01:32:47 +12:00
|
|
|
|
{
|
|
|
|
|
if (taskSettings == null) taskSettings = TaskSettings.GetDefaultTaskSettings();
|
|
|
|
|
|
|
|
|
|
DoCapture(() =>
|
|
|
|
|
{
|
|
|
|
|
Image img = null;
|
|
|
|
|
|
|
|
|
|
using (RectangleLight rectangleLight = new RectangleLight())
|
|
|
|
|
{
|
|
|
|
|
if (rectangleLight.ShowDialog() == DialogResult.OK)
|
|
|
|
|
{
|
|
|
|
|
img = rectangleLight.GetAreaImage();
|
|
|
|
|
|
|
|
|
|
if (img != null)
|
|
|
|
|
{
|
2014-07-10 11:59:03 +12:00
|
|
|
|
lastRegionCaptureType = LastRegionCaptureType.Light;
|
2014-07-05 01:32:47 +12:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return img;
|
|
|
|
|
}, CaptureType.Rectangle, taskSettings, autoHideForm);
|
|
|
|
|
}
|
|
|
|
|
|
2015-04-02 00:12:21 +13:00
|
|
|
|
private void CaptureRectangleTransparent(TaskSettings taskSettings = null, bool autoHideForm = true)
|
|
|
|
|
{
|
|
|
|
|
if (taskSettings == null) taskSettings = TaskSettings.GetDefaultTaskSettings();
|
|
|
|
|
|
|
|
|
|
DoCapture(() =>
|
|
|
|
|
{
|
|
|
|
|
Image img = null;
|
|
|
|
|
|
|
|
|
|
using (RectangleTransparent rectangleTransparent = new RectangleTransparent())
|
|
|
|
|
{
|
|
|
|
|
if (rectangleTransparent.ShowDialog() == DialogResult.OK)
|
|
|
|
|
{
|
2015-04-02 12:06:09 +13:00
|
|
|
|
img = rectangleTransparent.GetAreaImage();
|
2015-04-02 00:12:21 +13:00
|
|
|
|
|
|
|
|
|
if (img != null)
|
|
|
|
|
{
|
|
|
|
|
lastRegionCaptureType = LastRegionCaptureType.Transparent;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return img;
|
|
|
|
|
}, CaptureType.Rectangle, taskSettings, autoHideForm);
|
|
|
|
|
}
|
|
|
|
|
|
2014-07-05 01:32:47 +12:00
|
|
|
|
private void CaptureLastRegion(TaskSettings taskSettings, bool autoHideForm = true)
|
|
|
|
|
{
|
2014-07-10 11:59:03 +12:00
|
|
|
|
switch (lastRegionCaptureType)
|
2014-07-05 01:32:47 +12:00
|
|
|
|
{
|
2014-07-10 11:59:03 +12:00
|
|
|
|
case LastRegionCaptureType.Surface:
|
|
|
|
|
if (Surface.LastRegionFillPath != null)
|
2014-07-05 01:32:47 +12:00
|
|
|
|
{
|
2014-07-10 11:59:03 +12:00
|
|
|
|
DoCapture(() =>
|
2014-07-05 01:32:47 +12:00
|
|
|
|
{
|
2014-07-10 11:59:03 +12:00
|
|
|
|
using (Image screenshot = Screenshot.CaptureFullscreen())
|
|
|
|
|
{
|
|
|
|
|
return ShapeCaptureHelpers.GetRegionImage(screenshot, Surface.LastRegionFillPath, Surface.LastRegionDrawPath, taskSettings.CaptureSettings.SurfaceOptions);
|
|
|
|
|
}
|
|
|
|
|
}, CaptureType.LastRegion, taskSettings, autoHideForm);
|
|
|
|
|
}
|
|
|
|
|
else
|
2014-07-05 01:32:47 +12:00
|
|
|
|
{
|
2014-07-10 11:59:03 +12:00
|
|
|
|
CaptureRegion(CaptureType.Rectangle, taskSettings, autoHideForm);
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
case LastRegionCaptureType.Light:
|
|
|
|
|
if (!RectangleLight.LastSelectionRectangle0Based.IsEmpty)
|
|
|
|
|
{
|
|
|
|
|
DoCapture(() =>
|
2014-07-05 01:32:47 +12:00
|
|
|
|
{
|
2014-07-10 11:59:03 +12:00
|
|
|
|
using (Image screenshot = Screenshot.CaptureFullscreen())
|
|
|
|
|
{
|
|
|
|
|
return ImageHelpers.CropImage(screenshot, RectangleLight.LastSelectionRectangle0Based);
|
|
|
|
|
}
|
|
|
|
|
}, CaptureType.LastRegion, taskSettings, autoHideForm);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
CaptureRectangleLight(taskSettings, autoHideForm);
|
|
|
|
|
}
|
|
|
|
|
break;
|
2015-04-02 00:12:21 +13:00
|
|
|
|
case LastRegionCaptureType.Transparent:
|
|
|
|
|
if (!RectangleTransparent.LastSelectionRectangle0Based.IsEmpty)
|
|
|
|
|
{
|
|
|
|
|
DoCapture(() =>
|
|
|
|
|
{
|
|
|
|
|
using (Image screenshot = Screenshot.CaptureFullscreen())
|
|
|
|
|
{
|
2015-05-06 09:13:06 +12:00
|
|
|
|
return ImageHelpers.CropImage(screenshot, RectangleTransparent.LastSelectionRectangle0Based);
|
2015-04-02 00:12:21 +13:00
|
|
|
|
}
|
|
|
|
|
}, CaptureType.LastRegion, taskSettings, autoHideForm);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
CaptureRectangleTransparent(taskSettings, autoHideForm);
|
|
|
|
|
}
|
|
|
|
|
break;
|
2014-07-10 11:59:03 +12:00
|
|
|
|
case LastRegionCaptureType.Annotate:
|
|
|
|
|
if (!RectangleAnnotate.LastSelectionRectangle0Based.IsEmpty)
|
|
|
|
|
{
|
|
|
|
|
DoCapture(() =>
|
|
|
|
|
{
|
|
|
|
|
using (Image screenshot = Screenshot.CaptureFullscreen())
|
|
|
|
|
{
|
|
|
|
|
return ImageHelpers.CropImage(screenshot, RectangleAnnotate.LastSelectionRectangle0Based);
|
|
|
|
|
}
|
|
|
|
|
}, CaptureType.LastRegion, taskSettings, autoHideForm);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
CaptureRectangleAnnotate(taskSettings, autoHideForm);
|
|
|
|
|
}
|
|
|
|
|
break;
|
2014-07-05 01:32:47 +12:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void PrepareCaptureMenuAsync(ToolStripMenuItem tsmiWindow, EventHandler handlerWindow, ToolStripMenuItem tsmiMonitor, EventHandler handlerMonitor)
|
|
|
|
|
{
|
|
|
|
|
tsmiWindow.DropDownItems.Clear();
|
|
|
|
|
|
|
|
|
|
WindowsList windowsList = new WindowsList();
|
|
|
|
|
List<WindowInfo> windows = null;
|
|
|
|
|
|
|
|
|
|
TaskEx.Run(() =>
|
|
|
|
|
{
|
|
|
|
|
windows = windowsList.GetVisibleWindowsList();
|
|
|
|
|
},
|
|
|
|
|
() =>
|
|
|
|
|
{
|
|
|
|
|
if (windows != null)
|
|
|
|
|
{
|
|
|
|
|
foreach (WindowInfo window in windows)
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
2015-01-20 02:38:53 +13:00
|
|
|
|
string title = window.Text.Truncate(50, "...");
|
2014-07-05 01:32:47 +12:00
|
|
|
|
ToolStripItem tsi = tsmiWindow.DropDownItems.Add(title);
|
|
|
|
|
tsi.Tag = window;
|
|
|
|
|
tsi.Click += handlerWindow;
|
|
|
|
|
|
|
|
|
|
using (Icon icon = window.Icon)
|
|
|
|
|
{
|
|
|
|
|
if (icon != null && icon.Width > 0 && icon.Height > 0)
|
|
|
|
|
{
|
|
|
|
|
tsi.Image = icon.ToBitmap();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
catch (Exception e)
|
|
|
|
|
{
|
|
|
|
|
DebugHelper.WriteException(e);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
tsmiMonitor.DropDownItems.Clear();
|
|
|
|
|
|
|
|
|
|
Screen[] screens = Screen.AllScreens;
|
|
|
|
|
|
|
|
|
|
for (int i = 0; i < screens.Length; i++)
|
|
|
|
|
{
|
|
|
|
|
Screen screen = screens[i];
|
|
|
|
|
string text = string.Format("{0}. {1}x{2}", i + 1, screen.Bounds.Width, screen.Bounds.Height);
|
|
|
|
|
ToolStripItem tsi = tsmiMonitor.DropDownItems.Add(text);
|
|
|
|
|
tsi.Tag = screen.Bounds;
|
|
|
|
|
tsi.Click += handlerMonitor;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
tsmiWindow.Invalidate();
|
|
|
|
|
tsmiMonitor.Invalidate();
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#region Menu events
|
|
|
|
|
|
|
|
|
|
private void tsmiFullscreen_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
CaptureScreenshot(CaptureType.Screen);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void tsddbCapture_DropDownOpening(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
PrepareCaptureMenuAsync(tsmiWindow, tsmiWindowItems_Click, tsmiMonitor, tsmiMonitorItems_Click);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void tsmiWindowItems_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
ToolStripItem tsi = (ToolStripItem)sender;
|
|
|
|
|
WindowInfo wi = tsi.Tag as WindowInfo;
|
|
|
|
|
if (wi != null)
|
|
|
|
|
{
|
|
|
|
|
CaptureWindow(wi.Handle);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void tsmiMonitorItems_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
ToolStripItem tsi = (ToolStripItem)sender;
|
|
|
|
|
Rectangle rectangle = (Rectangle)tsi.Tag;
|
|
|
|
|
if (!rectangle.IsEmpty)
|
|
|
|
|
{
|
|
|
|
|
DoCapture(() => Screenshot.CaptureRectangle(rectangle), CaptureType.Monitor);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void tsmiRectangle_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
CaptureScreenshot(CaptureType.Rectangle);
|
|
|
|
|
}
|
|
|
|
|
|
2014-07-10 07:30:18 +12:00
|
|
|
|
private void tsmiRectangleAnnotate_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
CaptureRectangleAnnotate();
|
|
|
|
|
}
|
|
|
|
|
|
2014-07-05 01:32:47 +12:00
|
|
|
|
private void tsmiRectangleLight_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
2014-07-10 07:30:18 +12:00
|
|
|
|
CaptureRectangleLight();
|
2014-07-05 01:32:47 +12:00
|
|
|
|
}
|
|
|
|
|
|
2015-04-02 00:12:21 +13:00
|
|
|
|
private void tsmiRectangleTransparent_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
CaptureRectangleTransparent();
|
|
|
|
|
}
|
|
|
|
|
|
2014-07-05 01:32:47 +12:00
|
|
|
|
private void tsmiPolygon_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
CaptureScreenshot(CaptureType.Polygon);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void tsmiFreeHand_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
CaptureScreenshot(CaptureType.Freehand);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void tsmiLastRegion_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
CaptureScreenshot(CaptureType.LastRegion);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#endregion Menu events
|
|
|
|
|
|
|
|
|
|
#region Tray events
|
|
|
|
|
|
2014-10-22 00:30:52 +13:00
|
|
|
|
private void cmsTray_Opened(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
if (Program.Settings.TrayAutoExpandCaptureMenu)
|
|
|
|
|
{
|
2014-10-22 07:08:05 +13:00
|
|
|
|
tsmiTrayCapture.Select();
|
2014-10-22 00:30:52 +13:00
|
|
|
|
tsmiTrayCapture.ShowDropDown();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2014-07-05 01:32:47 +12:00
|
|
|
|
private void tsmiTrayFullscreen_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
CaptureScreenshot(CaptureType.Screen, null, false);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void tsmiCapture_DropDownOpening(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
PrepareCaptureMenuAsync(tsmiTrayWindow, tsmiTrayWindowItems_Click, tsmiTrayMonitor, tsmiTrayMonitorItems_Click);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void tsmiTrayWindowItems_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
ToolStripItem tsi = (ToolStripItem)sender;
|
|
|
|
|
WindowInfo wi = tsi.Tag as WindowInfo;
|
|
|
|
|
if (wi != null)
|
|
|
|
|
{
|
|
|
|
|
CaptureWindow(wi.Handle, null, false);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void tsmiTrayMonitorItems_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
ToolStripItem tsi = (ToolStripItem)sender;
|
|
|
|
|
Rectangle rectangle = (Rectangle)tsi.Tag;
|
|
|
|
|
if (!rectangle.IsEmpty)
|
|
|
|
|
{
|
|
|
|
|
DoCapture(() => Screenshot.CaptureRectangle(rectangle), CaptureType.Monitor, null, false);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void tsmiTrayRectangle_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
CaptureScreenshot(CaptureType.Rectangle, null, false);
|
|
|
|
|
}
|
|
|
|
|
|
2014-07-10 07:30:18 +12:00
|
|
|
|
private void tsmiTrayRectangleAnnotate_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
CaptureRectangleAnnotate(null, false);
|
|
|
|
|
}
|
|
|
|
|
|
2014-07-05 01:32:47 +12:00
|
|
|
|
private void tsmiTrayRectangleLight_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
2014-07-10 07:30:18 +12:00
|
|
|
|
CaptureRectangleLight(null, false);
|
2014-07-05 01:32:47 +12:00
|
|
|
|
}
|
|
|
|
|
|
2015-04-02 00:12:21 +13:00
|
|
|
|
private void tsmiTrayRectangleTransparent_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
CaptureRectangleTransparent(null, false);
|
|
|
|
|
}
|
|
|
|
|
|
2014-07-05 01:32:47 +12:00
|
|
|
|
private void tsmiTrayPolygon_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
CaptureScreenshot(CaptureType.Polygon, null, false);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void tsmiTrayFreeHand_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
CaptureScreenshot(CaptureType.Freehand, null, false);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void tsmiTrayLastRegion_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
CaptureScreenshot(CaptureType.LastRegion, null, false);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#endregion Tray events
|
|
|
|
|
|
|
|
|
|
#endregion Hotkey/Capture codes and form events
|
2013-11-03 23:53:49 +13:00
|
|
|
|
}
|
2015-08-16 20:34:46 +12:00
|
|
|
|
}
|