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;
        }
Ejemplo n.º 2
0
        public BoneGizmoController(IBoneGizmoView view, IUndoObject undo, IBoneGizmoToggle toggle)
        {
            m_BoneGizmoView   = view;
            m_UndoObject      = undo;
            m_BoneGizmoToggle = toggle;

            FindSkinComponents();
        }
Ejemplo n.º 3
0
 internal void MarkAsModified(IUndoObject obj)
 {
     obj.IsDirty = true;
     if (obj.SavedCommand == 0)
     {
         obj.SavedCommand = currentCommandCounter;
     }
 }
Ejemplo n.º 4
0
 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;
 }
Ejemplo n.º 6
0
        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;
		}
Ejemplo n.º 10
0
        public bool WasSaved(IUndoObject obj)
        {
            var data = GetSaveOptionsVM(obj);

            if (data == null)
            {
                return(false);
            }
            bool saved;

            savedFile.TryGetValue(data, out saved);
            return(saved);
        }
Ejemplo n.º 11
0
 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);
     }
 }
Ejemplo n.º 12
0
        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);
        }
Ejemplo n.º 13
0
 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;
        }
Ejemplo n.º 17
0
        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();
        }
Ejemplo n.º 18
0
        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);
        }
Ejemplo n.º 20
0
        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;
        }
Ejemplo n.º 21
0
		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);
		}
Ejemplo n.º 23
0
 public void MarkAsSaved(IUndoObject obj)
 {
     obj.SavedCommand = GetNewSavedCommand(obj);
     WriteIsDirty(obj, false);
 }
Ejemplo n.º 24
0
 public UndoCommandManagerEventArgs(UndoCommandManagerEventType type, IUndoObject obj)
 {
     this.Type       = type;
     this.UndoObject = obj;
 }
Ejemplo n.º 25
0
 bool IsModifiedCounter(IUndoObject obj, int counter) => obj.SavedCommand != 0 && obj.SavedCommand != counter;
		object IUndoableDocumentsProvider.GetDocument(IUndoObject obj) {
			return TryGetAsmEdHexDocument(obj);
		}
Ejemplo n.º 27
0
		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();
		}
Ejemplo n.º 28
0
 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;
 }
Ejemplo n.º 29
0
		public UndoCommandManagerEventArgs(UndoCommandManagerEventType type, IUndoObject obj) {
			this.Type = type;
			this.UndoObject = obj;
		}
Ejemplo n.º 30
0
 internal static AsmEdHexDocument TryGetAsmEdHexDocument(IUndoObject iuo) => (iuo as UndoObject)?.Value as AsmEdHexDocument;
Ejemplo n.º 31
0
 public void MarkAsSaved(IUndoObject obj)
 {
     obj.IsDirty = false;
     obj.SavedCommand = GetNewSavedCommand(obj);
     NotifyEvent(UndoCommandManagerEventType.Saved);
 }
Ejemplo n.º 32
0
 bool IUndoableDocumentsProvider.OnExecutedOneCommand(IUndoObject obj) => TryGetAsmEdHexDocument(obj) != null;
Ejemplo n.º 33
0
		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;
		}
Ejemplo n.º 36
0
		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);
Ejemplo n.º 40
0
 public bool IsModified(IUndoObject obj) => obj.IsDirty && IsModifiedCounter(obj, currentCommandCounter);
Ejemplo n.º 41
0
		SaveOptionsVM GetSaveOptionsVM(IUndoObject obj) {
			return modules.FirstOrDefault(a => a.UndoObject == obj);
		}
Ejemplo n.º 42
0
 internal static HexBuffer TryGetHexBuffer(IUndoObject iuo) => (iuo as UndoObject)?.Value as HexBuffer;
Ejemplo n.º 43
0
		public string GetSavedFileName(IUndoObject obj) {
			var data = GetSaveOptionsVM(obj);
			return data == null ? null : data.FileName;
		}
Ejemplo n.º 44
0
		public DnSpyFile TryGetDnSpyFile(IUndoObject iuo) {
			var uo = iuo as UndoObject;
			return uo == null ? null : uo.Value as DnSpyFile;
		}
Ejemplo n.º 45
0
 SaveOptionsVM GetSaveOptionsVM(IUndoObject obj)
 {
     return(modules.FirstOrDefault(a => a.UndoObject == obj));
 }
Ejemplo n.º 46
0
 bool IsModifiedCounter(IUndoObject obj, int counter)
 {
     return(obj.SavedCommand != 0 && obj.SavedCommand != counter);
 }
Ejemplo n.º 47
0
        public string GetSavedFileName(IUndoObject obj)
        {
            var data = GetSaveOptionsVM(obj);

            return(data == null ? null : data.FileName);
        }
Ejemplo n.º 48
0
		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;
		}
Ejemplo n.º 49
0
 object IUndoableDocumentsProvider.GetDocument(IUndoObject obj) => TryGetAsmEdHexDocument(obj);
Ejemplo n.º 50
0
		public void MarkAsModified(IUndoObject obj) {
			if (obj.SavedCommand == 0)
				obj.SavedCommand = currentCommandCounter;
			WriteIsDirty(obj, true);
		}
Ejemplo n.º 51
0
 public bool IsModified(IUndoObject obj)
 {
     return obj.IsDirty && IsModifiedCounter(obj, currentCommandCounter);
 }
Ejemplo n.º 52
0
		public void MarkAsSaved(IUndoObject obj) {
			obj.SavedCommand = GetNewSavedCommand(obj);
			WriteIsDirty(obj, false);
		}
Ejemplo n.º 53
0
 internal void MarkAsModified(IUndoObject obj)
 {
     obj.IsDirty = true;
     if (obj.SavedCommand == 0)
         obj.SavedCommand = currentCommandCounter;
 }
Ejemplo n.º 54
0
		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);
		}
Ejemplo n.º 55
0
 bool IsModifiedCounter(IUndoObject obj, int counter)
 {
     return obj.SavedCommand != 0 && obj.SavedCommand != counter;
 }
Ejemplo n.º 56
0
		void NotifyEvent(UndoCommandManagerEventType type, IUndoObject obj = null) {
			var evt = OnEvent;
			if (evt != null)
				evt(this, new UndoCommandManagerEventArgs(type, obj));
		}
Ejemplo n.º 57
0
 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;
 }
Ejemplo n.º 58
0
 void NotifyEvent(UndoCommandServiceEventType type, IUndoObject obj = null)
 {
     UndoRedoChanged();
     OnEvent?.Invoke(this, new UndoCommandServiceEventArgs(type, obj));
 }