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


C# ICommand.Execute方法代码示例

本文整理汇总了C#中ICommand.Execute方法的典型用法代码示例。如果您正苦于以下问题:C# ICommand.Execute方法的具体用法?C# ICommand.Execute怎么用?C# ICommand.Execute使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ICommand的用法示例。


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

示例1: InsertMenuItem

 public static IApplicationBarMenuItem InsertMenuItem(this IApplicationBar bar, int index, string text, ICommand cmd)
 {
     var menu = new ApplicationBarMenuItem { Text = text };
     menu.Click += (s, e) => cmd.Execute(null);
     bar.MenuItems.Insert(index, menu);
     return menu;
 }
开发者ID:thnk2wn,项目名称:codestock-winphone,代码行数:7,代码来源:IApplicationBar.cs

示例2: DoCommand

 public static void DoCommand(ICommand command)
 {
     if (command.Execute()) {
         undoStack.Push(command);
         redoStack.Clear();
     }
 }
开发者ID:kryptx,项目名称:Matrixplorer,代码行数:7,代码来源:CommandManager.cs

示例3: Execute

        public void Execute(ICommand command, string user)
        {
            // check user permission to execute command

            ICommandContext context = new CommandContext(_repository, user);
            command.Execute(context);
        }
开发者ID:yarikzub,项目名称:Ligas,代码行数:7,代码来源:CommandDispatcher.cs

示例4: TryExecute

		public static void TryExecute(ICommand command)
        {
            if (command != null)
            {
                command.Execute(null);
            }
        }
开发者ID:7711227,项目名称:Tutorials,代码行数:7,代码来源:CommandHelper.cs

示例5: PushButton

        public void PushButton()
        {
            if (_reader.CommandData != null)
            {
                if (_commands.ContainsKey(_reader.CommandData))
                {
                    _command = _commands[_reader.CommandData];

                    try
                    {
                        _command.Execute(_reader);
                    }
                    catch (Exception exception)
                    {
                        _reader.Help(this, exception.Message);
                    }
                }
                else
                {
                    _reader.Help(this, "Неправильно введена команда!");
                }
            }
            else
            {
                _reader.Help(this, null);
            }
        }
开发者ID:alermar69,项目名称:SmartHouseMVC,代码行数:27,代码来源:RemoteControl.cs

示例6: TrayWindowViewModel

        public TrayWindowViewModel(TaskbarIcon taskbarIcon)
        {
            _taskbarIcon = taskbarIcon;

            ExitCommand = new ExitCommand();
            ShowCommand = new ShowAllCommand();
            HideCommand = new HideAllCommand();
            AddRepoCommand = new AddRepositoryCommand();

            ShowAboutCommand = new ShowSingleViewCommand(typeof(AboutView));

            LeftClickCommand = new ToggleShowHideCommand();
            DoubleClickCommand = LeftClickCommand;

            ShowSettingsCommand = new ShowSingleViewCommand(typeof(SettingsView));
#if DEBUG
            ShowSettingsVisiblilty = "Visible";
#else
            ShowSettingsVisiblilty = "Collapsed";
#endif

            ShowUpdateCommand = new ShowSingleViewCommand(typeof(UpdateView));
            CheckUpdateCommand = ShowUpdateCommand;

            HotkeyHelper.OnHotkeyChanged += (sender, args) => OnPropertyChanged("ShowHideHeader");
            // todo: currently the only balloon is for update, so no distinction about what to do.
            _taskbarIcon.TrayBalloonTipClicked += (sender, args) => ShowUpdateCommand.Execute(null);
            UpdateManager.OnUpdateRequired += UpdateManager_OnUpdateRequired;
            UpdateManager.OnUpdateInfoChanged += delegate(object sender, EventArgs args)
            {
                OnPropertyChanged("CheckUpdateHeader");
                OnPropertyChanged("ToolTipText");
            };

        }
开发者ID:tbener,项目名称:DiGit,代码行数:35,代码来源:TrayWindowViewModel.cs

示例7: Handle

 public Notification Handle(ICommand command, ExecutionArguments executionArguments)
 {
     var prerequisiteResult = _prerequisiteChecker.Check(command, executionArguments);
     if (prerequisiteResult.HasErrors)
     {
         return prerequisiteResult;
     }
     var commandResult = command.Execute(executionArguments);
     if (commandResult.HasErrors)
     {
         return commandResult;
     }
     if (command.ChangesTheStatement())
     {
         var commandHistory = new CommandHistory
             {
                 Command = command.GetType().Name,
                 Args = executionArguments.Args,
                 Date = _systemService.CurrentDateTime
             };
         Statement statement = executionArguments.Statement;
         statement.CommandHistory.Add(commandHistory);
     }
     return commandResult;
 }
开发者ID:handcraftsman,项目名称:Afluistic,代码行数:25,代码来源:CommandHandler.cs

示例8: InsertGeFile

 public void InsertGeFile(string filename, GraphicContent graphicContent)
 {
     f_command = new InsertGeFileCommand(filename, graphicContent);
     f_undoCommands.Push(f_command);
     f_redoCommands.Clear();
     f_command.Execute();
 }
开发者ID:msCube,项目名称:Gallery,代码行数:7,代码来源:CommandReceiver.cs

示例9: Include

		public void Include (ICommand command)
		{
			command.CanExecuteChanged += (s, e) => {
				if (command.CanExecute (null))
					command.Execute (null);
			};
		}
开发者ID:fatelord,项目名称:chgk,代码行数:7,代码来源:LinkerPleaseInclude.cs

示例10: Execute

 /// <summary>
 /// The main execution method to decouple actions. Track
 /// commands in this method if you need to Undo or Redo actions.
 /// </summary>
 public void Execute(ICommand command)
 {
     command.Execute();
     UndoneCommands.Clear();
     RedoneCommands.Clear();
     Commands.Push(command);
 }
开发者ID:OhRyanOh,项目名称:DesignPatterns,代码行数:11,代码来源:CommandManager.cs

示例11: Execute

        public void Execute(ICommand command)
        {
            command.Execute();

            undoStack.Push(command);
            redoStack.Clear();
        }
开发者ID:shootdaj,项目名称:MIDIator,代码行数:7,代码来源:UndoManager.cs

示例12: InsertButton

 public static IApplicationBarIconButton InsertButton(this IApplicationBar bar, int index, string imageUrl, string text, ICommand cmd)
 {
     var btn = new ApplicationBarIconButton { IconUri = new Uri(imageUrl, UriKind.Relative), Text = text };
     btn.Click += (s, e) => cmd.Execute(null);
     bar.Buttons.Insert(index, btn);
     return btn;
 }
开发者ID:thnk2wn,项目名称:codestock-winphone,代码行数:7,代码来源:IApplicationBar.cs

示例13: CreateAndAddMenuItem

        /// <summary>
        /// Creates a menu item and adds it to an application bar.
        /// </summary>
        /// <param name="appBar"></param>
        /// <param name="command"></param>
        /// <param name="text"></param>
        /// <returns></returns>
        public static ApplicationBarMenuItem CreateAndAddMenuItem(this IApplicationBar appBar, ICommand command, string text)
        {
            ApplicationBarMenuItem mi = new ApplicationBarMenuItem(text);

            // First-time values.
            mi.IsEnabled = command.CanExecute(mi);

            // Adds click handler to execute the command upon click.
            mi.Click += (o, e) =>
            {
                if (command.CanExecute(mi))
                {
                    command.Execute(mi);
                }
            };

            // Adds CanExecute changed handler.
            command.CanExecuteChanged += (o, e) =>
            {
                mi.IsEnabled = command.CanExecute(mi);
            };

            // Adds the button.
            appBar.MenuItems.Add(mi);

            return mi;
        }
开发者ID:chier01,项目名称:WF.Player.WinPhone,代码行数:34,代码来源:ShellExtensions.cs

示例14: DoesNewPageCommandExecute

 protected bool DoesNewPageCommandExecute(ICommand command, PageName expected)
 {
     var passedNewPage = PageName.Navigation;
     Commands.NewPageCommand = new RelayCommand<PageName>(p => passedNewPage = p);
     command.Execute(null);
     return passedNewPage.Equals(expected);
 }
开发者ID:JWroe,项目名称:ScrapTraders,代码行数:7,代码来源:PageViewModelTests.cs

示例15: CreateAndAddButton

        /// <summary>
        /// Creates a button and adds it to an application bar.
        /// </summary>
        /// <param name="appBar"></param>
        /// <param name="iconFilenameRelative"></param>
        /// <param name="command"></param>
        /// <param name="text"></param>
        /// <returns></returns>
        public static ApplicationBarIconButton CreateAndAddButton(this IApplicationBar appBar, string iconFilenameRelative, ICommand command, string text)
        {
            ApplicationBarIconButton btn = new ApplicationBarIconButton(new Uri("/icons/" + iconFilenameRelative, UriKind.Relative));

            // First-time values.
            btn.IsEnabled = command.CanExecute(btn);
            btn.Text = text;

            // Adds click handler to execute the command upon click.
            btn.Click += (o, e) =>
            {
                if (command.CanExecute(btn))
                {
                    command.Execute(btn);
                }
            };

            // Adds CanExecute changed handler.
            command.CanExecuteChanged += (o, e) =>
            {
                btn.IsEnabled = command.CanExecute(btn);
            };

            // Adds the button.
            appBar.Buttons.Add(btn);

            return btn;
        }
开发者ID:chier01,项目名称:WF.Player.WinPhone,代码行数:36,代码来源:ShellExtensions.cs


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