public DialogViewModel(string title, string message) { Title = title; Message = message; OkCommand = new ActionCommand(p => CloseRequested?.Invoke(this, new DialogCloseRequestEventArgs(true))); CancelCommand = new ActionCommand(p => CloseRequested?.Invoke(this, new DialogCloseRequestEventArgs(false))); }
private void InitTreeViewPart() { ActionCommand ActCom(Action action) => new ActionCommand(action); TVItemMenuCommand TVCom(Action <FilesTreeViewNodeModel> action) => new ActionCommand <FilesTreeViewNodeModel>(action); TV_OpenFilterBoxCommand = ActCom(TV_OpenFilterBoxCommand_Execute); TV_CloseFilterBoxCommand = ActCom(TV_CloseFilterBoxCommand_Execute); TV_ToggleFilterBoxCommand = ActCom(TV_ToggleFilterBoxCommand_Execute); TV_ExpandCommand = ActCom(TV_ExpandCommand_Execute); TV_CollapseCommand = ActCom(TV_CollapseCommand_Execute); TV_RefreshFilesListCommand = ActCom(TV_RefreshFilesListCommand_Execute); TV_OpenFileCommand = TVCom(TV_OpenFileCommand_Execute); TV_OpenWithCommand = TVCom(TV_OpenWithCommand_Execute); TV_ReplaceFileCommand = TVCom(TV_ReplaceFileCommand_Execute); TV_LoadAllInXmlCommand = TVCom(TV_LoadAllInXmlCommand_Execute); TV_ExpandFolderCommand = TVCom(TV_ExpandFolderCommand_Execute); TV_DeleteElementCommand = TVCom(TV_DeleteElementCommand_Execute); TV_OpenInExplorerCommand = TVCom(TV_OpenInExplorerCommand_Execute); TV_CollapseFolderCommand = TVCom(TV_CollapseFolderCommand_Execute); TV_DropCommand = new ActionCommand <DragEventArgs>(TV_DropCommand_Execute); _tvCommands = new CommandContainers(this); TV_FilterString.PropertyChanged += async(sender, args) => await FilterItems(); }
/// <summary> /// 撤消操作,并返回能否继续撤销 /// </summary> /// <returns></returns> public bool UnDoCommand() { //清除已经开始的步骤 if (activeCommands.Count > 0) { foreach (var cmd in activeCommands) { cmd.UnDoExecute(); } activeCommands.Clear(); } //回退 if (executedCommands.Count > 0) { var cmd = executedCommands.Pop(); backupCommands.Push(cmd); cmd.UnDoExecute(); if (executedCommands.Count > 0) { CurrCommand = executedCommands.Peek(); } else { CurrCommand = null; } return(true); } else { return(false); } }
/// <summary> /// 结束已经开始的命令 /// </summary> public void OnEndExecuteCommand(string step) { bool haveNext = true; if (activeCommands.Count > 0) { foreach (var item in activeCommands) { if (step == item.StepName) { CurrCommand = item; executedCommands.Push(item); haveNext = commandDic.ContainsKey(item); } else { item.UnDoExecute(); } } activeCommands.Clear(); if (onEndExecute != null) { onEndExecute(haveNext); } } }
public AboutWindowViewModel( [NotNull] ApplicationUtils applicationUtils, [NotNull] GlobalVariables globalVariables ) { // properties Version = new DelegatedProperty <string>(applicationUtils.GetVersion, null).AsReadonly(); // commands ShowDeveloperCommand = new ActionCommand(() => { WebUtils.OpenLinkInBrowser("http://www.4pda.ru/forum/index.php?showuser=2114045"); }); ThankDeveloperCommand = new ActionCommand(() => { WebUtils.OpenLinkInBrowser("http://4pda.ru/forum/index.php?act=rep&type=win_add&mid=2114045&p=23243303"); }); OpenAppDataFolderCommand = new ActionCommand(() => { Process.Start(globalVariables.AppDataPath); }); OpenSourcesPage = new ActionCommand(() => { WebUtils.OpenLinkInBrowser("https://github.com/And42/SaveToGame"); }); }
public AboutWindowViewModel( [NotNull] ApplicationUtils applicationUtils, [NotNull] GlobalVariables globalVariables ) { // properties Version = new DelegatedProperty <string>(applicationUtils.GetVersion, null).AsReadonly(); // commands ShowDeveloperCommand = new ActionCommand(() => { WebUtils.OpenLinkInBrowser("https://www.andnixsh.com/"); }); ThankDeveloperCommand = new ActionCommand(() => { WebUtils.OpenLinkInBrowser("http://4pda.ru/forum/index.php?showtopic=477614&st=980"); }); OpenAppDataFolderCommand = new ActionCommand(() => { Process.Start(globalVariables.AppDataPath); }); OpenSourcesPage = new ActionCommand(() => { WebUtils.OpenLinkInBrowser("https://github.com/AndnixSH/SaveToGame"); }); }
public PluginMenuItemModel(string title, IActionCommand <PluginPart <IAdditionalAction> > command, ImageSource icon = null, PluginPart <IAdditionalAction> action = null) { Title = title; Command = command; Icon = icon; Action = action; }
private void OnOneCommandComplete(IActionCommand command) { if (onStepComplete != null) { onStepComplete(command.StepName); } }
/// <summary> /// 回到命令列表起始 /// </summary> public void ToAllCommandStart() { while (executedCommands.Count > 0) { UnDoCommand(); } CurrCommand = null; }
public void UpdateSection(string sectionName, IActionCommand actionCommand, object configValue) { lock (lockMe) { ExecuteWhilePaused(sectionName, new ActionTakenWhilePaused(actionCommand.Execute)); AddSection(sectionName, configValue); } }
public ApktoolCatalogWindowViewModel() { _webClient.DownloadProgressChanged += (sender, args) => Progress.Value = args.ProgressPercentage; ItemClickedCommand = new ActionCommand <DownloadableApktool>(ItemClickedCommand_Execute, _ => !IsBusy); PropertyChanged += OnPropertyChanged; }
public WinTasksViewModel(IStartup startup, Window window) : base(startup) { _window = window; KillTaskCommand = new ActionCommand <WinTask>(KillTask); Model.OnHotKeyPress += async() => await OnGlobalHookKeyPress(); ((WinTasksView)View).OnTaskKillEvent += async kill => await KillTask(kill); }
public void MarkExecutionEnd(IActionCommand actionCommand) { if (actionCommand == null) { throw new ArgumentNullException(nameof(actionCommand)); } Console.WriteLine($"End: {actionCommand}"); }
public void Add(IActionCommand command) { if (command == null) { throw new ArgumentNullException(nameof(command)); } Queued.Add(command); }
public AdbInstallWindowViewModel( [NotNull] GlobalVariables globalVariables ) { _globalVariables = globalVariables; // commands LoadDataCommand = new ActionCommand(LoadData, () => !Processing.Value).BindCanExecute(Processing); InstallCommand = new ActionCommand <AdbDeviceViewModel>(InstallCommand_Execute, _ => !Processing.Value).BindCanExecute(Processing); }
// This function is called to set a player's action for a given turn public void setAction(IActionCommand action) { // If there is already a command from that sender, remove it if (submittedActions.Exists(x => x.sender == action.sender)) { submittedActions.Remove(submittedActions.Find(x => x.sender == action.sender)); } submittedActions.Add(action); }
public void MarkExecutionEnd_NullActionCommand_ThrowsArgumentNullException() { // Arrange IActionCommand command = null; // Act TestDelegate action = () => _defaultTracker.MarkExecutionEnd(command); // Assert Assert.Throws <ArgumentNullException>(action); }
private void InitCommon() { ActionCommand ActCom(Action action) => new ActionCommand(action); AddNewLanguageCommand = ActCom(AddNewLanguageCommand_Execute); RemoveLanguagesCommand = ActCom(RemoveLanguagesCommand_Execute); InitMenuPart(); InitTreeViewPart(); InitMainButtonsPart(); }
public void Perform_NullActionCommand_ThrowsArgumentNullException() { // Arrange IActionCommand command = null; // Act TestDelegate action = () => _defaultPerformer.Perform(command); // Assert Assert.Throws <ArgumentNullException>(action); }
public void Add(IActionCommand command) { if (command == null) { throw new ArgumentNullException(nameof(command)); } Type type = command.GetType(); IActionCommandList commands = Get(type); commands.Add(command); }
/// <summary> /// 执行到指定的步骤 /// </summary> /// <param name="stepName"></param> public bool ToTargetCommand(string stepName) { bool haveNext = true; IActionCommand cmd = commandList.Find((x) => stepName == x.StepName); if (cmd != null) { int indexofCmd = commandList.IndexOf(cmd); haveNext &= ExecuteMutliCommand(indexofCmd - index); } return(haveNext); }
public static T RequeryOnCommandExecuted <T>(this T command, IActionCommand relatedCommand) where T : ICommand, IWeakEventListener { Guard.ArgumentNotDefault(command, "command"); Guard.ArgumentNotNull(relatedCommand, "relatedCommand"); // we attach a weak listener to hear for any changes in the other command relatedCommand.CommandExecuted += new WeakListenerHandler <CommandEventArgs, EventHandler <CommandEventArgs> >(command, (h) => relatedCommand.CommandExecuted -= h); return(command); }
/// <summary> /// /// </summary> /// <param name="command"></param> /// <returns></returns> private bool IsBackground(IActionCommand command) { ThreadModeAttribute attr = Attribute.GetCustomAttribute(command.GetType(), typeof(ThreadModeAttribute)) as ThreadModeAttribute; if (attr == null) { string mode = ConfigurationManager.AppSettings["Eleve.ThreadMode"]; return(mode == "Background"); } return(attr.ThreadMode == ThreadMode.Background); }
private void InitMainButtonsPart() { SignCommand = new ActionCommand(SignCommand_Execute, () => Apk?.NewApk != null); BuildCommand = new ActionCommand(BuildCommand_Execute, () => Apk != null); ChooseFileCommand = new ActionCommand(ChooseFileCommand_Execute); ChooseFolderCommand = new ActionCommand(ChooseFolderCommand_Execute); InstallFrameworkCommand = new ActionCommand(InstallFrameworkCommand_Execute); ShowSearchWindowCommand = new ActionCommand(OpenSearchCommand_Execute); ApkDropCommand = new ActionCommand <DragEventArgs>(ApkDropCommand_Execute); FolderDropCommand = new ActionCommand <DragEventArgs>(FolderDropCommand_Execute); FrameworkDropCommand = new ActionCommand <DragEventArgs>(FrameworkDropCommand_Execute); }
/// <summary> /// Queries for command state according to another command execution /// </summary> /// <typeparam name="T">Type of command</typeparam> /// <param name="command">Command</param> /// <param name="relatedCommand">Related command</param> /// <returns>Command after the setup</returns> public static T RequeryOnCommandExecuted <T>(this T command, IActionCommand relatedCommand) where T : ICommand, IReceiveEvent { Guard.ArgumentNotDefault(command, "command"); Guard.ArgumentNotNull(relatedCommand, "relatedCommand"); command.AddDisposable(Observable .FromEventPattern <EventHandler <CommandEventArgs>, CommandEventArgs>(a => relatedCommand.CommandExecuted += a, a => relatedCommand.CommandExecuted -= a) .Subscribe(a => command.ReceiveWeakEvent(a.EventArgs))); return(command); }
/// <summary> /// 结束已经开始的命令 /// </summary> public bool EndExecuteCommand() { if (backupCommands.Count > 0) { CurrCommand = backupCommands.Pop(); executedCommands.Push(CurrCommand); CurrCommand.EndExecute(); return(true); } else { return(false); } }
public void Handle(WebRequest request) { IActionCommand command = _commandRegistry.GetCommandFor(request); //If the command requests doesn't match any registered commands return an error page. if (command != null) { command.Process(request); } else { HttpContext.Current.Server.Transfer("~/Views/Errors/NoAction.aspx"); } }
public void Perform(IActionCommand actionCommand) { if (actionCommand == null) { throw new ArgumentNullException(nameof(actionCommand)); } if (!DirectPlay) { _commands.Enqueue(actionCommand); return; } ExecuteActionCommand(actionCommand); }
private void ExecuteActionCommand(IActionCommand actionCommand) { try { _tracker?.MarkExecutionBegin(actionCommand); actionCommand.Execute(WebDriver); _tracker?.MarkExecutionEnd(actionCommand); } catch (UnexpectedWebDriverStateException) { Dispose(); throw; } }
public PackStartupWindowViewModel( IAttachedWindowManipulator attachedWindowManipulator, AppSettingsJson appSettings ) { _attachedWindowManipulator = attachedWindowManipulator; _appSettings = appSettings; CreateNewPackCommand = new ActionCommand(CreateNewPackCommand_Execute); ChooseExistingPackCommand = new ActionCommand(ChooseExistingPackCommand_Execute); LaunchConverterCommand = new ActionCommand(LaunchConverterCommand_Execute); SwitchToEnglishCommand = new ActionCommand(() => SwitchLanguageTo("en-US")); SwitchToRussianCommand = new ActionCommand(() => SwitchLanguageTo("ru-RU")); PropertyChanged += OnPropertyChanged; }
public void UpdateSection(string sectionName, IActionCommand actionCommand, object configValue) { lock (lockMe) { ExecuteWhilePaused(sectionName, new ActionTakenWhilePaused(actionCommand.Execute)); AddSection(sectionName, configValue); } }