本文整理汇总了C#中System.Windows.Input.KeyGesture类的典型用法代码示例。如果您正苦于以下问题:C# KeyGesture类的具体用法?C# KeyGesture怎么用?C# KeyGesture使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
KeyGesture类属于System.Windows.Input命名空间,在下文中一共展示了KeyGesture类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: PadWindow
public PadWindow()
{
InitializeComponent();
KeyGesture F5Key = new KeyGesture(Key.F5, ModifierKeys.None);
KeyBinding F5CmdKeybinding = new KeyBinding(RunRoutedCommand, F5Key);
this.InputBindings.Add(F5CmdKeybinding);
}
开发者ID:hikaruyh88,项目名称:Projects,代码行数:7,代码来源:PadWindow.xaml.cs
示例2: MainWindow
// -------------------------------
// Window operations
// -------------------------------
/// <summary>
/// (Constructor) Initializes main window and sets up shortcut keys.
/// </summary>
public MainWindow()
{
InitializeComponent();
// Bind "New" command
CommandBinding cb = new CommandBinding( commandNew , new_Executed );
KeyGesture kg = new KeyGesture( Key.N , ModifierKeys.Control );
InputBinding ib = new InputBinding( commandNew , kg );
this.CommandBindings.Add( cb );
this.InputBindings.Add( ib );
// Bind "Open" command
cb = new CommandBinding( commandOpen , open_Executed );
kg = new KeyGesture( Key.O , ModifierKeys.Control );
ib = new InputBinding( commandOpen , kg );
this.CommandBindings.Add( cb );
this.InputBindings.Add( ib );
// Bind "Save" command
cb = new CommandBinding( commandSave , save_Executed );
kg = new KeyGesture( Key.S , ModifierKeys.Control );
ib = new InputBinding( commandSave , kg );
this.CommandBindings.Add( cb );
this.InputBindings.Add( ib );
// Bind "SaveAll" command
cb = new CommandBinding( commandSaveAll , saveAll_Executed );
kg = new KeyGesture( Key.S , ModifierKeys.Alt );
ib = new InputBinding( commandSaveAll , kg );
this.CommandBindings.Add( cb );
this.InputBindings.Add( ib );
// Bind "Exit" command
cb = new CommandBinding( commandExit , exit_Executed );
kg = new KeyGesture( Key.X , ModifierKeys.Control );
ib = new InputBinding( commandExit , kg );
this.CommandBindings.Add( cb );
this.InputBindings.Add( ib );
// Bind "Delete" command
cb = new CommandBinding( commandDelete , deleteBlock_Executed );
kg = new KeyGesture( Key.Delete );
ib = new InputBinding( commandDelete , kg );
this.CommandBindings.Add( cb );
this.InputBindings.Add( ib );
// Bind "Generate Mesh" command
cb = new CommandBinding( commandGenerateMesh , generateMesh_Executed );
kg = new KeyGesture( Key.F7 );
ib = new InputBinding( commandGenerateMesh , kg );
this.CommandBindings.Add( cb );
this.InputBindings.Add( ib );
// Bind "Run Analysis" command
cb = new CommandBinding( commandRunAnalysis , run_Executed );
kg = new KeyGesture( Key.F5 );
ib = new InputBinding( commandRunAnalysis , kg );
this.CommandBindings.Add( cb );
this.InputBindings.Add( ib );
}
开发者ID:karcheba,项目名称:SlopeFEA,代码行数:66,代码来源:MainWindow.xaml.cs
示例3: MWindow
public MWindow()
{
try
{
InitializeComponent();
Closing += new CancelEventHandler(MWindow_Closing);
worker.DoWork += new DoWorkEventHandler(worker_DoWork);
worker.RunWorkerCompleted += new RunWorkerCompletedEventHandler(worker_RunWorkerCompleted);
dt.Interval = TimeSpan.FromSeconds(1);
dt.Tick += new EventHandler(dt_Tick);
foldingManager = FoldingManager.Install(textEditor.TextArea);
foldingStrategy = new XmlFoldingStrategy();
textEditor.TextChanged += new EventHandler(textEditor_TextChanged);
if (App.StartUpCommand != "" && App.StartUpCommand != null)
{
openFile(App.StartUpCommand);
}
KeyGesture renderKeyGesture = new KeyGesture(Key.F5);
KeyBinding renderCmdKeybinding = new KeyBinding(Commands.Render, renderKeyGesture);
this.InputBindings.Add(renderCmdKeybinding);
status.Text = "Ready!";
}
catch (Exception e)
{
MessageBox.Show(e.Message);
}
}
开发者ID:JointJBA,项目名称:DisqueEngine,代码行数:27,代码来源:MWindow.xaml.cs
示例4: RegisterShortcut
/// <summary>Registers a given shortcut for a specific views and connect that shortcut with a given action.</summary>
/// <param name="viewTypes">The view types.</param>
/// <param name="gesture">The shortcut.</param>
/// <param name="command">The command.</param>
public static void RegisterShortcut(Type[] viewTypes, KeyGesture gesture, ICommand command)
{
Contract.Requires(command != null);
foreach (var type in viewTypes)
RegisterShortcut(type, gesture, command);
}
开发者ID:yukiyuki,项目名称:MyToolkit,代码行数:11,代码来源:ShortcutManager.cs
示例5: AbstractMenuItem
public AbstractMenuItem(string header, int priority, ImageSource icon = null, ICommand command = null,
KeyGesture gesture = null, bool isCheckable = false)
{
Priority = priority;
IsSeparator = false;
Header = header;
Key = header;
Command = command;
IsCheckable = isCheckable;
Icon = icon;
if (gesture != null && command != null)
{
Application.Current.MainWindow.InputBindings.Add(new KeyBinding(command, gesture));
InputGestureText = gesture.DisplayString;
}
if (isCheckable)
{
IsChecked = false;
}
if (Header == "SEP")
{
Key = "SEP" + sepCount.ToString();
Header = "";
sepCount++;
IsSeparator = true;
}
}
开发者ID:vinodj,项目名称:Wide,代码行数:27,代码来源:AbstractMenuItem.cs
示例6: SetGesture
/// <summary>
/// Sets the gesture property.
/// </summary>
/// <param name="element">The element.</param>
/// <param name="value">The value.</param>
public static void SetGesture(UIElement element, KeyGesture value)
{
if (element != null)
{
element.SetValue(GestureProperty, value);
}
}
开发者ID:yovannyr,项目名称:PropertyTools,代码行数:12,代码来源:ScreenGrab.cs
示例7: RelayCommand
/// <summary>
/// Initializes a new instance of the <see cref="RelayCommand"/> class.
/// </summary>
/// <param name="kg">The associated <see cref="KeyGesture"/>.</param>
/// <param name="registeredType">Type of the registered command.</param>
/// <param name="execute">The action to execute.</param>
/// <param name="canExecute">The predicate that determines if the command can be executed.</param>
/// <example>
/// <code><![CDATA[
/// var cmd = new RelayCommand(new KeyGesture(Key.F7), typeof(DesignerItemWithData),
/// this.CommandNameExecuted, this.CommandNameEnabled);
/// ]]>
/// </code>
/// </example>
public RelayCommand(KeyGesture kg, Type registeredType, Action<object> execute, Predicate<object> canExecute)
{
this.execute = execute;
this.canExecute = canExecute;
this.InputGestures.Add(kg);
InputBinding ib = new InputBinding(this, kg);
CommandManager.RegisterClassInputBinding(registeredType, ib);
}
开发者ID:Jedzia,项目名称:BackBock,代码行数:22,代码来源:RelayCommand.cs
示例8: CommandMenuItem
public CommandMenuItem(Command command, StandardMenuItem parent)
{
_command = command;
_keyGesture = IoC.Get<ICommandKeyGestureService>().GetPrimaryKeyGesture(_command.CommandDefinition);
_parent = parent;
_listItems = new List<StandardMenuItem>();
}
开发者ID:DraTeots,项目名称:gemini,代码行数:8,代码来源:CommandMenuItem.cs
示例9: RegisterShortcut
/// <summary>
/// Registers a given shortcut for a specific views and connect that shortcut with a given action.
/// </summary>
/// <param name="viewTypes">The view types.</param>
/// <param name="gesture">The shortcut.</param>
/// <param name="command">The command.</param>
public static void RegisterShortcut(Type[] viewTypes, KeyGesture gesture, ICommand command)
{
if (command == null)
throw new ArgumentNullException(nameof(command));
foreach (var type in viewTypes)
RegisterShortcut(type, gesture, command);
}
开发者ID:zhangz,项目名称:Toolbox,代码行数:14,代码来源:ShortcutManager.cs
示例10: Command
public Command(CommandDefinitionBase commandDefinition)
{
_commandDefinition = commandDefinition;
Text = commandDefinition.Text;
ToolTip = commandDefinition.ToolTip;
IconSource = commandDefinition.IconSource;
_keyGesture = commandDefinition.KeyGesture;
}
开发者ID:danjmackay,项目名称:gemini,代码行数:8,代码来源:Command.cs
示例11: CommandToolBarItem
public CommandToolBarItem(ToolBarItemDefinition toolBarItem, Command command, IToolBar parent)
{
_toolBarItem = toolBarItem;
_command = command;
_keyGesture = IoC.Get<ICommandKeyGestureService>().GetPrimaryKeyGesture(_command.CommandDefinition);
_parent = parent;
command.PropertyChanged += OnCommandPropertyChanged;
}
开发者ID:DraTeots,项目名称:gemini,代码行数:9,代码来源:CommandToolBarItem.cs
示例12: TestWindow
public TestWindow()
{
this.InitializeComponent();
CommandBinding cb = new CommandBinding(MyCommand, MyCommandExecute);
this.CommandBindings.Add(cb);
KeyGesture kg = new KeyGesture(Key.Escape, ModifierKeys.Shift);
InputBinding ib = new InputBinding(MyCommand, kg);
this.InputBindings.Add(ib);
}
开发者ID:kaszuster,项目名称:BattleShip,代码行数:10,代码来源:TestWindow.xaml.cs
示例13: CreateInputGesture
/// <summary>
/// Creates the input gesture.
/// </summary>
/// <param name="element">The element.</param>
/// <param name="key">The key to listen to.</param>
/// <param name="modifierKeys">The modifier keys to listen to.</param>
/// <param name="execute">The command to execute.</param>
/// <param name="canExecute">The command to check if the main command can execute.</param>
public static void CreateInputGesture(this UIElement element, Key key, ModifierKeys modifierKeys, ExecutedRoutedEventHandler execute, CanExecuteRoutedEventHandler canExecute)
{
var command = new RoutedUICommand();
var binding = new CommandBinding(command, execute, canExecute);
var gesture = new KeyGesture(key, modifierKeys);
var keyBinding = new KeyBinding(command, gesture);
element.CommandBindings.Add(binding);
element.InputBindings.Add(keyBinding);
}
开发者ID:StevenThuriot,项目名称:Saber,代码行数:19,代码来源:UIElementExtensions.cs
示例14: MainWindow
public MainWindow()
{
InitializeComponent();
RootFrame.NavigationService.Navigate(new Uri("/Pages/MainPage.xaml", UriKind.Relative));
var timestampCommand = new DelegateCommand(OnTimestampKeyBinding);
var timestampGesture = new KeyGesture(Key.T, ModifierKeys.Alt);
var timestampBinding = new KeyBinding(timestampCommand, timestampGesture);
InputBindings.Add(timestampBinding);
}
开发者ID:roberdjp,项目名称:lastfm,代码行数:11,代码来源:MainWindow.xaml.cs
示例15: SaveAsMenuItemViewModel
/// <summary>
/// Initializes a new instance of the <see cref="MenuItemViewModel" /> class.
/// </summary>
/// <param name="header">The header.</param>
/// <param name="priority">The priority.</param>
/// <param name="icon">The icon.</param>
/// <param name="command">The command.</param>
/// <param name="gesture">The gesture.</param>
/// <param name="isCheckable">if set to <c>true</c> this menu acts as a checkable menu.</param>
/// <param name="hideDisabled">if set to <c>true</c> this menu is not visible when disabled.</param>
/// <param name="container">The container.</param>
public SaveAsMenuItemViewModel(string header, int priority, ImageSource icon = null, ICommand command = null,
KeyGesture gesture = null, bool isCheckable = false, bool hideDisabled = false,
IUnityContainer container = null)
: base(header, priority, icon, command, gesture, isCheckable, hideDisabled)
{
if (container != null)
{
var eventAggregator = container.Resolve<IEventAggregator>();
eventAggregator.GetEvent<ActiveContentChangedEvent>().Subscribe(SaveAs);
}
}
开发者ID:chandramouleswaran,项目名称:Hypertest,代码行数:22,代码来源:SaveAsMenuItemViewModel.cs
示例16: OnHotkeyChanged
private void OnHotkeyChanged(KeyGesture hotkey)
{
if (hotkey == null)
//Subscription will be recreated by static property watcher
Stop();
else
{
Unregister();
_hotkey = hotkey;
Register();
}
}
开发者ID:CarlSosaDev,项目名称:Avalonia,代码行数:12,代码来源:HotkeyManager.cs
示例17: MainWindow
public MainWindow()
{
this.InitializeComponent();
PlaySound();
frame = mainFrame;
CommandBinding cb = new CommandBinding(GameMenuCommand, GameMenuExecute);
this.CommandBindings.Add(cb);
KeyGesture kg = new KeyGesture(Key.Escape, ModifierKeys.Shift);
InputBinding ib = new InputBinding(GameMenuCommand, kg);
this.InputBindings.Add(ib);
GameMenu.LockElement = LayoutRoot;
}
开发者ID:kaszuster,项目名称:BattleShip,代码行数:13,代码来源:MainWindow.xaml.cs
示例18: KeyGestureExtension
/// <summary>
/// Initializes a new instance of the <see cref="KeyGestureExtension"/> class with a string representing the gesture.
/// </summary>
/// <param name="gesture">A string representing the gesture.</param>
public KeyGestureExtension(string gesture)
{
var modifiers = ModifierKeys.None;
var tokens = gesture.Split('+');
for (int i = 0; i < tokens.Length - 1; ++i)
{
var token = tokens[i].Replace("Ctrl", "Control");
var modifier = (ModifierKeys)Enum.Parse(typeof(ModifierKeys), token, true);
modifiers |= modifier;
}
var key = (Key)Enum.Parse(typeof(Key), tokens[tokens.Length - 1], true);
Gesture = new KeyGesture(key, modifiers);
}
开发者ID:cg123,项目名称:xenko,代码行数:17,代码来源:KeyGestureExtension.cs
示例19: Add
public void Add(Icon icon, string text, Action action, KeyGesture gesture)
{
var screenAction = new ScreenAction()
{
Binding = new InputBinding(new ActionCommand(action), gesture),
Icon = icon,
Name = text
};
InputBindings.Add(screenAction.Binding);
var item = CommandMenuItem.Build(screenAction);
item.StaysOpenOnClick = true;
Items.Add(item);
}
开发者ID:adymitruk,项目名称:storyteller,代码行数:15,代码来源:OutlineGrammarSelector.cs
示例20: RecentMenuItemViewModel
public RecentMenuItemViewModel(string header, int priority, IUnityContainer container = null, ImageSource icon = null,
ICommand command = null, KeyGesture gesture = null, bool isCheckable = false)
: base(header, priority, icon, command, gesture, isCheckable)
{
if (container != null)
{
_containerWeak = new GenericWeakReference<IUnityContainer>(container);
IFileHistoryService service = _containerWeak.Get().Resolve<IFileHistoryService>();
if (service != null)
{
_historyServWeak = new GenericWeakReference<IFileHistoryService>(service);
_historyServWeak.Get().RecentChanged += RecentMenuItemViewModel_RecentChanged;
}
}
}
开发者ID:OleksandrKulchytskyi,项目名称:MyFirstMEF,代码行数:15,代码来源:MenuItemViewModel.cs
注:本文中的System.Windows.Input.KeyGesture类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论