mirror of
https://github.com/ShareX/ShareX.git
synced 2024-10-01 09:47:22 +13:00
Text watermark context menu to show name parsing shortcuts
This commit is contained in:
parent
73bdd05527
commit
405ee48d30
4 changed files with 83 additions and 1 deletions
|
@ -90,5 +90,38 @@ public static ContextMenuStrip Create<TEntry>(TextBox tb, params TEntry[] ignore
|
||||||
|
|
||||||
return cms;
|
return cms;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static ContextMenuStrip Create<TEntry>(params TEntry[] ignoreList)
|
||||||
|
where TEntry : CodeMenuEntry
|
||||||
|
{
|
||||||
|
ContextMenuStrip cms = new ContextMenuStrip
|
||||||
|
{
|
||||||
|
Font = new Font("Lucida Console", 8),
|
||||||
|
AutoClose = true,
|
||||||
|
Opacity = 0.9,
|
||||||
|
ShowImageMargin = false
|
||||||
|
};
|
||||||
|
|
||||||
|
var variables = Helpers.GetValueFields<TEntry>().Where(x => !ignoreList.Contains(x)).
|
||||||
|
Select(x => new
|
||||||
|
{
|
||||||
|
Name = x.ToPrefixString(),
|
||||||
|
Description = x.Description
|
||||||
|
});
|
||||||
|
|
||||||
|
foreach (var variable in variables)
|
||||||
|
{
|
||||||
|
ToolStripMenuItem tsmi = new ToolStripMenuItem { Text = string.Format("{0} - {1}", variable.Name, variable.Description), Tag = variable.Name };
|
||||||
|
cms.Items.Add(tsmi);
|
||||||
|
}
|
||||||
|
|
||||||
|
cms.Items.Add(new ToolStripSeparator());
|
||||||
|
|
||||||
|
ToolStripMenuItem tsmiClose = new ToolStripMenuItem(Resources.CodeMenu_Create_Close);
|
||||||
|
tsmiClose.Click += (sender, e) => cms.Close();
|
||||||
|
cms.Items.Add(tsmiClose);
|
||||||
|
|
||||||
|
return cms;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -253,6 +253,7 @@
|
||||||
<Compile Include="Cryptographic\HashCheck.cs" />
|
<Compile Include="Cryptographic\HashCheck.cs" />
|
||||||
<Compile Include="Cryptographic\Translator.cs" />
|
<Compile Include="Cryptographic\Translator.cs" />
|
||||||
<Compile Include="Cryptographic\TranslatorHelper.cs" />
|
<Compile Include="Cryptographic\TranslatorHelper.cs" />
|
||||||
|
<Compile Include="UITypeEditors\NameParserEditor.cs" />
|
||||||
<Compile Include="UnsafeBitmap.cs" />
|
<Compile Include="UnsafeBitmap.cs" />
|
||||||
<Compile Include="UpdateChecker\GitHubUpdateChecker.cs" />
|
<Compile Include="UpdateChecker\GitHubUpdateChecker.cs" />
|
||||||
<Compile Include="UpdateChecker\UpdateChecker.cs" />
|
<Compile Include="UpdateChecker\UpdateChecker.cs" />
|
||||||
|
|
48
HelpersLib/UITypeEditors/NameParserEditor.cs
Normal file
48
HelpersLib/UITypeEditors/NameParserEditor.cs
Normal file
|
@ -0,0 +1,48 @@
|
||||||
|
#region License Information (GPL v3)
|
||||||
|
|
||||||
|
/*
|
||||||
|
ShareX - A program that allows you to take screenshots and share any file type
|
||||||
|
Copyright (C) 2007-2014 ShareX Developers
|
||||||
|
|
||||||
|
This program is free software; you can redistribute it and/or
|
||||||
|
modify it under the terms of the GNU General Public License
|
||||||
|
as published by the Free Software Foundation; either version 2
|
||||||
|
of the License, or (at your option) any later version.
|
||||||
|
|
||||||
|
This program is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with this program; if not, write to the Free Software
|
||||||
|
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
|
|
||||||
|
Optionally you can also view the license at <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#endregion License Information (GPL v3)
|
||||||
|
|
||||||
|
using System;
|
||||||
|
using System.ComponentModel;
|
||||||
|
using System.Drawing;
|
||||||
|
using System.Drawing.Design;
|
||||||
|
using System.Windows.Forms;
|
||||||
|
|
||||||
|
namespace HelpersLib
|
||||||
|
{
|
||||||
|
public class NameParserEditor : UITypeEditor
|
||||||
|
{
|
||||||
|
public override UITypeEditorEditStyle GetEditStyle(ITypeDescriptorContext context)
|
||||||
|
{
|
||||||
|
return UITypeEditorEditStyle.Modal;
|
||||||
|
}
|
||||||
|
|
||||||
|
public override object EditValue(ITypeDescriptorContext context, IServiceProvider provider, object value)
|
||||||
|
{
|
||||||
|
Point pos = Cursor.Position;
|
||||||
|
CodeMenu.Create<ReplCodeMenuEntry>(ReplCodeMenuEntry.t, ReplCodeMenuEntry.pn).Show(pos.X, pos.Y);
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -57,7 +57,7 @@ public Point Offset
|
||||||
[DefaultValue(true), Description("If text watermark size bigger than source image then don't draw it.")]
|
[DefaultValue(true), Description("If text watermark size bigger than source image then don't draw it.")]
|
||||||
public bool AutoHide { get; set; }
|
public bool AutoHide { get; set; }
|
||||||
|
|
||||||
[DefaultValue("getsharex.com")]
|
[DefaultValue("getsharex.com"), Editor(typeof(NameParserEditor), typeof(UITypeEditor))]
|
||||||
public string Text { get; set; }
|
public string Text { get; set; }
|
||||||
|
|
||||||
private FontSafe textFontSafe = new FontSafe();
|
private FontSafe textFontSafe = new FontSafe();
|
||||||
|
|
Loading…
Reference in a new issue