当前位置: 首页>>代码示例>>C#>>正文


C# Input.CommandBinding类代码示例

本文整理汇总了C#中System.Windows.Input.CommandBinding的典型用法代码示例。如果您正苦于以下问题:C# CommandBinding类的具体用法?C# CommandBinding怎么用?C# CommandBinding使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


CommandBinding类属于System.Windows.Input命名空间,在下文中一共展示了CommandBinding类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: DatasetVertexView

        /// <summary>
        /// Initializes a new instance of the <see cref="DatasetVertexView"/> class.
        /// </summary>
        /// <remarks>
        /// This constructor is called internally by the WPF system because this class is part of a template
        /// in the DatasetGraphView. No point in changing this constructor to take external arguments because
        /// it won't work that way.
        /// </remarks>
        internal DatasetVertexView()
        {
            InitializeComponent();

            // Bind the new dataset command
            {
                var cb = new CommandBinding(s_NewDatasetCommand, CommandNewDatasetExecuted, CommandNewDatasetCanExecute);
                CommandBindings.Add(cb);
                addChildDatasetButton.Command = s_NewDatasetCommand;
            }

            // Bind the delete dataset command
            {
                var cb = new CommandBinding(s_RemoveDatasetCommand, CommandDeleteDatasetExecuted, CommandDeleteDatasetCanExecute);
                CommandBindings.Add(cb);
                deleteDatasetButton.Command = s_RemoveDatasetCommand;
            }

            // Bind the activate / deactivate command
            {
                var cb = new CommandBinding(
                    s_ActivateOrDeactivateDatasetCommand,
                    CommandActivateDeactivateDatasetExecuted,
                    CommandActivateDeactivateDatasetCanExecute);
                CommandBindings.Add(cb);
                activateOrDeactivateDatasetButton.Command = s_ActivateOrDeactivateDatasetCommand;
            }

            // Bind the show detail view command
            {
                var cb = new CommandBinding(s_ShowDetailViewCommand, CommandShowDetailViewExecuted, CommandShowDetailViewCanExecute);
                CommandBindings.Add(cb);
                showDetailButton.Command = s_ShowDetailViewCommand;
            }
        }
开发者ID:pvandervelde,项目名称:Apollo,代码行数:43,代码来源:DatasetVertexView.xaml.cs

示例2: MainWindow

    public MainWindow ()
    {
      InitializeComponent ();

      StatusBarText = String.Empty;
      IsHlrOffPushed = false;
      IsHlrOnPushed = true;
      IsZoomWinEnabled = true;

      #region menu operations

      CommandBinding aBind_New = new CommandBinding (IECommands.New);
      aBind_New.Executed += NewCommand_Executed;
      CommandBindings.Add (aBind_New);

      CommandBinding aBind_Close = new CommandBinding (IECommands.Close);
      aBind_Close.Executed += CloseCommand_Executed;
      aBind_Close.CanExecute += CloseCommand_CanExecute;
      CommandBindings.Add (aBind_Close);

      CommandBinding aBind_Quit = new CommandBinding (IECommands.Quit);
      aBind_Quit.Executed += QuitCommand_Executed;
      CommandBindings.Add (aBind_Quit);

      CommandBinding aBind_About = new CommandBinding (IECommands.About);
      aBind_About.Executed += AboutCommand_Executed;
      CommandBindings.Add (aBind_About);

      #endregion
    }
开发者ID:xushengli,项目名称:oce,代码行数:30,代码来源:MainWindow.xaml.cs

示例3: TablesContextMenu

        public TablesContextMenu(DatabaseMenuCommandParameters menuCommandParameters, ExplorerToolWindow parent)
        {
            var dcmd = new DatabaseMenuCommandsHandler(parent);

            var createTableCommandBinding = new CommandBinding(DatabaseMenuCommands.DatabaseCommand,
                            dcmd.BuildTable);
            var createTableMenuItem = new MenuItem
            {
                Header = "Build Table (beta)...",
                Icon = ImageHelper.GetImageFromResource("../resources/AddTable_5632.png"),
                Command = DatabaseMenuCommands.DatabaseCommand,
                CommandParameter = menuCommandParameters
            };
            createTableMenuItem.CommandBindings.Add(createTableCommandBinding);
            Items.Add(createTableMenuItem);
            
            Items.Add(new Separator());

            var refreshCommandBinding = new CommandBinding(DatabaseMenuCommands.DatabaseCommand,
                                                    dcmd.RefreshTables);
            var refreshMenuItem = new MenuItem
            {
                Header = "Refresh",
                Icon = ImageHelper.GetImageFromResource("../resources/refresh.png"),
                Command = DatabaseMenuCommands.DatabaseCommand,
                CommandParameter = menuCommandParameters
            };
            refreshMenuItem.CommandBindings.Add(refreshCommandBinding);
            Items.Add(refreshMenuItem);
        }
开发者ID:inickvel,项目名称:SqlCeToolbox,代码行数:30,代码来源:TablesContextMenu.cs

示例4: createCommandBindings

        private void createCommandBindings()
        {
            CommandBinding bindNew = new CommandBinding();
            CommandBinding bindOpen = new CommandBinding();
            CommandBinding bindSave = new CommandBinding();
            CommandBinding bindExit = new CommandBinding();

            bindNew.Command = ApplicationCommands.New;
            bindNew.Executed += NewGame_Executed;
            bindNew.CanExecute += NewGame_CanExecute;
            CommandBindings.Add(bindNew);

            bindOpen.Command = ApplicationCommands.Open;
            bindOpen.Executed += OpenFile_Executed;
            bindOpen.CanExecute += OpenFile_CanExecute;
            CommandBindings.Add(bindOpen);

            bindSave.Command = ApplicationCommands.Save;
            bindSave.Executed += SaveFile_Executed;
            bindSave.CanExecute += SaveFile_CanExecute;
            CommandBindings.Add(bindSave);

            bindExit.Command = CustomCommands.Exit;
            bindExit.Executed += ExitGame_Executed;
            bindExit.CanExecute += ExitGame_CanExecute;
            CommandBindings.Add(bindExit);
        }
开发者ID:Nefflius,项目名称:Sigge-Projekt,代码行数:27,代码来源:MainWindow.xaml.cs

示例5: page_chat

        public page_chat()
        {
            InitializeComponent();

            RoutedCommand Input_SendMessage = new RoutedCommand();
            RoutedCommand Input_Return = new RoutedCommand();

            KeyBinding Input_SendMessage_Keybinding = new KeyBinding(Input_SendMessage, new KeyGesture(Key.Enter));
            CommandBinding Input_SendMessage_Binding = new CommandBinding(Input_SendMessage, Input_SentMessage_Execute, CmdCanExecute);

            KeyBinding Input_Return_Keybinding = new KeyBinding(Input_Return, new KeyGesture(Key.Enter, ModifierKeys.Control));
            CommandBinding Input_Return_Binding = new CommandBinding(Input_Return, Input_Return_Execute, CmdCanExecute);

            this.rtf_input.InputBindings.Add(Input_SendMessage_Keybinding);
            this.rtf_input.CommandBindings.Add(Input_SendMessage_Binding);

            this.rtf_input.InputBindings.Add(Input_Return_Keybinding);
            this.rtf_input.CommandBindings.Add(Input_Return_Binding);

            CommandBinding pasteCmdBinding = new CommandBinding(ApplicationCommands.Paste, OnPaste, OnCanExecutePaste);
            this.rtf_input.CommandBindings.Add(pasteCmdBinding);

            try
            {
                this.rtf_input.FontSize = Convert.ToDouble(ConfigManager.Instance.GetString("font_size", "12"));
                this.rtf_input.FontFamily = new FontFamily(ConfigManager.Instance.GetString("font", "Segoe WP"));
                this.rtf_input.Foreground = (SolidColorBrush)new BrushConverter().ConvertFromString(ConfigManager.Instance.GetString("font_color", "#000000"));
            }
            catch { }

            this.rtf_input.AddHandler(RichTextBox.DragOverEvent, new DragEventHandler(rtf_DragOver), true);
            this.rtf_input.AddHandler(RichTextBox.DropEvent, new DragEventHandler(rtf_DragDrop), true);
        }
开发者ID:astorks,项目名称:BlazeIM,代码行数:33,代码来源:page_chat.xaml.cs

示例6: MainWindow_Loaded

        private void MainWindow_Loaded(object sender, RoutedEventArgs e)
        {
            // Creating the main panel
            var mainStackPanel = new StackPanel();
            AddChild(mainStackPanel);

            // Button used to invoke the command
            var commandButton = new Button
            {
                Command = ApplicationCommands.Open,
                Content = "Open (KeyBindings: Ctrl-R, Ctrl-0)"
            };
            mainStackPanel.Children.Add(commandButton);

            // Creating CommandBinding and attaching an Executed and CanExecute handler
            var openCmdBinding = new CommandBinding(
                ApplicationCommands.Open,
                OpenCmdExecuted,
                OpenCmdCanExecute);

            CommandBindings.Add(openCmdBinding);

            // Creating a KeyBinding between the Open command and Ctrl-R
            var openCmdKeyBinding = new KeyBinding(
                ApplicationCommands.Open,
                Key.R,
                ModifierKeys.Control);

            InputBindings.Add(openCmdKeyBinding);
        }
开发者ID:ClemensT,项目名称:WPF-Samples,代码行数:30,代码来源:MainWindow.cs

示例7: InitializeComponent

 public 部門表()
 {
     InitializeComponent();
     CommandBinding binding = new CommandBinding(ApplicationCommands.ContextMenu);
     binding.Executed += ContextMenu_Executed;
     this.CommandBindings.Add(binding);
 }
开发者ID:momo16542,项目名称:DarbWareERP,代码行数:7,代码来源:部門表.xaml.cs

示例8: SetF1CommandBinding

 private void SetF1CommandBinding()
 {
     CommandBinding helpBinding = new CommandBinding(ApplicationCommands.Help);
     helpBinding.CanExecute += CanHelpExecute;
     helpBinding.Executed += HelpExecuted;
     CommandBindings.Add(helpBinding);
 }
开发者ID:newhuaszh,项目名称:WPF,代码行数:7,代码来源:MainWindow.xaml.cs

示例9: MainWindow

		public MainWindow(SessionInfo sessionInfo)
		{
			this.DataContext = sessionInfo;
			
			#region Command bindings
			//New command binding
			CommandBinding newCommandBinding = new CommandBinding(InvoiceManagerCommands.New);
			newCommandBinding.Executed += NewCommand_Executed;
			newCommandBinding.CanExecute += NewCommand_CanExecute;
			CommandBindings.Add(newCommandBinding);
			//Edit command binding
			CommandBinding editCommandBinding = new CommandBinding(InvoiceManagerCommands.Edit);
			editCommandBinding.Executed += EditCommand_Executed;
			editCommandBinding.CanExecute += EditCommand_CanExecute;
			CommandBindings.Add(editCommandBinding);
			//Delete command binding
			CommandBinding deleteCommandBinding = new CommandBinding(InvoiceManagerCommands.Delete);
			deleteCommandBinding.Executed += DeleteCommand_Executed;
			deleteCommandBinding.CanExecute += DeleteCommand_CanExecute;
			CommandBindings.Add(deleteCommandBinding);
			#endregion
			
			InitializeComponent();
			App.Current.MainWindow = this;
		}
开发者ID:revov,项目名称:InvoiceManager,代码行数:25,代码来源:MainWindow.xaml.cs

示例10: MainWindow

        public MainWindow()
        {
            SOTC_BindingErrorTracer.BindingErrorTraceListener.SetTrace();
            this.InitializeComponent();
            /*
            // Insert code required on object creation below this point.
            KeyBinding ib = new KeyBinding(
                GlobalCommands.IncrementSectionNumber, new KeyGesture(Key.U, ModifierKeys.Control));
            this.InputBindings.Add(ib);
            */

            incrementCenterIndexCommand = new RoutedUICommand("+", "IncrementCenterIndexCommand", typeof(MainWindow));
            decrementCenterIndexCommand = new RoutedUICommand("-", "DecrementCenterIndexCommand", typeof(MainWindow));

            CommandBinding cb = new CommandBinding(incrementCenterIndexCommand, OnIncrementSectionNumber);
            this.CommandBindings.Add(cb);

            cb = new CommandBinding(decrementCenterIndexCommand, OnDecrementSectionNumber);
            this.CommandBindings.Add(cb);

            GlobalCommands.IncrementSectionNumber.RegisterCommand(incrementCenterIndexCommand);
            GlobalCommands.IncrementSectionNumber.RegisterCommand(decrementCenterIndexCommand);
            //GlobalCommands.IncrementSectionNumber.Execute(null);

            OnStartup(null);
        }
开发者ID:abordt,项目名称:Viking,代码行数:26,代码来源:MainWindowShell.xaml.cs

示例11: DateInputUC

 public DateInputUC()
 {
     InitializeComponent();
     toggleCalendarAction = new CommandBinding(ToggleCalendarAction, ToggleCalendar);
     CommandBindings.Add(toggleCalendarAction);
     this.AddHandler(Validation.ErrorEvent, new EventHandler<ValidationErrorEventArgs>(ValidationErrorEventHandler));
 }
开发者ID:koder05,项目名称:fogel-ba,代码行数:7,代码来源:DateInputUC.xaml.cs

示例12: MessageWindowElement

        public MessageWindowElement(MessageDailog dm)
            : base()
        {
            var bindinAccept = new CommandBinding(AcceptCommand, OnAccept);
            this.CommandBindings.Add(bindinAccept);

            var bindingCancel = new CommandBinding(CancelCommand, OnCancel);
            this.CommandBindings.Add(bindingCancel);

            if (dm != null)
            {
                Buttons = dm.DialogButton;
                Title = dm.Title;
                Content = dm.Caption;

                if (dm.DialogHeight != 0)
                    this.Height = dm.DialogHeight;
                if (dm.DialogWidth != 0)
                    this.Height = dm.DialogWidth;

                if(dm.IsSizeToContent)
                    this.SizeToContent = SizeToContent.WidthAndHeight;
            }

            CreateContainer();
        }
开发者ID:ruisebastiao,项目名称:WPF-MVVM-With-Entity-Framework,代码行数:26,代码来源:MessageWindowElement.cs

示例13: 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

示例14: OnStartup

        protected override void OnStartup(StartupEventArgs e)
        {
            base.OnStartup(e);

            var binding = new CommandBinding(Commands.CloseWindow, CloseWindow);
            CommandManager.RegisterClassCommandBinding(typeof(Window), binding);
        }
开发者ID:yu-kopylov,项目名称:cramtool,代码行数:7,代码来源:App.xaml.cs

示例15: MainWindow

        public MainWindow()
            : base(SplashShowing)
        {
            Default = this;

            #region initialize command bindings
            SDWindow.NewCommand.Text = "New Receipt";
            this.NewCommandBinding.Executed += NewReceiptCommand_Executed;
            this.OptionsCommandBinding.Executed += OptionsCommand_Executed;
            ReceiptSingularCommandBinding = new CommandBinding(ReceiptSingularCommand, ReceiptSingularCommand_Executed);
            this.CommandBindings.Add(ReceiptSingularCommandBinding);
            ReceiptTabularCommandBinding = new CommandBinding(ReceiptTabularCommand, ReceiptTabularCommand_Executed);
            this.CommandBindings.Add(ReceiptTabularCommandBinding);
            FeesRegisterCommandBinding = new CommandBinding(FeesRegisterCommand, FeesRegisterCommand_Executed);
            this.CommandBindings.Add(FeesRegisterCommandBinding);
            FeesBalancesCommandBinding = new CommandBinding(FeesBalancesCommand, FeesBalancesCommand_Executed);
            this.CommandBindings.Add(FeesBalancesCommandBinding);
            #endregion
            try
            {
                InitializeComponent();          
            }
            catch (Exception ex)
            {
                Errors.displayError("An error occured starting the application", ErrorCode.MainWindowConstructor, ErrorAction.Exit, ex);
            }
        }
开发者ID:GrayJumba,项目名称:Onion,代码行数:27,代码来源:MainWindow.xaml.cs


注:本文中的System.Windows.Input.CommandBinding类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。