public void CopyOntoSelf(IAEActionViewModel source) { if (source.AEAction != AEAction) { return; } this.EatOrNotToEat = (source as FoodViewModel).EatOrNotToEat; }
public override void CopyOntoSelf(IAEActionViewModel source) { base.CopyOntoSelf(source); var sourceObject = source as EXPBattleViewModel; this.Loop = sourceObject.Loop; SelectedLeftRight = new ObservableCollection <Action>(sourceObject.SelectedLeftRight); }
public virtual void CopyOntoSelf(IAEActionViewModel source) { if (source.AEAction != AEAction || source.Equals(this)) { return; } var sourceObject = source as TrashMobBattleViewModel; this.CopyTurnList(sourceObject.TurnList); }
public void CopyOntoSelf(IAEActionViewModel source) { if (source.AEAction != AEAction || source.Equals(this)) { return; } var sourceObject = source as WaitViewModel; this.WaitTime = sourceObject.WaitTime; }
/// <summary> /// Generate script for the selected AEaction only /// </summary> /// <param name="macro">The macro template</param> /// <param name="aEActionList">the aeaction to generate script</param> /// <returns></returns> public bool?GenerateScript(MacroTemplate macro, IAEActionViewModel aEAction) { if (!ApplyConvertSetting(macro)) { return(false); } var actionList = ScaleActionsToMacroResolution(macro, aEAction.UserChoicesToActionList()); var script = this.emulatorToScriptFactory.GetEmulatorScriptGenerator(setting.SelectedEmulator).MacroToScript(actionList); return(scriptApplyFactory.GetScriptApplier(setting.SelectedEmulator).ApplyScriptTo(string.IsNullOrEmpty(setting.CustomName) ? macro.MacroName + "_Test" : setting.CustomName + "_Test", setting.SelectedPath, script, false)); }
public override void CopyOntoSelf(IAEActionViewModel source) { if (source.AEAction != AEAction || source.Equals(this)) { return; } base.CopyOntoSelf(source); var sourceObject = source as EXPBattleViewModel; this.Loop = sourceObject.Loop; this.BattleExitTime = sourceObject.BattleExitTime; SelectedLeftRight = new ObservableCollection <Action>(sourceObject.SelectedLeftRight); }
/// <summary> /// Generate script for the selected AEaction only /// </summary> /// <param name="macro">The macro template</param> /// <param name="aEActionList">the aeaction to generate script</param> /// <returns></returns> public bool?GenerateScript(MacroTemplate macro, IAEActionViewModel aEAction) { var timer = 200; if (!ApplyConvertSetting(macro)) { return(false); } var actionList = ScaleActionsToMacroResolution(macro, aEAction.UserChoicesToActionList()); var script = new StringBuilder(); foreach (var action in actionList) { script.Append(action.GenerateAction(ref timer)); } return(scriptApplyFactory.GetScriptApplier(setting.SelectedEmulator).ApplyScriptTo(string.IsNullOrEmpty(setting.CustomName) ? macro.MacroName + "_Test": setting.CustomName + "_Test", setting.SelectedPath, script, false)); }
private void InitializeCommandAndEvents() { CopyCommand = new RelayCommand(p => { this.copyAEAction = this.SelectedAEAction; }, p => SelectedAEAction != null); ApplyCommand = new RelayCommand(p => { foreach (var action in AEActionList.GetSelectedElement()) { if (action.AEAction == copyAEAction.AEAction) { action.CopyOntoSelf(copyAEAction); } } ; }, p => this.copyAEAction != null); this.macroManager.SelectChanged += (sender, e) => { if (AEActionList == null) { AEActionList = new ObservableCollection <IAEActionViewModel>(); } AEActionList.Clear(); foreach (var a in macroManager.GetCurrentAEActionList()) { AEActionList.Add(a); } this.copyAEAction = null; }; }
private void InitializeCommandAndEvents() { CopyCommand = new RelayCommand(p => { this.copyAEAction = this.SelectedAEAction; }, p => SelectedAEAction != null); ApplyCommand = new RelayCommand(p => { foreach (var action in AEActionList.GetSelectedElement()) { if (action.AEAction == copyAEAction.AEAction) { action.CopyOntoSelf(copyAEAction); } } ; }, p => this.copyAEAction != null); OpenSavedDialogCommand = new RelayCommand(p => { IsSavedSetupDialogOpen = true; }, p => SelectedAEAction != null); CloseSavedDialogCommand = new RelayCommand(p => { IsSavedSetupDialogOpen = false; }, p => IsSavedSetupDialogOpen == true); SaveCommand = new RelayCommand(p => { var action = this.SelectedAEAction.ConvertBackToAction(); action.Name = SavedSetupName; repository.Add(action); if (!repository.SaveChange()) { messageBoxService.ShowMessageBox("Can not save your setup. Check the permission to the folder", "ERROR", MessageButton.OK, MessageImage.Error); } else { SavedAEActions.Add(action); IsSavedSetupDialogOpen = false; } }, p => SelectedAEAction != null && !string.IsNullOrWhiteSpace(SavedSetupName)); LoadCommand = new RelayCommand(p => { if (!(p is IAEAction aeAction)) { return; } foreach (var action in AEActionList.GetSelectedElement()) { if (action.AEAction == aeAction.AEAction) { action.ConvertFromAction(aeAction); } } ; }, p => SavedAEActions.Count > 0); RemoveCommand = new RelayCommand(p => { if (!(p is IAEAction aeAction)) { return; } repository.Remove(aeAction); if (!repository.SaveChange()) { messageBoxService.ShowMessageBox("Can not remove the saved setup. Check the permission to the folder", "ERROR", MessageButton.OK, MessageImage.Error); } else { SavedAEActions?.Remove(aeAction); } }, p => SavedAEActions.Count > 0); this.macroManager.SelectChanged += (sender, e) => { var newList = macroManager.GetCurrentAEActionList(); AEActionList.Clear(); if (newList != null) { foreach (var a in newList) { AEActionList.Add(a); } } this.copyAEAction = null; }; this.macroManager.BeforeMacroReloaded += (sender, e) => { oldList = new List <IAEActionViewModel>(AEActionList); }; this.macroManager.AfterMacroReloaded += (sender, e) => { if (oldList != null) { var count = oldList.Count < AEActionList.Count ? oldList.Count : AEActionList.Count; for (int i = 0; i < count; i++) { AEActionList[i].CopyOntoSelf(oldList[i]); } } }; this.macroManager.MacroProfileSelected += (sender, e) => { if (e == null || e.Profile.Setups?.Count == 0) { return; } ApplyProfile(e.Profile); }; this.macroManager.MacroSaveLoaded += (sender, e) => { if (e == null || e.Save == null) { return; } ApplyProfile(e.Save.DefaultProfile); }; }