diff --git a/ShareX.HelpersLib/ControlHider.cs b/ShareX.HelpersLib/ControlHider.cs new file mode 100644 index 000000000..d650004a9 --- /dev/null +++ b/ShareX.HelpersLib/ControlHider.cs @@ -0,0 +1,66 @@ +#region License Information (GPL v3) + +/* + ShareX - A program that allows you to take screenshots and share any file type + Copyright (c) 2007-2020 ShareX Team + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License + as published by the Free Software Foundation; either version 2 + of the License, or (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + + Optionally you can also view the license at . +*/ + +#endregion License Information (GPL v3) + +using System; +using System.Windows.Forms; + +namespace ShareX.HelpersLib +{ + public class ControlHider : IDisposable + { + public Control Control { get; private set; } + public int AutoHideTime { get; private set; } + + private Timer timer; + + public ControlHider(Control control, int autoHideTime) + { + Control = control; + AutoHideTime = autoHideTime; + + timer = new Timer(); + timer.Interval = AutoHideTime; + timer.Tick += Timer_Tick; + } + + private void Timer_Tick(object sender, EventArgs e) + { + timer.Stop(); + Control.Visible = false; + } + + public void Show() + { + Control.Visible = true; + timer.Stop(); + timer.Start(); + } + + public void Dispose() + { + timer?.Dispose(); + } + } +} \ No newline at end of file diff --git a/ShareX.HelpersLib/Forms/ColorPickerForm.Designer.cs b/ShareX.HelpersLib/Forms/ColorPickerForm.Designer.cs index 4d4093ddd..2f39de235 100644 --- a/ShareX.HelpersLib/Forms/ColorPickerForm.Designer.cs +++ b/ShareX.HelpersLib/Forms/ColorPickerForm.Designer.cs @@ -69,7 +69,6 @@ private void InitializeComponent() this.lblAlpha = new System.Windows.Forms.Label(); this.ttMain = new System.Windows.Forms.ToolTip(this.components); this.btnScreenColorPicker = new System.Windows.Forms.Button(); - this.cbTransparent = new ShareX.HelpersLib.ColorButton(); this.btnClipboardColorPicker = new System.Windows.Forms.Button(); this.cmsCopy = new System.Windows.Forms.ContextMenuStrip(this.components); this.tsmiCopyAll = new System.Windows.Forms.ToolStripMenuItem(); @@ -92,7 +91,9 @@ private void InitializeComponent() this.flpColorPaletteSelection = new System.Windows.Forms.FlowLayoutPanel(); this.lblName = new System.Windows.Forms.Label(); this.lblNameValue = new System.Windows.Forms.Label(); + this.btnClipboardStatus = new System.Windows.Forms.Button(); this.mbCopy = new ShareX.HelpersLib.MenuButton(); + this.cbTransparent = new ShareX.HelpersLib.ColorButton(); this.pbColorPreview = new ShareX.HelpersLib.MyPictureBox(); this.colorPicker = new ShareX.HelpersLib.ColorPicker(); ((System.ComponentModel.ISupportInitialize)(this.nudKey)).BeginInit(); @@ -427,16 +428,6 @@ private void InitializeComponent() this.btnScreenColorPicker.UseVisualStyleBackColor = true; this.btnScreenColorPicker.Click += new System.EventHandler(this.btnScreenColorPicker_Click); // - // cbTransparent - // - this.cbTransparent.Color = System.Drawing.Color.Transparent; - resources.ApplyResources(this.cbTransparent, "cbTransparent"); - this.cbTransparent.ManualButtonClick = true; - this.cbTransparent.Name = "cbTransparent"; - this.ttMain.SetToolTip(this.cbTransparent, resources.GetString("cbTransparent.ToolTip")); - this.cbTransparent.UseVisualStyleBackColor = true; - this.cbTransparent.Click += new System.EventHandler(this.cbTransparent_Click); - // // btnClipboardColorPicker // this.btnClipboardColorPicker.Image = global::ShareX.HelpersLib.Properties.Resources.clipboard_block; @@ -583,6 +574,13 @@ private void InitializeComponent() resources.ApplyResources(this.lblNameValue, "lblNameValue"); this.lblNameValue.Name = "lblNameValue"; // + // btnClipboardStatus + // + resources.ApplyResources(this.btnClipboardStatus, "btnClipboardStatus"); + this.btnClipboardStatus.Image = global::ShareX.HelpersLib.Properties.Resources.tick; + this.btnClipboardStatus.Name = "btnClipboardStatus"; + this.btnClipboardStatus.UseVisualStyleBackColor = true; + // // mbCopy // resources.ApplyResources(this.mbCopy, "mbCopy"); @@ -590,6 +588,16 @@ private void InitializeComponent() this.mbCopy.Name = "mbCopy"; this.mbCopy.UseVisualStyleBackColor = true; // + // cbTransparent + // + this.cbTransparent.Color = System.Drawing.Color.Transparent; + resources.ApplyResources(this.cbTransparent, "cbTransparent"); + this.cbTransparent.ManualButtonClick = true; + this.cbTransparent.Name = "cbTransparent"; + this.ttMain.SetToolTip(this.cbTransparent, resources.GetString("cbTransparent.ToolTip")); + this.cbTransparent.UseVisualStyleBackColor = true; + this.cbTransparent.Click += new System.EventHandler(this.cbTransparent_Click); + // // pbColorPreview // this.pbColorPreview.BackColor = System.Drawing.SystemColors.Window; @@ -613,6 +621,7 @@ private void InitializeComponent() this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Dpi; this.BackColor = System.Drawing.SystemColors.Window; this.CancelButton = this.btnCancel; + this.Controls.Add(this.btnClipboardStatus); this.Controls.Add(this.btnClipboardColorPicker); this.Controls.Add(this.lblName); this.Controls.Add(this.lblNameValue); @@ -755,5 +764,6 @@ private void InitializeComponent() private System.Windows.Forms.Label lblName; private System.Windows.Forms.Label lblNameValue; private System.Windows.Forms.Button btnClipboardColorPicker; + private System.Windows.Forms.Button btnClipboardStatus; } } \ No newline at end of file diff --git a/ShareX.HelpersLib/Forms/ColorPickerForm.cs b/ShareX.HelpersLib/Forms/ColorPickerForm.cs index 75a8436a0..81c47f6bf 100644 --- a/ShareX.HelpersLib/Forms/ColorPickerForm.cs +++ b/ShareX.HelpersLib/Forms/ColorPickerForm.cs @@ -40,11 +40,13 @@ public partial class ColorPickerForm : Form private bool oldColorExist; private bool controlChangingColor; + private ControlHider clipboardStatusHider; public ColorPickerForm(Color currentColor, bool isScreenColorPickerMode = false, bool checkClipboard = true) { InitializeComponent(); ShareXResources.ApplyTheme(this); + clipboardStatusHider = new ControlHider(btnClipboardStatus, 2000); IsScreenColorPickerMode = isScreenColorPickerMode; @@ -70,10 +72,19 @@ public bool CheckClipboard() { string text = ClipboardHelpers.GetText(true); - if (!string.IsNullOrEmpty(text) && ColorHelpers.ParseColor(text, out Color clipboardColor)) + if (!string.IsNullOrEmpty(text)) { - colorPicker.ChangeColor(clipboardColor); - return true; + text = text.Trim(); + + if (ColorHelpers.ParseColor(text, out Color clipboardColor)) + { + colorPicker.ChangeColor(clipboardColor); + btnClipboardStatus.Text = "Clipboard: " + text; + btnClipboardStatus.Location = new Point(btnClipboardColorPicker.Left + btnClipboardColorPicker.Width / 2 - btnClipboardStatus.Width / 2, + btnClipboardColorPicker.Top - btnClipboardStatus.Height - 5); + clipboardStatusHider.Show(); + return true; + } } return false; diff --git a/ShareX.HelpersLib/Forms/ColorPickerForm.resx b/ShareX.HelpersLib/Forms/ColorPickerForm.resx index 843be9830..2fd1a4027 100644 --- a/ShareX.HelpersLib/Forms/ColorPickerForm.resx +++ b/ShareX.HelpersLib/Forms/ColorPickerForm.resx @@ -145,7 +145,7 @@ $this - 27 + 28 NoControl @@ -172,7 +172,7 @@ $this - 28 + 29 True @@ -202,7 +202,7 @@ $this - 29 + 30 True @@ -232,7 +232,7 @@ $this - 30 + 31 600, 174 @@ -262,7 +262,7 @@ $this - 31 + 32 True @@ -292,7 +292,7 @@ $this - 32 + 33 600, 142 @@ -316,7 +316,7 @@ $this - 33 + 34 600, 108 @@ -340,7 +340,7 @@ $this - 34 + 35 600, 78 @@ -364,7 +364,7 @@ $this - 35 + 36 600, 46 @@ -388,7 +388,7 @@ $this - 36 + 37 True @@ -418,7 +418,7 @@ $this - 37 + 38 True @@ -448,7 +448,7 @@ $this - 38 + 39 True @@ -478,7 +478,7 @@ $this - 39 + 40 True @@ -508,7 +508,7 @@ $this - 40 + 41 True @@ -541,7 +541,7 @@ $this - 41 + 42 True @@ -574,7 +574,7 @@ $this - 42 + 43 True @@ -607,7 +607,7 @@ $this - 43 + 44 408, 78 @@ -631,7 +631,7 @@ $this - 11 + 12 408, 46 @@ -655,7 +655,7 @@ $this - 12 + 13 408, 14 @@ -679,7 +679,7 @@ $this - 13 + 14 408, 174 @@ -703,7 +703,7 @@ $this - 44 + 45 408, 142 @@ -727,7 +727,7 @@ $this - 45 + 46 408, 108 @@ -751,7 +751,7 @@ $this - 46 + 47 True @@ -781,7 +781,7 @@ $this - 14 + 15 True @@ -811,7 +811,7 @@ $this - 15 + 16 True @@ -841,7 +841,7 @@ $this - 16 + 17 True @@ -871,7 +871,7 @@ $this - 47 + 48 True @@ -901,7 +901,7 @@ $this - 48 + 49 True @@ -931,7 +931,7 @@ $this - 49 + 50 True @@ -961,7 +961,7 @@ $this - 25 + 26 600, 204 @@ -988,7 +988,7 @@ $this - 24 + 25 True @@ -1021,7 +1021,7 @@ $this - 23 + 24 True @@ -1054,7 +1054,7 @@ $this - 22 + 23 True @@ -1087,7 +1087,7 @@ $this - 21 + 22 True @@ -1120,7 +1120,7 @@ $this - 20 + 21 600, 14 @@ -1144,7 +1144,7 @@ $this - 19 + 20 True @@ -1174,7 +1174,7 @@ $this - 18 + 19 17, 17 @@ -1207,34 +1207,7 @@ $this - 6 - - - NoControl - - - 652, 13 - - - 23, 23 - - - 39 - - - Transparent - - - cbTransparent - - - ShareX.HelpersLib.ColorButton, ShareX.HelpersLib, Version=13.1.1.0, Culture=neutral, PublicKeyToken=null - - - $this - - - 10 + 7 NoControl @@ -1261,20 +1234,11 @@ $this - 1 + 2 104, 17 - - 148, 158 - - - cmsCopy - - - System.Windows.Forms.ContextMenuStrip, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - 147, 22 @@ -1317,86 +1281,14 @@ Copy position - - txtY + + 148, 158 - - System.Windows.Forms.TextBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + cmsCopy - - pCursorPosition - - - 0 - - - txtX - - - System.Windows.Forms.TextBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - pCursorPosition - - - 1 - - - lblY - - - System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - pCursorPosition - - - 2 - - - lblX - - - System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - pCursorPosition - - - 3 - - - lblCursorPosition - - - System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - pCursorPosition - - - 4 - - - 488, 232 - - - 192, 48 - - - 42 - - - pCursorPosition - - - System.Windows.Forms.Panel, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - $this - - - 8 + + System.Windows.Forms.ContextMenuStrip, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 136, 24 @@ -1542,6 +1434,27 @@ 4 + + 488, 232 + + + 192, 48 + + + 42 + + + pCursorPosition + + + System.Windows.Forms.Panel, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + $this + + + 9 + NoControl @@ -1567,7 +1480,7 @@ $this - 7 + 8 8, 293 @@ -1588,7 +1501,7 @@ $this - 4 + 5 True @@ -1675,7 +1588,7 @@ $this - 5 + 6 True @@ -1705,7 +1618,7 @@ $this - 2 + 3 NoControl @@ -1732,7 +1645,49 @@ $this - 3 + 4 + + + True + + + GrowAndShrink + + + Flat + + + Microsoft Sans Serif, 9pt + + + NoControl + + + 436, 264 + + + 24, 24 + + + 53 + + + TextBeforeImage + + + False + + + btnClipboardStatus + + + System.Windows.Forms.Button, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + $this + + + 1 NoControl @@ -1759,7 +1714,34 @@ $this - 9 + 10 + + + NoControl + + + 652, 13 + + + 23, 23 + + + 39 + + + Transparent + + + cbTransparent + + + ShareX.HelpersLib.ColorButton, ShareX.HelpersLib, Version=13.1.1.0, Culture=neutral, PublicKeyToken=null + + + $this + + + 11 408, 232 @@ -1780,7 +1762,7 @@ $this - 17 + 18 True @@ -1804,7 +1786,7 @@ $this - 26 + 27 True diff --git a/ShareX.HelpersLib/Properties/Resources.Designer.cs b/ShareX.HelpersLib/Properties/Resources.Designer.cs index 5457be70b..390c7d637 100644 --- a/ShareX.HelpersLib/Properties/Resources.Designer.cs +++ b/ShareX.HelpersLib/Properties/Resources.Designer.cs @@ -3434,6 +3434,16 @@ internal class Resources { } } + /// + /// Looks up a localized resource of type System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap tick { + get { + object obj = ResourceManager.GetObject("tick", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + /// /// Looks up a localized string similar to A newer version of {0} is available. /// diff --git a/ShareX.HelpersLib/Properties/Resources.resx b/ShareX.HelpersLib/Properties/Resources.resx index 4834ba6b0..b932c98d3 100644 --- a/ShareX.HelpersLib/Properties/Resources.resx +++ b/ShareX.HelpersLib/Properties/Resources.resx @@ -132,6 +132,9 @@ Big square + + Tools + Second @@ -171,9 +174,6 @@ User login name - - Clipboard content: Image (Size: {0}x{1}) - Image effects @@ -189,9 +189,8 @@ Speech balloon (S) - - - ..\Resources\ShareX_Icon_White.ico;System.Drawing.Icon, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + {0} is up to date Screen record @@ -226,8 +225,8 @@ Perform actions - - Tools + + Percentage of canvas Date and time @@ -235,6 +234,9 @@ Image combiner + + Tools + Capture region (Transparent) @@ -277,8 +279,8 @@ Auto increment hexadecimal. 0 pad left using {n} - - Don't resize + + Cyan: {0:0.0}%, Magenta: {1:0.0}%, Yellow: {2:0.0}%, Key: {3:0.0}% Upload folder @@ -292,6 +294,9 @@ Day + + 1 Day + Arrow (A) @@ -352,6 +357,9 @@ Tools + + Tools + Capture pre configured region @@ -383,15 +391,12 @@ Would you like to download it? Download failed: - - Google image search - - - Medium thumbnail - Text (Outline) (O) + + Capture active monitor + Small thumbnail @@ -401,6 +406,10 @@ Would you like to download it? Octree quantizer 16 colors + + Show "After upload" window + + ..\Resources\crosshair.cur;System.Byte[], mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 @@ -413,7 +422,7 @@ Would you like to download it? Custom file uploader - + Tools @@ -431,6 +440,9 @@ Would you like to download it? Start/Stop screen recording using active window region + + Tools + Random number 0 to 9. Repeat using {n} @@ -470,9 +482,6 @@ Would you like to download it? Amazon S3 Glacier Deep Archive - - Screen capture - Octree quantizer 256 colors (Slow encoding but better quality) @@ -485,8 +494,8 @@ Would you like to download it? Auto increment alphanumeric case-insensitive. 0 pad left using {n} - - Upload + + Setting DNS failed. Manual @@ -530,6 +539,9 @@ Would you like to download it? Ellipse region + + Simulate pressing "Page down" key + DNS changer @@ -539,9 +551,6 @@ Would you like to download it? Start/Stop screen recording (GIF) using custom region - - Value - Unlisted @@ -623,8 +632,8 @@ Would you like to download it? File path without extension + "Output file name extension" - - 1 Day + + Google image search Screen capture @@ -644,11 +653,8 @@ Would you like to download it? Tweet message - - Auto capture - - - Video converter + + Don't resize Stop all active uploads @@ -662,6 +668,9 @@ Would you like to download it? ..\Resources\cross.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + Upload + Loading image... @@ -685,8 +694,8 @@ File size: {2:n0} / {3:n0} KB Current version - - Choose folder + + Screen capture Email @@ -701,9 +710,6 @@ File size: {2:n0} / {3:n0} KB A newer version of {0} is available. Would you like to download and install it? - - Tools - Screen record @@ -719,6 +725,9 @@ Would you like to download and install it? File does not exist: + + Choose folder + Import failed. @@ -737,8 +746,8 @@ Would you like to download and install it? 24 bit - - Copy file to clipboard + + Week of year Absolute size @@ -779,11 +788,11 @@ Would you like to download and install it? Sticker - - Percentage of canvas + + QR code - - Screen capture + + 1 Week Other @@ -791,9 +800,6 @@ Would you like to download and install it? URL sharing service - - Image height - Automatically try all methods until one works @@ -818,6 +824,9 @@ Would you like to download and install it? Upload + + Other + Simulate mouse wheel scrolling @@ -827,14 +836,17 @@ Would you like to download and install it? Error + + Random animal + Custom URL sharing service Capture fullscreen - - Setting DNS failed. + + Process name of window Waiting. @@ -842,8 +854,8 @@ Would you like to download and install it? Image editor - - Automatic + + Email Open history window @@ -851,9 +863,6 @@ Would you like to download and install it? Upload - - Email - Select and move (M) @@ -881,8 +890,11 @@ Would you like to download and install it? ..\Resources\Loading.gif;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a - - Tools + + Automatic + + + Screen record Upload file @@ -917,8 +929,8 @@ Would you like to download and install it? Screen capture - - Screen record + + Screen capture No @@ -941,8 +953,8 @@ Would you like to download and install it? Disable scrolling to top - - Process name of window + + Clipboard content: Image (Size: {0}x{1}) Month name (English) @@ -956,17 +968,14 @@ Would you like to download and install it? Start - - ..\Resources\LoadingSmallWhite.gif;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a - Show tray balloon tip Week name (English) - - Cyan: {0:0.0}%, Magenta: {1:0.0}%, Yellow: {2:0.0}%, Key: {3:0.0}% + + ..\Resources\LoadingSmallWhite.gif;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a Browse for executable... @@ -1040,6 +1049,9 @@ Would you like to download and install it? Other + + ..\Resources\clipboard-block.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + Filename: {0} @@ -1055,8 +1067,8 @@ Would you like to download and install it? Amazon S3 Glacier - - Copy name + + Screen record Stop @@ -1073,11 +1085,11 @@ Would you like to download and install it? Screen capture - - Random animal + + Value - - Screen record + + ..\Resources\ShareX_Icon_White.ico;System.Drawing.Icon, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a Disable/Enable hotkeys @@ -1091,8 +1103,8 @@ Would you like to download and install it? Send scroll top message - - Other + + Copy name Remove shape @@ -1100,12 +1112,6 @@ Would you like to download and install it? File path - - Week of year - - - {0} is up to date - ..\Resources\ShareX_Icon.ico;System.Drawing.Icon, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a @@ -1115,8 +1121,8 @@ Would you like to download and install it? Tools - - Capture active monitor + + Video converter Cancel @@ -1136,8 +1142,8 @@ Would you like to download and install it? Name: {0}, Size: {1} - - 1 Week + + Auto capture Rectangle (R) @@ -1154,8 +1160,8 @@ Would you like to download and install it? Choose file - - QR code + + Image height 1 Month @@ -1181,9 +1187,6 @@ Would you like to download and install it? Public - - Tools - Send scroll message to window or control @@ -1241,22 +1244,22 @@ Would you like to download and install it? Start auto capture using last region - - Tools + + Medium thumbnail Undo - - Show "After upload" window + + Copy file to clipboard - - Simulate pressing "Page down" key + + Tools Amazon S3 Standard-Infrequent Access - - ..\Resources\clipboard-block.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + ..\Resources\tick.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a \ No newline at end of file diff --git a/ShareX.HelpersLib/Resources/tick.png b/ShareX.HelpersLib/Resources/tick.png new file mode 100644 index 000000000..a7d7a96be Binary files /dev/null and b/ShareX.HelpersLib/Resources/tick.png differ diff --git a/ShareX.HelpersLib/ShareX.HelpersLib.csproj b/ShareX.HelpersLib/ShareX.HelpersLib.csproj index f60928884..74371fd13 100644 --- a/ShareX.HelpersLib/ShareX.HelpersLib.csproj +++ b/ShareX.HelpersLib/ShareX.HelpersLib.csproj @@ -104,6 +104,7 @@ Properties\SharedAssemblyInfo.cs + Component @@ -1483,6 +1484,9 @@ + + +