public void Setup() { m_HoveredBone = -1; m_View = Substitute.For <IBindPoseView>(); m_View.hoveredBone.Returns(x => m_HoveredBone); m_SelectedBones = new List <int>(); m_Selection = Substitute.For <ISelection>(); m_Selection.Count.Returns(x => m_SelectedBones.Count); m_Selection.IsSelected(Arg.Any <int>()).Returns(x => m_SelectedBones.Contains((int)x[0])); m_Selection.GetEnumerator().Returns(x => m_SelectedBones.GetEnumerator()); m_Selection.single.Returns(x => { if (m_SelectedBones.Count == 1) { return(m_SelectedBones[0]); } return(-1); }); m_UndoObject = Substitute.For <IUndoObject>(); m_SpriteMeshData = new SpriteMeshData(); m_SpriteMeshData.frame = new Rect(0f, 0f, 100f, 100f); m_SpriteMeshData.bones = CreateSpriteBoneData(); m_BindPoseController = new BindPoseController(); m_BindPoseController.spriteMeshData = m_SpriteMeshData; m_BindPoseController.bindPoseView = m_View; m_BindPoseController.selection = m_Selection; m_BindPoseController.undoObject = m_UndoObject; }
public BoneGizmoController(IBoneGizmoView view, IUndoObject undo, IBoneGizmoToggle toggle) { m_BoneGizmoView = view; m_UndoObject = undo; m_BoneGizmoToggle = toggle; FindSkinComponents(); }
internal void MarkAsModified(IUndoObject obj) { obj.IsDirty = true; if (obj.SavedCommand == 0) { obj.SavedCommand = currentCommandCounter; } }
public void MarkAsModified(IUndoObject obj) { if (obj.SavedCommand == 0) { obj.SavedCommand = currentCommandCounter; } WriteIsDirty(obj, true); }
public void Setup() { m_UndoObject = new TestUndo(); m_EditablePath = new EditablePath(); m_Controller = new EditablePathController(); m_Controller.editablePath = m_EditablePath; m_EditablePath.undoObject = m_UndoObject; }
void NotifyEvent(UndoCommandManagerEventType type, IUndoObject obj = null) { var evt = OnEvent; if (evt != null) { evt(this, new UndoCommandManagerEventArgs(type, obj)); } }
public void Setup() { m_UndoObject = new TestUndo(); m_EditablePath1 = new EditablePath(); m_EditablePath2 = new EditablePath(); m_Controller = new MultipleEditablePathController(); m_Controller.AddPath(m_EditablePath1); m_Controller.AddPath(m_EditablePath2); m_Controller.editablePath = m_EditablePath1; m_EditablePath1.undoObject = m_UndoObject; m_EditablePath2.undoObject = m_UndoObject; }
bool IUndoableDocumentsProvider.OnExecutedOneCommand(IUndoObject obj) { var file = TryGetDnSpyFile(obj); if (file != null) { var module = file.ModuleDef; if (module != null) module.ResetTypeDefFindCache(); fileTabManager.RefreshModifiedFile(file); return true; } return false; }
bool IUndoableDocumentsProvider.OnExecutedOneCommand(IUndoObject obj) { var file = TryGetDocument(obj); if (file != null) { var module = file.ModuleDef; if (module != null) module.ResetTypeDefFindCache(); documentTabService.RefreshModifiedDocument(file); return true; } return false; }
public bool WasSaved(IUndoObject obj) { var data = GetSaveOptionsVM(obj); if (data == null) { return(false); } bool saved; savedFile.TryGetValue(data, out saved); return(saved); }
void WriteIsDirty(IUndoObject obj, bool newIsDirty) { // Always call NotifyEvent() even when value doesn't change. obj.IsDirty = newIsDirty; if (newIsDirty) { NotifyEvent(UndoCommandServiceEventType.Dirty, obj); } else { NotifyEvent(UndoCommandServiceEventType.Saved, obj); } }
object GetDocument(IUndoObject uo) { foreach (var p in undoableDocumentsProviders) { var doc = p.Value.GetDocument(uo); if (doc != null) { return(doc); } } Debug.Fail("Couldn't get the document"); return(null); }
int GetNewSavedCommand(IUndoObject obj) { for (int i = undoCommands.Count - 1; i >= 0; i--) { var group = undoCommands[i]; if (group.ModifiedObjects.Contains(obj)) { return(group.CommandCounter); } } if (undoCommands.Count > 0) { return(undoCommands[0].PrevCommandCounter); } return(currentCommandCounter); }
bool IUndoableDocumentsProvider.OnExecutedOneCommand(IUndoObject obj) { var file = TryGetDocument(obj); if (file != null) { var module = file.ModuleDef; if (module != null) { module.ResetTypeDefFindCache(); } documentTabService.RefreshModifiedDocument(file); return(true); } return(false); }
bool IUndoableDocumentsProvider.OnExecutedOneCommand(IUndoObject obj) { var file = TryGetDnSpyFile(obj); if (file != null) { var module = file.ModuleDef; if (module != null) { module.ResetTypeDefFindCache(); } fileTabManager.RefreshModifiedFile(file); return(true); } return(false); }
public void Setup() { m_Triangulator = new Triangulator(); m_Selection = Substitute.For <ISelection>(); m_UndoObject = Substitute.For <IUndoObject>(); m_SpriteMeshData = new SpriteMeshData(); m_SpriteMeshData.bones = CreateBones(); m_SpriteMeshData.vertices = CreateVertices(); m_SpriteMeshData.edges = CreateEdges(); m_SpriteMeshData.Triangulate(m_Triangulator); m_WeightEditor = new WeightEditor(); m_WeightEditor.spriteMeshData = m_SpriteMeshData; m_WeightEditor.selection = m_Selection; m_WeightEditor.undoObject = m_UndoObject; }
static SaveOptionsVM Create(IUndoObject obj) { var file = UndoCommandManager.Instance.TryGetDnSpyFile(obj); if (file != null) { return(new SaveModuleOptionsVM(file)); } var doc = UndoCommandManager.Instance.TryGetAsmEdHexDocument(obj); if (doc != null) { return(new SaveHexOptionsVM(doc)); } throw new InvalidOperationException(); }
static SaveOptionsVM Create(IUndoObject obj) { var asm = obj as LoadedAssembly; if (asm != null) { return(new SaveModuleOptionsVM(asm)); } var doc = obj as AsmEdHexDocument; if (doc != null) { return(new SaveHexOptionsVM(doc)); } throw new InvalidOperationException(); }
public void Setup() { var go = new GameObject("TestObject"); m_SkinnedSprite = AssetDatabase.LoadAssetAtPath <Sprite>("Assets/Temp/bird.png"); m_SpriteSkin = go.AddComponent <SpriteSkin>(); m_SpriteSkin.spriteRenderer.sprite = m_SkinnedSprite; m_SpriteSkin.CreateBoneHierarchy(); m_BoneGizmoView = Substitute.For <IBoneGizmoView>(); m_BoneGizmoView.IsBoneVisible(Arg.Any <Transform>(), Arg.Any <float>(), Arg.Any <float>()).Returns(x => { return(true); }); m_BoneGizmoView.IsActionHot(BoneGizmoAction.None).Returns(x => { return(true); }); m_BoneGizmoView.CanLayout().Returns(x => { return(true); }); m_UndoObject = Substitute.For <IUndoObject>(); m_BoneGizmoToggle = Substitute.For <IBoneGizmoToggle>(); m_BoneGizmoToggle.enableGizmos.Returns(x => { return(true); }); m_BoneGizmoController = new BoneGizmoController(m_BoneGizmoView, m_UndoObject, m_BoneGizmoToggle); }
public void Setup() { m_MousePosition = Vector2.zero; m_HoveredVertex = -1; m_HoveredEdge = -1; m_ClosestEdge = -1; m_View = Substitute.For <ISpriteMeshView>(); m_View.mouseWorldPosition.Returns(x => m_MousePosition); m_View.hoveredVertex.Returns(x => m_HoveredVertex); m_View.hoveredEdge.Returns(x => m_HoveredEdge); m_View.closestEdge.Returns(x => m_ClosestEdge); m_View.WorldToScreen(Arg.Any <Vector2>()).Returns(x => ((Vector2)x[0] * 100f)); m_SelectedVertices = new List <int>(); m_Selection = Substitute.For <ISelection>(); m_Selection.Count.Returns(x => m_SelectedVertices.Count); m_Selection.IsSelected(Arg.Any <int>()).Returns(x => m_SelectedVertices.Contains((int)x[0])); m_Selection.GetEnumerator().Returns(x => m_SelectedVertices.GetEnumerator()); m_Selection.single.Returns(x => { if (m_SelectedVertices.Count == 1) { return(m_SelectedVertices[0]); } return(-1); }); m_UndoObject = Substitute.For <IUndoObject>(); m_Triangulator = Substitute.For <ITriangulator>(); m_SpriteMeshData = new SpriteMeshData(); m_SpriteMeshData.frame = new Rect(0f, 0f, 100f, 100f); m_SpriteMeshController = new SpriteMeshController(); m_SpriteMeshController.spriteMeshData = m_SpriteMeshData; m_SpriteMeshController.spriteMeshView = m_View; m_SpriteMeshController.selection = m_Selection; m_SpriteMeshController.undoObject = m_UndoObject; m_SpriteMeshController.triangulator = m_Triangulator; }
static bool MarkAsSaved(SaveMultiModuleVM vm, IUndoObject[] objs) { bool setNewFileName = false; bool allSaved = true; foreach (var obj in objs) { if (!vm.WasSaved(obj)) allSaved = false; else { UndoCommandManager.Instance.MarkAsSaved(obj); var file = UndoCommandManager.Instance.TryGetDnSpyFile(obj); if (file != null && string.IsNullOrEmpty(file.Filename)) { var filename = vm.GetSavedFileName(obj); if (!string.IsNullOrWhiteSpace(filename) && file.ModuleDef != null) { file.ModuleDef.Location = filename; file.Filename = filename; setNewFileName = true; var asmNode = MainWindow.Instance.FindTreeNode(file.ModuleDef) as AssemblyTreeNode; Debug.Assert(asmNode != null); if (asmNode != null) { asmNode.OnFileNameChanged(); Utils.NotifyModifiedAssembly(file); } } } } } if (setNewFileName) MainWindow.Instance.DnSpyFileListManager.RefreshSave(MainWindow.Instance.DnSpyFileList); return allSaved; }
object IUndoableDocumentsProvider.GetDocument(IUndoObject obj) { return TryGetDnSpyFile(obj); }
public void MarkAsSaved(IUndoObject obj) { obj.SavedCommand = GetNewSavedCommand(obj); WriteIsDirty(obj, false); }
public UndoCommandManagerEventArgs(UndoCommandManagerEventType type, IUndoObject obj) { this.Type = type; this.UndoObject = obj; }
bool IsModifiedCounter(IUndoObject obj, int counter) => obj.SavedCommand != 0 && obj.SavedCommand != counter;
object IUndoableDocumentsProvider.GetDocument(IUndoObject obj) { return TryGetAsmEdHexDocument(obj); }
static SaveOptionsVM Create(IUndoObject obj) { var file = UndoCommandManager.Instance.TryGetDnSpyFile(obj); if (file != null) return new SaveModuleOptionsVM(file); var doc = UndoCommandManager.Instance.TryGetAsmEdHexDocument(obj); if (doc != null) return new SaveHexOptionsVM(doc); throw new InvalidOperationException(); }
int GetNewSavedCommand(IUndoObject obj) { for (int i = undoCommands.Count - 1; i >= 0; i--) { var group = undoCommands[i]; if (group.ModifiedObjects.Contains(obj)) return group.CommandCounter; } if (undoCommands.Count > 0) return undoCommands[0].PrevCommandCounter; return currentCommandCounter; }
public UndoCommandManagerEventArgs(UndoCommandManagerEventType type, IUndoObject obj) { this.Type = type; this.UndoObject = obj; }
internal static AsmEdHexDocument TryGetAsmEdHexDocument(IUndoObject iuo) => (iuo as UndoObject)?.Value as AsmEdHexDocument;
public void MarkAsSaved(IUndoObject obj) { obj.IsDirty = false; obj.SavedCommand = GetNewSavedCommand(obj); NotifyEvent(UndoCommandManagerEventType.Saved); }
bool IUndoableDocumentsProvider.OnExecutedOneCommand(IUndoObject obj) => TryGetAsmEdHexDocument(obj) != null;
static SaveOptionsVM Create(IUndoObject obj) { var asm = obj as LoadedAssembly; if (asm != null) return new SaveModuleOptionsVM(asm); var doc = obj as AsmEdHexDocument; if (doc != null) return new SaveHexOptionsVM(doc); throw new InvalidOperationException(); }
bool IUndoableDocumentsProvider.OnExecutedOneCommand(IUndoObject obj) { return TryGetAsmEdHexDocument(obj) != null; }
public UndoCommandServiceEventArgs(UndoCommandServiceEventType type, IUndoObject obj) { Type = type; UndoObject = obj; }
public bool WasSaved(IUndoObject obj) { var data = GetSaveOptionsVM(obj); if (data == null) return false; bool saved; savedFile.TryGetValue(data, out saved); return saved; }
public static IDsDocument TryGetDocument(IUndoObject iuo) => (iuo as UndoObject)?.Value as IDsDocument;
internal static AsmEdHexDocument TryGetAsmEdHexDocument(IUndoObject iuo) { var uo = iuo as UndoObject; return uo == null ? null : uo.Value as AsmEdHexDocument; }
object IUndoableDocumentsProvider.GetDocument(IUndoObject obj) => TryGetDocument(obj);
public bool IsModified(IUndoObject obj) => obj.IsDirty && IsModifiedCounter(obj, currentCommandCounter);
SaveOptionsVM GetSaveOptionsVM(IUndoObject obj) { return modules.FirstOrDefault(a => a.UndoObject == obj); }
internal static HexBuffer TryGetHexBuffer(IUndoObject iuo) => (iuo as UndoObject)?.Value as HexBuffer;
public string GetSavedFileName(IUndoObject obj) { var data = GetSaveOptionsVM(obj); return data == null ? null : data.FileName; }
public DnSpyFile TryGetDnSpyFile(IUndoObject iuo) { var uo = iuo as UndoObject; return uo == null ? null : uo.Value as DnSpyFile; }
SaveOptionsVM GetSaveOptionsVM(IUndoObject obj) { return(modules.FirstOrDefault(a => a.UndoObject == obj)); }
bool IsModifiedCounter(IUndoObject obj, int counter) { return(obj.SavedCommand != 0 && obj.SavedCommand != counter); }
public string GetSavedFileName(IUndoObject obj) { var data = GetSaveOptionsVM(obj); return(data == null ? null : data.FileName); }
object GetDocument(IUndoObject uo) { foreach (var p in undoableDocumentsProviders) { var doc = p.Value.GetDocument(uo); if (doc != null) return doc; } Debug.Fail("Couldn't get the document"); return null; }
object IUndoableDocumentsProvider.GetDocument(IUndoObject obj) => TryGetAsmEdHexDocument(obj);
public void MarkAsModified(IUndoObject obj) { if (obj.SavedCommand == 0) obj.SavedCommand = currentCommandCounter; WriteIsDirty(obj, true); }
public bool IsModified(IUndoObject obj) { return obj.IsDirty && IsModifiedCounter(obj, currentCommandCounter); }
public void MarkAsSaved(IUndoObject obj) { obj.SavedCommand = GetNewSavedCommand(obj); WriteIsDirty(obj, false); }
internal void MarkAsModified(IUndoObject obj) { obj.IsDirty = true; if (obj.SavedCommand == 0) obj.SavedCommand = currentCommandCounter; }
void WriteIsDirty(IUndoObject obj, bool newIsDirty) { // Always call NotifyEvent() even when value doesn't change. obj.IsDirty = newIsDirty; if (newIsDirty) NotifyEvent(UndoCommandManagerEventType.Dirty, obj); else NotifyEvent(UndoCommandManagerEventType.Saved, obj); }
bool IsModifiedCounter(IUndoObject obj, int counter) { return obj.SavedCommand != 0 && obj.SavedCommand != counter; }
void NotifyEvent(UndoCommandManagerEventType type, IUndoObject obj = null) { var evt = OnEvent; if (evt != null) evt(this, new UndoCommandManagerEventArgs(type, obj)); }
static bool MarkAsSaved(SaveMultiModuleVM vm, IUndoObject[] objs) { bool setNewFileName = false; bool allSaved = true; foreach (var obj in objs) { if (!vm.WasSaved(obj)) allSaved = false; else { UndoCommandManager.Instance.MarkAsSaved(obj); var asm = obj as LoadedAssembly; if (asm != null && string.IsNullOrEmpty(asm.FileName)) { var filename = vm.GetSavedFileName(asm); if (!string.IsNullOrWhiteSpace(filename)) { asm.ModuleDefinition.Location = filename; asm.FileName = filename; setNewFileName = true; var asmNode = MainWindow.Instance.FindTreeNode(asm.ModuleDefinition) as AssemblyTreeNode; Debug.Assert(asmNode != null); if (asmNode != null) { asmNode.OnFileNameChanged(); Utils.NotifyModifiedAssembly(asm); } } } } } if (setNewFileName) MainWindow.Instance.CurrentAssemblyList.RefreshSave(); return allSaved; }
void NotifyEvent(UndoCommandServiceEventType type, IUndoObject obj = null) { UndoRedoChanged(); OnEvent?.Invoke(this, new UndoCommandServiceEventArgs(type, obj)); }