From 6d50877900adc37d2d76214f7b76a80aa8ece510 Mon Sep 17 00:00:00 2001 From: Jaex Date: Tue, 26 May 2015 19:14:09 +0300 Subject: [PATCH] OAuth verification code text box will show "Paste verification code here" text when it not got focus --- ShareX.HelpersLib/Extensions/Extensions.cs | 8 +++++ ShareX.HelpersLib/Native/NativeConstants.cs | 3 ++ ShareX.HelpersLib/Native/NativeMethods.cs | 3 ++ ShareX.UploadersLib/Controls/OAuthControl.cs | 3 +- .../Controls/OAuthControl.resx | 33 ++++++++++++++++--- ShareX/Forms/MainForm.resx | 4 +-- ShareX/Properties/Resources.tr.resx | 3 ++ 7 files changed, 50 insertions(+), 7 deletions(-) diff --git a/ShareX.HelpersLib/Extensions/Extensions.cs b/ShareX.HelpersLib/Extensions/Extensions.cs index bb58d26f9..03a4ab5b5 100644 --- a/ShareX.HelpersLib/Extensions/Extensions.cs +++ b/ShareX.HelpersLib/Extensions/Extensions.cs @@ -446,5 +446,13 @@ public static void Move(this List list, int oldIndex, int newIndex) list.RemoveAt(oldIndex); list.Insert(newIndex, obj); } + + public static void SetWatermark(this TextBox textBox, string watermarkText, bool showCueWhenFocus = false) + { + if (textBox != null && textBox.IsHandleCreated && watermarkText != null) + { + NativeMethods.SendMessage(textBox.Handle, (int)NativeMethods.EM_SETCUEBANNER, showCueWhenFocus ? 1 : 0, watermarkText); + } + } } } \ No newline at end of file diff --git a/ShareX.HelpersLib/Native/NativeConstants.cs b/ShareX.HelpersLib/Native/NativeConstants.cs index 746fb34a9..37864d2ec 100644 --- a/ShareX.HelpersLib/Native/NativeConstants.cs +++ b/ShareX.HelpersLib/Native/NativeConstants.cs @@ -79,5 +79,8 @@ public static partial class NativeMethods /// Windows XP: Draws the icon as an unmirrored icon. By default, the icon is drawn as a mirrored icon if hdc is mirrored. /// public const int DI_NOMIRROR = 0x0010; + + public const uint ECM_FIRST = 0x1500; + public const uint EM_SETCUEBANNER = ECM_FIRST + 1; } } \ No newline at end of file diff --git a/ShareX.HelpersLib/Native/NativeMethods.cs b/ShareX.HelpersLib/Native/NativeMethods.cs index 703b5953d..5a3409438 100644 --- a/ShareX.HelpersLib/Native/NativeMethods.cs +++ b/ShareX.HelpersLib/Native/NativeMethods.cs @@ -198,6 +198,9 @@ public static partial class NativeMethods [DllImport("user32.dll", CharSet = CharSet.Auto)] public static extern IntPtr SendMessage(IntPtr hWnd, int Msg, int wParam, int lParam); + [DllImport("user32.dll")] + public static extern IntPtr SendMessage(IntPtr hWnd, int Msg, int wParam, [MarshalAs(UnmanagedType.LPWStr)] string lParam); + [DllImport("user32.dll", CharSet = CharSet.Auto)] public static extern IntPtr SendMessageTimeout(IntPtr hWnd, uint Msg, IntPtr wParam, IntPtr lParam, SendMessageTimeoutFlags fuFlags, uint uTimeout, out UIntPtr lpdwResult); diff --git a/ShareX.UploadersLib/Controls/OAuthControl.cs b/ShareX.UploadersLib/Controls/OAuthControl.cs index 9487cdf61..7e8b99021 100644 --- a/ShareX.UploadersLib/Controls/OAuthControl.cs +++ b/ShareX.UploadersLib/Controls/OAuthControl.cs @@ -23,6 +23,7 @@ You should have received a copy of the GNU General Public License #endregion License Information (GPL v3) +using ShareX.HelpersLib; using ShareX.UploadersLib.Properties; using System; using System.ComponentModel; @@ -111,6 +112,7 @@ public OAuthControl() defaultGroupBoxSize = gbUserAccount.Size; smallGroupBoxSize = new Size(defaultGroupBoxSize.Width, (int)(defaultGroupBoxSize.Height / 1.16f)); IsRefreshable = true; + txtVerificationCode.HandleCreated += (sender, e) => txtVerificationCode.SetWatermark("Paste verification code here"); } private void btnOpenAuthorizePage_Click(object sender, EventArgs e) @@ -118,7 +120,6 @@ private void btnOpenAuthorizePage_Click(object sender, EventArgs e) if (OpenButtonClicked != null) { OpenButtonClicked(); - txtVerificationCode.Focus(); } } diff --git a/ShareX.UploadersLib/Controls/OAuthControl.resx b/ShareX.UploadersLib/Controls/OAuthControl.resx index c29220aec..cc21c6277 100644 --- a/ShareX.UploadersLib/Controls/OAuthControl.resx +++ b/ShareX.UploadersLib/Controls/OAuthControl.resx @@ -125,6 +125,10 @@ 16, 160 + + + 3, 0, 0, 0 + 288, 23 @@ -134,6 +138,9 @@ Clear authorization + + MiddleLeft + btnClearAuthorization @@ -152,6 +159,9 @@ 16, 192 + + 3, 0, 0, 0 + 288, 23 @@ -161,6 +171,9 @@ Refresh authorization + + MiddleLeft + btnRefreshAuthorization @@ -176,6 +189,9 @@ 16, 24 + + 3, 0, 0, 0 + 288, 23 @@ -185,6 +201,9 @@ Step 1: Open authorize page... + + MiddleLeft + btnOpenAuthorizePage @@ -201,16 +220,16 @@ True - 13, 56 + 14, 56 - 292, 13 + 89, 13 1 - Verification code (Get verification code from authorize page): + Verification code: lblVerificationCode @@ -230,6 +249,9 @@ 16, 104 + + 3, 0, 0, 0 + 288, 23 @@ -239,6 +261,9 @@ Step 2: Complete authorization + + MiddleLeft + btnCompleteAuthorization @@ -276,7 +301,7 @@ True - 13, 136 + 14, 136 37, 13 diff --git a/ShareX/Forms/MainForm.resx b/ShareX/Forms/MainForm.resx index ed7e231aa..d4d678c94 100644 --- a/ShareX/Forms/MainForm.resx +++ b/ShareX/Forms/MainForm.resx @@ -1523,7 +1523,7 @@ ShareX - + @Invariant True @@ -1544,7 +1544,7 @@ ShareX - + @Invariant chFilename diff --git a/ShareX/Properties/Resources.tr.resx b/ShareX/Properties/Resources.tr.resx index e2f5c2ef3..353e568ce 100644 --- a/ShareX/Properties/Resources.tr.resx +++ b/ShareX/Properties/Resources.tr.resx @@ -422,4 +422,7 @@ Lütfen başka bir kısayol seçin veya çakışan uygulamayı kapatın ve Share Bildirim alanındaki ShareX simgesine orta tuş ile tıklıyarak dikdörtgen yakalama başlatabilirsiniz. + + Adresi kopyalamak için sol tıklayın. Adresi açmak için sağ tıklayın. + \ No newline at end of file