private void AddModificationToUndoRedoManager(IModification modification) { if ((UndoRedoManager != null) && (modification is IUndoableRedoable)) { //To do: Dodanie nie ustawialnej listy nie wspieranych przez undoRedoManager typów modyfikacji if (modification is SubtitlesEditStateModification) { return; } //else if ((modification is CompositeModification) && (UndoRedoManager.LastUndoableRedoable is CompositeModification)) //{ ////Co z sytuacją keidy mamy tylko SubtitlesContentModification, a nie composite? //var currentCompositeMod = (CompositeModification)modification; //var currentContentMods = from mod in currentCompositeMod where mod is SubtitlesContentModification select mod; //var lastCompositeMod = (CompositeModification)UndoRedoManager.LastUndoableRedoable; //var lastContentMods = from mod in lastCompositeMod where mod is SubtitlesContentModification select mod; //if (new HashSet<IModification>(currentContentMods).SetEquals(lastContentMods)) //{ // UndoRedoManager.DeleteLastUndoableRedoeable(); //} //} UndoRedoManager.AddUndoableRedoable(modification as IUndoableRedoable); } }
public static void DoModificationWithSelectionTracking(IModification mod, ComboBox animBox, ListBox frameBox, ListBox frameSpriteBox) { mod.SetPreChangeSelection(new SelectionState(animBox, frameBox, frameSpriteBox)); mod.Do(); mod.SetPostChangeSelection(new SelectionState(animBox, frameBox, frameSpriteBox)); Console.WriteLine("Perform: " + mod); }
/// <summary> /// Revert passed modification, if found in queue. /// </summary> /// <param name="modification">Modification to revert.</param> public void RevertModification(IModification modification) { // Find match. var match = _queue.FirstOrDefault(x => x == modification); // Can't revert a modification not in the queue. if (match == null) { throw new ArgumentException($"Modification [{modification}] not found, cannot revert."); } // Can't revert unless execution already took place. if (match.Status != Status.ExecuteSucceeded) { throw new ArgumentException($"Modification [{modification}] 'Status' must be Status.ExecuteSucceeded to revert."); } // Revert modification. match.Revert(); // Update status and remove from queue. if (match.Status == Status.RevertSucceeded) { _queue.Remove(match); } }
/// <summary> /// Register a modification that can be brought with scraps in the modification menu /// </summary> /// <param name="modificationTarget">The type of something that can be modified (drone upgrade for example)</param> /// <param name="modification">An instance of the modification</param> public void RegisterModificationFor(Type modificationTarget, IModification modification) { if (!modificationsByType.ContainsKey(modificationTarget)) { modificationsByType[modificationTarget] = new List <IModification>(); } modificationsByType[modificationTarget].Add(modification); }
protected override void Initialize(object parameter) { _modification = parameter as IModification; if (_modification == null) { return; } this.NotifyPropertyChanged("Modification"); }
public void Add(IModification change) { if (position < changes.Count - 1) { changes.RemoveRange(position + 1, changes.Count - 1 - position); } changes.Add(change); position = changes.Count - 1; OnHistoryUpdated(); }
public bool Equals(IModification <MySolution> other_) { MyModification other = other_ as MyModification; if (other == null) { return(false); } return(true); }
private void AssignModificationTarget(IModification modification) { if (modification is IModificationSource <SubtitlesEditor> ) { var mod = modification as IModificationSource <SubtitlesEditor>; if (mod.ModificationTarget == null) { mod.ModificationTarget = this; } } }
public static Account ApplyChanges(object parent, IModification <Account> mod, EntityContext context) { Account acct = context.ApplyChanges(parent, mod); if (mod.Type == ModificationType.Add) { acct.Password = CryptoUtil.HashPassword(acct.Password); acct.DateAdded = DateTime.UtcNow; } acct.Status = ACCOUNT_STATUS.ACTIVE; acct.LastLoginDate = DateTime.UtcNow; return(acct); }
internal void AddUndoOperation([NotNull] IModification m) { if (_RedoStack.Count > 0) { foreach (var md in _RedoStack) { md.Dispose(); } _RedoStack.Clear(); } _UndoStack.Push(m); Course.NotifyChanged(); }
public void Redo() { #if CHECKERS if (!CanRedo) { throw new InvalidOperationException(); } #endif IModification m = _RedoStack.Pop(); m.Redo(); _UndoStack.Push(m); Course.NotifyChanged(); }
private SubtitlesEditState TryGetModifiedEditState() { //Jeśli modyfikacja należy do grupy modyfikacji //to sprawdzamy czy następna modyfikacja w grupie jest modyfikacją stanu edytowania. if ((Group != null) && (GroupIndex + 1 < Group.Count)) { IModification mod = Group[GroupIndex + 1]; if (mod is SubtitlesEditStateModification) { return((mod as SubtitlesEditStateModification).ModifiedState); } } return(null); }
/// <summary> /// Wykonuje wskazana modyfikację. /// </summary> /// <param name="modification">Obiekt implementujący interfejs modyfikacji.</param> /// <remarks> /// </remarks> public void PerformModification(IModification modification) { if (modification is CompositeModification) { foreach (var mod in (modification as CompositeModification)) { AssignModificationTarget(mod); } } else { AssignModificationTarget(modification); } modification.Perform(); AddModificationToUndoRedoManager(modification); }
public void RevertModification(IModification modification) { var match = _queue.FirstOrDefault(x => x == modification); if (match == null) { throw new ArgumentException("Modification not found"); } if (match.Status != Status.ExecuteSucceeded) { throw new ArgumentException("Modification must be be..."); } match.Revert(); if (match.Status == Status.RevertSucceeded) { _queue.Remove(match); } }
public void AddModification(IModification modification) { _queue.Add(modification); }
public void ApplyChange(IModification <T> newModification) { Commit(newModification); }
private async Task OnItemClickCommand(IModification arg) { NavigationServiceCustom.NavigateTo <ModificationPageVm>(arg); }
//protected void Inject_ClassCreationHook(ClassCreationHook classCreationHook) //{ // var meth = MethodBaseToMethodDefinition(classCreationHook.InterceptCreationInMethod); // //var conType = Module.Import(classCreationHook.ClassToInterceptCreation); // var ilgen = meth.Body.GetILProcessor(); // for (var i = 0; i < meth.Body.Instructions.Count; i++) // { // var ins = meth.Body.Instructions[i]; // if (ins.OpCode == OpCodes.Newobj) // { // var trgMeth = ins.Operand as MethodReference; // if (Helper_TypeReference_to_Type(trgMeth.DeclaringType) == classCreationHook.ClassToInterceptCreation) // //if ((trgMeth.DeclaringType == conType) && trgMeth.Name == ".ctor") // { // meth.Body.Instructions[i] = ilgen.Create(OpCodes.Call, Module.Import(classCreationHook.CustomCreationMethod)); // } // } // } // //throw new NotImplementedException(); //} internal void InjectModification(IModification modification) { if (modification == null) { throw new Exception("Modification is null."); } if (modification is MethodHook) { InjectHook(modification as MethodHook); } else if (modification is MethodAddVirtual) { Inject_Virtual(modification as MethodAddVirtual); } else if (modification is MethodRefHook) { Inject_RefHook(modification as MethodRefHook); } else if (modification is EnumAddElement) { Inject_AddEnumElement(modification as EnumAddElement); } else if (modification is ClassChangeBase) { Inject_ClassChangeBase(modification as ClassChangeBase); } //else if (modification is ClassCreationHook) //{ // Inject_ClassCreationHook(modification as ClassCreationHook); //} else if (modification is IModificationCollection) { foreach (var subModification in (modification as IModificationCollection)) { InjectModification(subModification); } } else { throw new Exception("Unknown change " + modification.GetType().FullName + "; failed to apply!"); } }
public void Add(IModification modification) { modifications.Add(modification); }
private void DoModification(IModification mod) { ModHelper.DoModificationWithSelectionTracking(mod, animationBox, frameListBox, frameSpriteListBox); undoHistory.Add(mod); }
public static void RedoAndRestoreSelection(IModification mod, ComboBox animBox, ListBox frameBox, ListBox frameSpriteBox) { mod.Do(); RestoreSelection(mod.GetPostChangeSelection(), animBox, frameBox, frameSpriteBox); Console.WriteLine("Redo: " + mod); }
void OnGUI() { if (implementations == null || implementations.Length == 0) { SearchConfigurationModifiers(); } GUILayout.Label("Essentials Settings", EditorStyles.boldLabel); GUILayout.Label(""); if (implementations != null && implementations.Length != 0) { GUILayout.Label("Recommended modifications:"); EditorGUILayout.BeginHorizontal(); EditorGUILayout.BeginVertical(); foreach (var modificationType in implementations) { IModification modification = (IModification)Activator.CreateInstance(modificationType); if (!modification.showInSettingsWindow) { continue; } GUILayout.Label($" • {modification.title}"); } EditorGUILayout.EndVertical(); EditorGUILayout.BeginVertical(); foreach (var modificationType in implementations) { IModification modification = (IModification)Activator.CreateInstance(modificationType); if (!modification.showInSettingsWindow) { continue; } EditorGUILayout.BeginHorizontal(); if (GUILayout.Button(new GUIContent(modification.infoButtonText, $"Open {modification.infoURL}"))) { modification.OpenInfoURL(); } GUILayout.Label(""); //Separation GUILayout.Label(""); //Separation if (GUILayout.Button(new GUIContent(modification.applyButtonText, modification.applyModificationShortEplanation))) { modification.Apply(); } if (GUILayout.Button(new GUIContent(modification.revertButtonText, modification.revertModificationShortEplanation))) { modification.Revert(); } EditorGUILayout.EndHorizontal(); } EditorGUILayout.EndVertical(); EditorGUILayout.EndHorizontal(); GUILayout.Label(""); EditorGUILayout.BeginHorizontal(); if (GUILayout.Button("Apply all")) { foreach (var modificationType in implementations) { IModification modification = (IModification)Activator.CreateInstance(modificationType); modification.Apply(); } } if (GUILayout.Button("Revert all")) { foreach (var modificationType in implementations) { IModification modification = (IModification)Activator.CreateInstance(modificationType); modification.Revert(); } } EditorGUILayout.EndHorizontal(); GUILayout.Label(""); } GUILayout.Label(""); #region Tooltip GUIStyle style = GUI.skin.label; //get the current style of the GUI; TextAnchor defaultAlignment = style.alignment; // Expected: TextAnchor.MiddleLeft style.alignment = TextAnchor.MiddleRight; GUILayout.Label(GUI.tooltip, style); style.alignment = defaultAlignment; #endregion EditorGUILayout.BeginHorizontal(); if (implementations != null) { EditorGUILayout.LabelField($"Found {implementations.Count()} modifications", EditorStyles.helpBox); } if (implementations == null) { EditorGUILayout.LabelField($"NO IMPLEMENTATIONS FOUND"); } if (GUILayout.Button(new GUIContent("Search for modifications", "Search for any implementation of the abstract class 'Modification' to be displayed in this window.")) && implementations == null) { SearchConfigurationModifiers(); } EditorGUILayout.EndHorizontal(); }