// ------------------------------- // 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 ); }
/// <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); }
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); }
public static void RegisterHotkeys(Map pMap) { var mMgrsHotkey = new MapCoordinateCopyPasteCommand(CoordinateKind.Mgrs); InputBinding ib = new InputBinding(mMgrsHotkey, new KeyGesture(Key.M, ModifierKeys.Shift | ModifierKeys.Control)); pMap.InputBindings.Add(ib); var mLatLonHotkey = new MapCoordinateCopyPasteCommand(CoordinateKind.LatLon); InputBinding ib1 = new InputBinding(mLatLonHotkey, new KeyGesture(Key.L, ModifierKeys.Shift | ModifierKeys.Control)); pMap.InputBindings.Add(ib1); }
void initKeyBindings() { // Bind Key InputBinding ib = new InputBinding( CommandSet.ToggleConsole, new KeyGesture(Key.OemTilde, ModifierKeys.Control)); this.InputBindings.Add(ib); // Bind handler CommandBinding cb = new CommandBinding(CommandSet.ToggleConsole); cb.Executed += new ExecutedRoutedEventHandler(OnToggleConsole); this.CommandBindings.Add(cb); }
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; }
List<InputBinding> Load(CommandContext ctx) { var result = new List<InputBinding>(); foreach (var cmd in ctx.Commands.OfType<RelayCommandModel>() .Where(p => (p.Usage & CommandUsage.KeyBinding) == CommandUsage.KeyBinding)) { foreach (InputGesture g in cmd.InputGestures) { InputBinding binding = new InputBinding((System.Windows.Input.ICommand)cmd, g); result.Add(binding); } } return result; }
public MainWindow() { InitializeComponent(); button1.Command = MyTestCommand(); var copyCommandBinding = new CommandBinding(MyTestCommand()); copyCommandBinding.Executed += OnCopyExecuted; this.CommandBindings.Add(copyCommandBinding); var inputBinding = new InputBinding(MyTestCommand(), new KeyGesture(Key.R, ModifierKeys.Control)); this.InputBindings.Add(inputBinding); }
public LauncherWindow() { Initialized += LauncherInitialized; InitializeComponent(); DebugWindowCommand.InputGestures.Add(new KeyGesture(Key.D, ModifierKeys.Control)); var cb = new CommandBinding(DebugWindowCommand, MyCommandExecute, MyCommandCanExecute); CommandBindings.Add(cb); var kg = new KeyGesture(Key.M, ModifierKeys.Control); var ib = new InputBinding(DebugWindowCommand, kg); InputBindings.Add(ib); ConstructAnim(); }
public DWindow() { InitializeComponent(); Color color = Color.FromRgb(0x00, 0x00, 0x00); _turnBrush = new SolidColorBrush(color); _turnBrush.Freeze(); DebugWindowCommand.InputGestures.Add(new KeyGesture(Key.D, ModifierKeys.Control)); var cb = new CommandBinding(DebugWindowCommand, MyCommandExecute, MyCommandCanExecute); CommandBindings.Add(cb); var kg = new KeyGesture(Key.M, ModifierKeys.Control); var ib = new InputBinding(DebugWindowCommand, kg); InputBindings.Add(ib); }
public void InitilizeBindings() { //Playback Go CommandBinding bindingPlaybackGO = new CommandBinding(_playbackGO, _mainWindow.CommandBinding_PlaybackGo_Executed, _mainWindow.CommandBinding_PlaybackGO_CanExecute); _mainWindow.CommandBindings.Add(bindingPlaybackGO); _mainWindow.playbackGO.Command = _playbackGO; KeyGesture keyGuestureGO = new KeyGesture(Key.Space); InputBinding inputBindingGO = new InputBinding(_playbackGO, keyGuestureGO); _mainWindow.InputBindings.Add(inputBindingGO); //Playback Fade CommandBinding bindingPlaybackFADE = new CommandBinding(_playbackFADE, _mainWindow.CommandBinding_PlaybackFADE_Executed, _mainWindow.CommandBinding_PlaybackFADE_CanExecute); _mainWindow.CommandBindings.Add(bindingPlaybackFADE); _mainWindow.playbackGO.Command = _playbackGO; KeyGesture keyGuestureFADE = new KeyGesture(Key.F); InputBinding inputBindingFADE = new InputBinding(_playbackFADE, keyGuestureFADE); _mainWindow.InputBindings.Add(inputBindingFADE); }
public MainWindow() { InitializeComponent(); selector = new TabSelector(editSpace, tabs); editSpace.Visibility = System.Windows.Visibility.Hidden; cmbFontFamily.ItemsSource = Fonts.SystemFontFamilies.OrderBy(f => f.Source); cmbFontSize.ItemsSource = new List<double>() { 8, 9, 10, 11, 12, 14, 16, 18, 20, 22, 24, 26, 28, 36, 48, 72 }; CommandBinding cb = new CommandBinding(MyCommand, SelectAllExecute, SelectAllCanExecute); KeyGesture gest = new KeyGesture(Key.A, ModifierKeys.Control); InputBinding ib = new InputBinding(MyCommand, gest); this.InputBindings.Add(ib); editSpace.Document = new FlowDocument(); editSpace.SelectAll(); editSpace.Selection.Text = ""; }
public Main() { this.Initialized += Main_Initialized; InitializeComponent(); //Set title with version info. Version version = System.Reflection.Assembly.GetExecutingAssembly().GetName().Version; this.Title = "OCTGN verson " + version.ToString(); frame1.Navigate(new ContactList()); DebugWindowCommand.InputGestures.Add(new KeyGesture(Key.D, ModifierKeys.Control)); CommandBinding cb = new CommandBinding(DebugWindowCommand, MyCommandExecute, MyCommandCanExecute); this.CommandBindings.Add(cb); KeyGesture kg = new KeyGesture(Key.M, ModifierKeys.Control); InputBinding ib = new InputBinding(DebugWindowCommand, kg); this.InputBindings.Add(ib); Program.lobbyClient.OnFriendRequest += new LobbyClient.FriendRequest(lobbyClient_OnFriendRequest); Program.lobbyClient.OnDisconnect += new EventHandler(lobbyClient_OnDisconnectEvent); Program.lobbyClient.OnUserStatusChanged += new LobbyClient.UserStatusChanged(lobbyClient_OnUserStatusChanged); Program.lobbyClient.Chatting.eChatEvent += new Chatting.ChatEventDelegate(Chatting_eChatEvent); Program.lobbyClient.OnDataRecieved += new LobbyClient.DataRecieved(lobbyClient_OnDataRecieved); tbUsername.Text = Program.lobbyClient.Me.DisplayName; tbStatus.Text = Program.lobbyClient.Me.CustomStatus; _originalBorderBrush = NotificationTab.Background; System.Windows.Forms.ContextMenu cm = new System.Windows.Forms.ContextMenu(); cm.MenuItems.Add("Show", cmShow_Click).DefaultItem = true; cm.MenuItems.Add("Log Off", cmLogOff_Click); cm.MenuItems.Add("-"); cm.MenuItems.Add("Quit", cmQuit_Click); SystemTrayIcon = new System.Windows.Forms.NotifyIcon(); SystemTrayIcon.Icon = new System.Drawing.Icon("Resources/Icon.ico"); SystemTrayIcon.Visible = false; SystemTrayIcon.ContextMenu = cm; SystemTrayIcon.Text = "Octgn"; SystemTrayIcon.DoubleClick += new System.EventHandler(this.SystemTrayIcon_DoubleClick); // Insert code required on object creation below this point. }
/// <summary> /// キーボードショートカットを初期化、登録する /// </summary> private void InitializeKeyboardShortcut() { if (Settings.Default.KeyMapping == null) { if (KeyMapping.KeyMappings.Count == 0) { return; } var keyMapping = KeyMapping.GetKeyMapping(0); Settings.Default.KeyMapping = keyMapping.Name; Settings.Default.KeyBindings.Clear(); foreach (var item in keyMapping.KeyBindings) { Settings.Default.KeyBindings.Add(item); } } InputBindings.Clear(); TweetTextBox.InputBindings.Clear(); TimelineTabControl.InputBindings.Clear(); foreach (var keyBinding in Settings.Default.KeyBindings) { if (keyBinding.Key == Key.None) { continue; } try { var inputBinding = new InputBinding(keyBinding.Action.ToCommand(), new KeyGesture(keyBinding.Key, keyBinding.ModifierKeys)); switch (keyBinding.ActionSpot) { case KeyActionSpot.All: InputBindings.Add(inputBinding); break; case KeyActionSpot.TweetTextBox: TweetTextBox.InputBindings.Add(inputBinding); break; case KeyActionSpot.Timeline: TimelineTabControl.InputBindings.Add(inputBinding); break; case KeyActionSpot.Global: //TODO:全局热键绑定 break; } } catch { keyBinding.Key = Key.None; keyBinding.ModifierKeys = ModifierKeys.None; } } }
public static void SetCommand(InputBinding obj, bool value) { obj.SetValue(CommandProperty, value); }
public int Add(InputBinding inputBinding) { return(default(int)); }
public static void RegisterClassInputBinding (Type type, InputBinding inputBinding) { throw new NotImplementedException (); }
public static bool GetCommand(InputBinding obj) { return (bool)obj.GetValue(CommandProperty); }
public void Insert(int index, InputBinding inputBinding) { }
/// <summary> /// Initialize CreateTagCommand /// </summary> private void InitializeCreateTagCommand() { RoutedCommand CreateTagCommand = new RoutedCommand(); CommandBinding cb = new CommandBinding(CreateTagCommand, CreateTagCommandExecute, CreateTagCommandCanExecute); CommandBindings.Add(cb); BtnCreate.Command = CreateTagCommand; KeyGesture kg = new KeyGesture(Key.N, ModifierKeys.Control); InputBinding ib = new InputBinding(CreateTagCommand, kg); InputBindings.Add(ib); }
public static void RegisterClassInputBinding(Type type, InputBinding inputBinding) { throw new NotImplementedException(); }
/// <summary> /// Initialize TagCommand /// </summary> private void InitializeTagCommand() { RoutedCommand TagCommand = new RoutedCommand(); CommandBinding cb = new CommandBinding(TagCommand, TagCommandExecute, TagCommandCanExecute); CommandBindings.Add(cb); btnTag.Command = TagCommand; KeyGesture kg = new KeyGesture(Key.T, ModifierKeys.Control); InputBinding ib = new InputBinding(TagCommand, kg); InputBindings.Add(ib); }
public bool Contains(InputBinding key) { return(default(bool)); }
void InputBinding_Removed(InputBinding inputBinding) { if (isAttached) textArea.InputBindings.Remove(inputBinding); }
private void RebuildBinding() { // TODO: is this safe? perhaps keep a ref to the main window var window = Application.Current.MainWindow; if (window == null) return; // Remove old bindings foreach (var binding in m_inputBindings) { window.InputBindings.Remove(binding); } // Add new bindings m_inputBindings = new List<InputBinding>(); for (int i = 0; i < m_inputGestures.Length; i++) { var binding = new InputBinding(this, m_inputGestures[i]); m_inputBindings.Add(binding); window.InputBindings.Add(binding); } }
public MainWindow(AppViewModel viewModel, IPluginRepository pluginRepository, IAccountSettingsProvider accountSettingsProvider, IColumnsSettingsProvider columnsSettingsProvider, IApplicationSettingsProvider applicationSettingsProvider, IEventAggregator eventAggregator) { InitializeComponent(); _pluginRepository = pluginRepository; _accountSettings = accountSettingsProvider; _columnsSettings = columnsSettingsProvider; _applicationSettingsProvider = applicationSettingsProvider; _eventAggregator = eventAggregator; var mainViewModel = viewModel.Model; var resourceViewModel = viewModel.Resources; txtUpdate.SetHeight((Double) FindResource("DefaultCompositionBoxHeight")); var c = (CompositionTextBox) txtUpdate.FindName("txtUpdateBox"); if (c != null) c.IsInlineReply = false; Model = mainViewModel; ResourcesViewModel = resourceViewModel; mainViewModel.View = this; DataContext = mainViewModel; GlobalWindows.MainWindow = this; try { if (TaskbarManager.IsPlatformSupported) TaskbarManager = TaskbarManager.Instance; } catch (Exception ex) { CompositionManager.Get<IExceptionReporter>().ReportHandledException(ex); } if (resourceViewModel.Views == null) return; //Import the XAML foreach (var r in resourceViewModel.Views) { Resources.MergedDictionaries.Add(r); } var ibShowSetup = new InputBinding(ShowSetup, new KeyGesture(Key.S, ModifierKeys.Control)); var ibShowScriptingConsole = new InputBinding(ShowScriptConsoleCommand, new KeyGesture(Key.S, ModifierKeys.Alt)); InputBindings.Add(ibShowSetup); InputBindings.Add(ibShowScriptingConsole); var cbShowSetup = new CommandBinding(ShowSetup); cbShowSetup.Executed += CbShowSetupExecuted; CommandBindings.Add(cbShowSetup); var scriptConsole = new CommandBinding(ShowScriptConsoleCommand); scriptConsole.Executed += ScriptConsoleVisible; CommandBindings.Add(scriptConsole); if (!DesignerProperties.GetIsInDesignMode(this)) { MahTweets.Configuration.WindowSettings.SetSave(this, true); } }
public int IndexOf(InputBinding value) { return(default(int)); }
private static void CreateCommandBindings() { // Create our generic ExecutedRoutedEventHandler. ExecutedRoutedEventHandler executeHandler = new ExecutedRoutedEventHandler(ExecutedRoutedEventHandler); // Create our generic QueryEnabledStatusHandler CanExecuteRoutedEventHandler queryEnabledHandler = new CanExecuteRoutedEventHandler(QueryEnabledHandler); // // Command: ViewThumbnails // Tells DocumentViewer to display thumbnails. _viewThumbnailsCommand = new RoutedUICommand(SR.Get(SRID.DocumentViewerViewThumbnailsCommandText), "ViewThumbnailsCommand", typeof(DocumentViewer), null); CommandHelpers.RegisterCommandHandler( typeof(DocumentViewer), _viewThumbnailsCommand, executeHandler, queryEnabledHandler); //no key gesture // // Command: FitToWidth // Tells DocumentViewer to zoom to the document width. _fitToWidthCommand = new RoutedUICommand( SR.Get(SRID.DocumentViewerViewFitToWidthCommandText), "FitToWidthCommand", typeof(DocumentViewer), null); CommandHelpers.RegisterCommandHandler(typeof(DocumentViewer), _fitToWidthCommand, executeHandler, queryEnabledHandler, new KeyGesture(Key.D2, ModifierKeys.Control)); // // Command: FitToHeight // Tells DocumentViewer to zoom to the document height. _fitToHeightCommand = new RoutedUICommand( SR.Get(SRID.DocumentViewerViewFitToHeightCommandText), "FitToHeightCommand", typeof(DocumentViewer), null); CommandHelpers.RegisterCommandHandler(typeof(DocumentViewer), _fitToHeightCommand, executeHandler, queryEnabledHandler); //no key gesture // // Command: MaxPagesAcross // Sets the MaxPagesAcross to the value provided. _fitToMaxPagesAcrossCommand = new RoutedUICommand( SR.Get(SRID.DocumentViewerViewFitToMaxPagesAcrossCommandText), "FitToMaxPagesAcrossCommand", typeof(DocumentViewer), null); CommandHelpers.RegisterCommandHandler(typeof(DocumentViewer), _fitToMaxPagesAcrossCommand, executeHandler, queryEnabledHandler); //no key gesture #region Library Commands // Command: ApplicationCommands.Find - Ctrl+F // Invokes DocumentViewer's Find dialog. CommandHelpers.RegisterCommandHandler(typeof(DocumentViewer), ApplicationCommands.Find, executeHandler, queryEnabledHandler); // // Command: ComponentCommands.ScrollPageUp - PageUp // Causes DocumentViewer to scroll a Viewport up. CommandHelpers.RegisterCommandHandler(typeof(DocumentViewer), ComponentCommands.ScrollPageUp, executeHandler, queryEnabledHandler, Key.PageUp); // // Command: ComponentCommands.ScrollPageDown - PageDown // Causes DocumentViewer to scroll a Viewport down. CommandHelpers.RegisterCommandHandler(typeof(DocumentViewer), ComponentCommands.ScrollPageDown, executeHandler, queryEnabledHandler, Key.PageDown); // // Command: ComponentCommands.ScrollPageLeft // Causes DocumentViewer to scroll a Viewport to the left. CommandHelpers.RegisterCommandHandler(typeof(DocumentViewer), ComponentCommands.ScrollPageLeft, executeHandler, queryEnabledHandler); //no key gesture // // Command: ComponentCommands.ScrollPageRight // Causes DocumentViewer to scroll a Viewport to the right. CommandHelpers.RegisterCommandHandler(typeof(DocumentViewer), ComponentCommands.ScrollPageRight, executeHandler, queryEnabledHandler); //no key gesture // // Command: ComponentCommands.MoveUp - Up // Causes DocumentViewer to scroll the Viewport up by 16px. CommandHelpers.RegisterCommandHandler(typeof(DocumentViewer), ComponentCommands.MoveUp, executeHandler, queryEnabledHandler, Key.Up); // // Command: ComponentCommands.MoveDown - Down // Causes DocumentViewer to scroll the Viewport down by 16px. CommandHelpers.RegisterCommandHandler(typeof(DocumentViewer), ComponentCommands.MoveDown, executeHandler, queryEnabledHandler, Key.Down); // // Command: ComponentCommands.MoveLeft - Left // Causes DocumentViewer to scroll a Viewport left by 16px. CommandHelpers.RegisterCommandHandler(typeof(DocumentViewer), ComponentCommands.MoveLeft, executeHandler, queryEnabledHandler, Key.Left); // // Command: ComponentCommands.MoveRight - Right // Causes DocumentViewer to scroll a Viewport right by 16px. CommandHelpers.RegisterCommandHandler(typeof(DocumentViewer), ComponentCommands.MoveRight, executeHandler, queryEnabledHandler, Key.Right); // // Command: NavigationCommands.Zoom // Sets DocumentViewer's Zoom to the specified level. CommandHelpers.RegisterCommandHandler(typeof(DocumentViewer), NavigationCommands.Zoom, executeHandler, queryEnabledHandler); //no key gesture // // Command: NavigationCommands.IncreaseZoom // Causes DocumentViewer to zoom in on the content. CommandHelpers.RegisterCommandHandler(typeof(DocumentViewer), NavigationCommands.IncreaseZoom, executeHandler, queryEnabledHandler, // Ctrl+Numpad '+' new KeyGesture(Key.Add, ModifierKeys.Control), // Ctrl+Numpad '+' (In case shift is held down) new KeyGesture(Key.Add, ModifierKeys.Shift | ModifierKeys.Control), // Ctrl+'+' new KeyGesture(Key.OemPlus, ModifierKeys.Control), // Ctrl+'+' (In case shift is held down) new KeyGesture(Key.OemPlus, ModifierKeys.Shift | ModifierKeys.Control)); // // Command: NavigationCommands.DecreaseZoom // Causes DocumentViewer to zoom out of the content. CommandHelpers.RegisterCommandHandler(typeof(DocumentViewer), NavigationCommands.DecreaseZoom, executeHandler, queryEnabledHandler, // Ctrl+Numpad '-' new KeyGesture(Key.Subtract, ModifierKeys.Control), // Ctrl+Numpad '-' (In case shift is held down) new KeyGesture(Key.Subtract, ModifierKeys.Shift | ModifierKeys.Control), // Ctrl+'-' new KeyGesture(Key.OemMinus, ModifierKeys.Control), // Ctrl+'-' (In case shift is held down) new KeyGesture(Key.OemMinus, ModifierKeys.Shift | ModifierKeys.Control)); // Command: NavigationCommands.PreviousPage CommandHelpers.RegisterCommandHandler(typeof(DocumentViewer), NavigationCommands.PreviousPage, executeHandler, queryEnabledHandler, new KeyGesture(Key.PageUp, ModifierKeys.Control)); // Command: NavigationCommands.NextPage CommandHelpers.RegisterCommandHandler(typeof(DocumentViewer), NavigationCommands.NextPage, executeHandler, queryEnabledHandler, new KeyGesture(Key.PageDown, ModifierKeys.Control)); // Command: NavigationCommands.FirstPage CommandHelpers.RegisterCommandHandler(typeof(DocumentViewer), NavigationCommands.FirstPage, executeHandler, queryEnabledHandler, new KeyGesture(Key.Home, ModifierKeys.Control)); // Command: NavigationCommands.FirstPage CommandHelpers.RegisterCommandHandler(typeof(DocumentViewer), NavigationCommands.LastPage, executeHandler, queryEnabledHandler, new KeyGesture(Key.End, ModifierKeys.Control)); #endregion Library Commands //Register input bindings for keyboard shortcuts that require //Command Parameters: //Zoom 100%: Requires a CommandParameter of 100.0 with the Zoom Command. //Bound to Ctrl+1. InputBinding zoom100InputBinding = new InputBinding(NavigationCommands.Zoom, new KeyGesture(Key.D1, ModifierKeys.Control)); zoom100InputBinding.CommandParameter = 100.0; CommandManager.RegisterClassInputBinding(typeof(DocumentViewer), zoom100InputBinding); //Whole Page: Requires a CommandParameter of 1 with the FitToMaxPagesAcross Command. //Bound to Ctrl+3. InputBinding wholePageInputBinding = new InputBinding(DocumentViewer.FitToMaxPagesAcrossCommand, new KeyGesture(Key.D3, ModifierKeys.Control)); wholePageInputBinding.CommandParameter = 1; CommandManager.RegisterClassInputBinding(typeof(DocumentViewer), wholePageInputBinding); //Two Pages: Requires a CommandParameter of 2 with the FitToMaxPagesAcross Command. //Bound to Ctrl+4. InputBinding twoPagesInputBinding = new InputBinding(DocumentViewer.FitToMaxPagesAcrossCommand, new KeyGesture(Key.D4, ModifierKeys.Control)); twoPagesInputBinding.CommandParameter = 2; CommandManager.RegisterClassInputBinding(typeof(DocumentViewer), twoPagesInputBinding); }
/// <summary> /// Initialize RemoveTagCommand /// </summary> private void InitializeRemoveTagCommand() { RoutedCommand RemoveTagCommand = new RoutedCommand(); CommandBinding cb = new CommandBinding(RemoveTagCommand, RemoveTagCommandExecute, RemoveTagCommandCanExecute); CommandBindings.Add(cb); btnRemove.Command = RemoveTagCommand; KeyGesture kg = new KeyGesture(Key.R, ModifierKeys.Control); InputBinding ib = new InputBinding(RemoveTagCommand, kg); InputBindings.Add(ib); }
private void InitUI() { this.imgFace.Source = this.imageService.GetToolBar(ImageTypeToolBar.Face); this.imgShake.Source = this.imageService.GetToolBar(ImageTypeToolBar.Shake); this.imgFont.Source = this.imageService.GetToolBar(ImageTypeToolBar.Font); this.btnFontB.Source = this.imageService.GetToolBar(ImageTypeToolBar.StyleB); this.btnFontI.Source = this.imageService.GetToolBar(ImageTypeToolBar.StyleI); this.btnFontU.Source = this.imageService.GetToolBar(ImageTypeToolBar.StyleU); this.InitFontStyle(); this.ibCtrl = new InputBinding(new ChatComponent.KeyCommand(delegate(object x) { this.KeySendMessage(); }), new KeyGesture(System.Windows.Input.Key.Return, ModifierKeys.Control)); this.ibEnter = new InputBinding(new ChatComponent.KeyCommand(delegate(object x) { this.KeySendMessage(); }), new KeyGesture(System.Windows.Input.Key.Return)); this.imgHide.Source = this.imageService.GetIcon(ImageTypeIcon.LHide); this.btnGroupShield.ContextMenu = null; this.SetKeyEnter(); }
public void Remove(InputBinding inputBinding) { }
private void SetupHotkeysAndCommands() { var ib = new InputBinding(UiCommands.Execute, new KeyGesture(Key.F5)); InputBindings.Add(ib); ib = new InputBinding(UiCommands.BeautifyJson, new KeyGesture(Key.B, ModifierKeys.Control)); InputBindings.Add(ib); // Bind handler var cb = new CommandBinding(UiCommands.Execute); cb.Executed += ExecuteHandler; CommandBindings.Add(cb); cb = new CommandBinding(UiCommands.BeautifyJson); cb.Executed += BeautifyJsonHandler; CommandBindings.Add(cb); }
private static void OnCommandPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) { InputBinding inputBinding = (InputBinding)d; inputBinding.CheckSecureCommand((ICommand)e.NewValue, inputBinding.Gesture); }
/// <summary> /// IndexOf - returns the index of the item in the list /// </summary> /// <param name="value">item whose index is sought</param> /// <returns>index of the item or -1 </returns> int IList.IndexOf(object value) { InputBinding inputBinding = value as InputBinding; return((inputBinding != null) ? this.IndexOf(inputBinding) : -1); }
/// <summary> /// IndexOf /// </summary> /// <param name="value"></param> /// <returns></returns> public int IndexOf(InputBinding value) { return((_innerBindingList != null) ? _innerBindingList.IndexOf(value) : -1); }
void IGestureService.AddKeyBinding(InputBinding binding, object scope) { var bindings = GetBindingScope(scope); bindings.Add(binding); _view.InputBindings.Add(binding); }
internal static void TranslateInput(IInputElement targetElement, InputEventArgs inputEventArgs) { if ((targetElement == null) || (inputEventArgs == null)) { return; } ICommand command = null; IInputElement target = null; object parameter = null; // Determine UIElement/ContentElement/Neither type DependencyObject targetElementAsDO = targetElement as DependencyObject; bool isUIElement = InputElement.IsUIElement(targetElementAsDO); bool isContentElement = !isUIElement && InputElement.IsContentElement(targetElementAsDO); bool isUIElement3D = !isUIElement && !isContentElement && InputElement.IsUIElement3D(targetElementAsDO); // Step 1: Check local input bindings InputBindingCollection localInputBindings = null; if (isUIElement) { localInputBindings = ((UIElement)targetElement).InputBindingsInternal; } else if (isContentElement) { localInputBindings = ((ContentElement)targetElement).InputBindingsInternal; } else if (isUIElement3D) { localInputBindings = ((UIElement3D)targetElement).InputBindingsInternal; } if (localInputBindings != null) { InputBinding inputBinding = localInputBindings.FindMatch(targetElement, inputEventArgs); if (inputBinding != null) { command = inputBinding.Command; target = inputBinding.CommandTarget; parameter = inputBinding.CommandParameter; } } // Step 2: If no command, check class input bindings if (command == null) { lock (_classInputBindings.SyncRoot) { Type classType = targetElement.GetType(); while (classType != null) { InputBindingCollection classInputBindings = _classInputBindings[classType] as InputBindingCollection; if (classInputBindings != null) { InputBinding inputBinding = classInputBindings.FindMatch(targetElement, inputEventArgs); if (inputBinding != null) { command = inputBinding.Command; target = inputBinding.CommandTarget; parameter = inputBinding.CommandParameter; break; } } classType = classType.BaseType; } } } // Step 3: If no command, check local command bindings if (command == null) { // Check for the instance level ones Next CommandBindingCollection localCommandBindings = null; if (isUIElement) { localCommandBindings = ((UIElement)targetElement).CommandBindingsInternal; } else if (isContentElement) { localCommandBindings = ((ContentElement)targetElement).CommandBindingsInternal; } else if (isUIElement3D) { localCommandBindings = ((UIElement3D)targetElement).CommandBindingsInternal; } if (localCommandBindings != null) { command = localCommandBindings.FindMatch(targetElement, inputEventArgs); } } // Step 4: If no command, look at class command bindings if (command == null) { lock (_classCommandBindings.SyncRoot) { Type classType = targetElement.GetType(); while (classType != null) { CommandBindingCollection classCommandBindings = _classCommandBindings[classType] as CommandBindingCollection; if (classCommandBindings != null) { command = classCommandBindings.FindMatch(targetElement, inputEventArgs); if (command != null) { break; } } classType = classType.BaseType; } } } // Step 5: If found a command, then execute it (unless it is // the special "NotACommand" command, which we simply ignore without // setting Handled=true, so that the input bubbles up to the parent) if (command != null && command != ApplicationCommands.NotACommand) { // We currently do not support declaring the element with focus as the target // element by setting target == null. Instead, we interpret a null target to indicate // the element that we are routing the event through, e.g. the targetElement parameter. if (target == null) { target = targetElement; } bool continueRouting = false; RoutedCommand routedCommand = command as RoutedCommand; if (routedCommand != null) { if (routedCommand.CriticalCanExecute(parameter, target, inputEventArgs.UserInitiated /*trusted*/, out continueRouting)) { // If the command can be executed, we never continue to route the // input event. continueRouting = false; ExecuteCommand(routedCommand, parameter, target, inputEventArgs); } } else { if (command.CanExecute(parameter)) { command.Execute(parameter); } } // If we mapped an input event to a command, we should always // handle the input event - regardless of whether the command // was executed or not. Unless the CanExecute handler told us // to continue the route. inputEventArgs.Handled = !continueRouting; } }
void InputBinding_Added(InputBinding inputBinding) { if (isAttached) textArea.InputBindings.Add(inputBinding); }
/// <summary> /// Initialize TagDetailsCommand /// </summary> private void InitializeTagDetailsCommand() { RoutedCommand DetailsCommand = new RoutedCommand(); CommandBinding cb = new CommandBinding(DetailsCommand, DetailsCommandExecute, DetailsCommandCanExecute); CommandBindings.Add(cb); BtnDetails.Command = DetailsCommand; KeyGesture kg = new KeyGesture(Key.D, ModifierKeys.Control); InputBinding ib = new InputBinding(DetailsCommand, kg); InputBindings.Add(ib); }
public Main() { Initialized += MainInitialized; InitializeComponent(); frame1.NavigationService.LoadCompleted += delegate(object sender, NavigationEventArgs args) { this.frame1.NavigationService.RemoveBackEntry(); }; //Set title with version info. Version version = Assembly.GetExecutingAssembly().GetName().Version; Title = "Octgn version " + version; frame1.Navigate(new ContactList()); DebugWindowCommand.InputGestures.Add(new KeyGesture(Key.D, ModifierKeys.Control)); var cb = new CommandBinding(DebugWindowCommand, MyCommandExecute, MyCommandCanExecute); CommandBindings.Add(cb); var kg = new KeyGesture(Key.M, ModifierKeys.Control); var ib = new InputBinding(DebugWindowCommand, kg); InputBindings.Add(ib); //Program.LobbyClient.OnFriendRequest += lobbyClient_OnFriendRequest; Program.LobbyClient.OnFriendRequest += LobbyClientOnOnFriendRequest; Program.LobbyClient.OnDataRecieved += LobbyClientOnOnDataRecieved; Program.LobbyClient.OnDisconnect += LobbyClientOnOnDisconnect; tbUsername.Text = Program.LobbyClient.Username; tbStatus.Text = Program.LobbyClient.CustomStatus; _originalBorderBrush = NotificationTab.Background; var cm = new ContextMenu(); cm.MenuItems.Add("Show", CmShowClick).DefaultItem = true; cm.MenuItems.Add("Log Off", CmLogOffClick); cm.MenuItems.Add("-"); cm.MenuItems.Add("Quit", CmQuitClick); SystemTrayIcon = new NotifyIcon { Icon = Properties.Resources.Icon, Visible = false, ContextMenu = cm, Text = Properties.Resources.Main_Main_Octgn }; SystemTrayIcon.DoubleClick += SystemTrayIconDoubleClick; // Insert code required on object creation below this point. RefreshGameFilter(true); tbUsername.Cursor = Cursors.Arrow; tbUsername.ForceCursor = true; tbStatus.Cursor = Cursors.Pen; tbStatus.ForceCursor = true; }
public static void RegisterClassInputBinding(Type type, InputBinding inputBinding) { }