本文整理汇总了C#中Shortcut类的典型用法代码示例。如果您正苦于以下问题:C# Shortcut类的具体用法?C# Shortcut怎么用?C# Shortcut使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Shortcut类属于命名空间,在下文中一共展示了Shortcut类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ConvertShortcutToString
public static string ConvertShortcutToString(Shortcut shortcut)
{
string shortcutString = Convert.ToString(shortcut);
StringBuilder result = new StringBuilder(shortcutString);
if (shortcutString.StartsWith("Alt"))
{
result.Insert(3, " + ");
}
else if (shortcutString.StartsWith("CtrlShift"))
{
result.Insert(9, " + ");
result.Insert(4, " + ");
}
else if (shortcutString.StartsWith("Ctrl"))
{
result.Insert(4, " + ");
}
else if (shortcutString.StartsWith("Shift"))
{
result.Insert(5, " + ");
}
return result.ToString();
}
示例2: TextShortcut
public TextShortcut(string methodName,
string shortName, string longName, Shortcut shortcut)
{
MethodName = methodName;
_shortcut = shortcut;
ShortName = shortName;
LongName = longName;
}
示例3: Initialize
private void Initialize(Bitmap bitmap, Shortcut shortcut, EventHandler handler, ImageList list, int imageIndex)
{
OwnerDraw = true;
this.Shortcut = shortcut;
icon = bitmap;
clickHandler = handler;
imageList = list;
this.imageIndex = imageIndex;
}
示例4: ConfigurationUICommand
/// <summary>
/// Initialize a new instance of the <see cref="ConfigurationUICommand"/> class.
/// </summary>
/// <param name="serviceProvider">The a mechanism for retrieving a service object; that is, an object that provides custom support to other objects.</param>
/// <param name="text">The text for the command.</param>
/// <param name="longText">The text that will be in the status bar.</param>
/// <param name="commandState">One of the <see cref="CommandState"/> values.</param>
/// <param name="command">The command to execute.</param>
/// <param name="shortcut">A short cut for the command.</param>
/// <param name="insertionPoint">One of the <see cref="InsertionPoint"/> values.</param>
/// <param name="icon">The icon for the command.</param>
public ConfigurationUICommand(IServiceProvider serviceProvider, string text,
string longText, CommandState commandState,
ConfigurationNodeCommand command, Shortcut shortcut,
InsertionPoint insertionPoint, Icon icon)
: this(serviceProvider,
text, longText, commandState, NodeMultiplicity.Allow, command, null,
shortcut, insertionPoint, icon)
{
}
示例5: ShortcutToString
private static string ShortcutToString(Shortcut shortcut)
{
if (shortcut != Shortcut.None)
{
Keys keys = (Keys)shortcut;
return TypeDescriptor.GetConverter(keys.GetType()).ConvertToString(keys);
}
return null;
}
示例6: RegisterHotkey
protected bool RegisterHotkey(Shortcut key)
{ //register hotkey
int mod=0;
Keys k2=Keys.None;
if (((int)key & (int)Keys.Alt)==(int)Keys.Alt) {mod+=(int)Win32.Modifiers.MOD_ALT;k2=Keys.Alt;}
if (((int)key & (int)Keys.Shift)==(int)Keys.Shift) {mod+=(int)Win32.Modifiers.MOD_SHIFT;k2=Keys.Shift;}
if (((int)key & (int)Keys.Control)==(int)Keys.Control) {mod+=(int)Win32.Modifiers.MOD_CONTROL;k2=Keys.Control;}
System.Diagnostics.Debug.Write(mod.ToString()+" ");
System.Diagnostics.Debug.WriteLine((((int)key)-((int)k2)).ToString());
return Win32.User32.RegisterHotKey(m_Window.Handle,this.GetType().GetHashCode(),(int)mod,((int)key)-((int)k2));
}
示例7: AddMenuItem
private static MenuItem AddMenuItem(
Menu menu, string text, EventHandler handler, object context,
Shortcut shortcut = Shortcut.None)
{
var item = new MenuItem(text, handler)
{
Tag = context,
Shortcut = shortcut,
ShowShortcut = shortcut != Shortcut.None
};
menu.MenuItems.Add(item);
return item;
}
示例8: ConfigurationMenuItem
/// <summary>
/// <para>Initializes a new instance of the class with a specified caption, event handler, associated shortcut key, icon, status bar text, and the insertion point for the menu item.</para>
/// </summary>
/// <param name="text">
/// <para>The caption for the menu item.</para>
/// </param>
/// <param name="command">
/// <para>The <see cref="ConfigurationNodeCommand"/> to execute.</para>
/// </param>
/// <param name="node">
/// <para>The <see cref="ConfigurationNode"/> to execute the command upon.</para>
/// </param>
/// <param name="shortcut">
/// <para>One of the <see cref="Shortcut"/> values.</para>
/// </param>
/// <param name="statusBarText">
/// <para>The text for the status bar.</para>
/// </param>
/// <param name="insertionPoint">
/// <para>One of the <see cref="InsertionPoint"/> values.</para>
/// </param>
public ConfigurationMenuItem(string text, ConfigurationNodeCommand command, ConfigurationNode node, Shortcut shortcut, string statusBarText, InsertionPoint insertionPoint)
: base(text, null, shortcut)
{
if (command == null)
{
throw new ArgumentNullException("command");
}
if (node == null)
{
throw new ArgumentNullException("node");
}
this.statusBarText = statusBarText;
this.insertionPoint = insertionPoint;
this.command = command;
this.node = node;
}
示例9: MenuItem
public MenuItem(MenuMerge mergeType, int mergeOrder, Shortcut shortcut,
String text, EventHandler onClick, EventHandler onPopup,
EventHandler onSelect, MenuItem[] items)
: base(items)
{
this.flags = ItemFlags.Default;
this.mergeType = mergeType;
this.mergeOrder = mergeOrder;
this.shortcut = shortcut;
this.text = text;
if(onClick != null)
{
Click += onClick;
}
if(onPopup != null)
{
Popup += onPopup;
}
if(onSelect != null)
{
Select += onSelect;
}
}
示例10: MenuCommand
public MenuCommand(string text, Shortcut shortcut, EventHandler clickHandler)
{
InternalConstruct(text, null, -1, shortcut, clickHandler);
}
示例11: ToolBarItem
public ToolBarItem(Image image, string text, EventHandler clickHandler, Shortcut shortcut)
{
Initialize(image, text, clickHandler, shortCut, null);
}
示例12: MxMenuItem
public MxMenuItem(string text, string helpText, Shortcut shortcut)
: base(MenuMerge.Add, 0, shortcut, text, null, null, null, null)
{
this._helpText = helpText;
if (shortcut != Shortcut.None)
{
this._shortcutText = TypeDescriptor.GetConverter(typeof(Keys)).ConvertToString((Keys) shortcut);
}
base.OwnerDraw = true;
}
示例13: ShouldIgnore
public bool ShouldIgnore(Shortcut shortcut)
{
if (maskedShortcuts != null && maskedShortcuts.Contains(shortcut))
return true;
return false;
}
示例14: Execute
public override void Execute(DirectoryInfo targetDirectory, PortableEnvironment portableEnvironment)
{
var shortcut = new Shortcut
{
FileName = Path.Combine(portableEnvironment.Shortcuts.StartMenuTargetDirectory, FileName),
Target = Path.Combine(targetDirectory.FullName, Target),
Arguments = Arguments,
WorkingDirectory = string.IsNullOrWhiteSpace(WorkingDirectory) ? null : Path.Combine(targetDirectory.FullName, WorkingDirectory),
IconPath = string.IsNullOrWhiteSpace(IconPath) ? null : Path.Combine(targetDirectory.FullName, IconPath),
DisplayMode = DisplayMode,
Description = Description,
};
// Create the link file.
portableEnvironment.Shortcuts.Add(shortcut);
}
示例15: IgnoreShortcut
/// <summary>
/// Instructs the command manager to ignore the shortcut until
/// UnignoreShortcut is called.
///
/// LIMITATION: You cannot currently ignore an AdvancedShortcut
/// (i.e. one based on Keys instead of Shortcut).
/// </summary>
public void IgnoreShortcut(Shortcut shortcut)
{
if (maskedShortcuts == null)
maskedShortcuts = new HashSet();
bool isNewElement = maskedShortcuts.Add(shortcut);
Debug.Assert(isNewElement, "Shortcut " + shortcut + " was already masked");
}