當前位置: 首頁>>代碼示例>>C#>>正文


C# Input.KeyGesture類代碼示例

本文整理匯總了C#中System.Windows.Input.KeyGesture的典型用法代碼示例。如果您正苦於以下問題:C# KeyGesture類的具體用法?C# KeyGesture怎麽用?C# KeyGesture使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


KeyGesture類屬於System.Windows.Input命名空間,在下文中一共展示了KeyGesture類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的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


注:本文中的System.Windows.Input.KeyGesture類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。