public override void Trigger(object sender, MouseEventArgs e, Invoker invoker) { if (MainForm.selected1 == null) { Symbol foundSymbol = TargetDrawing.FindSymbolAtPosition(e.Location); if (foundSymbol == null) { } else if (foundSymbol.type == "Class") { MainForm.selected1 = foundSymbol as ClassSymbol; } } else if (MainForm.moveToLocation == MainForm.defaultLocation) { MainForm.moveToLocation = e.Location; } if (MainForm.selected1 != null && MainForm.moveToLocation != MainForm.defaultLocation) { for (int i = 0; i < TargetDrawing._RelationShipLines.Count; i++) { if (TargetDrawing._RelationShipLines[i].Location1 == MainForm.selected1.Location || TargetDrawing._RelationShipLines[i].Location2 == MainForm.selected1.Location) { MoveLineCommand moveCommand = new MoveLineCommand(TargetDrawing._RelationShipLines[i], MainForm.selected1.Location, MainForm.moveToLocation, TargetDrawing); invoker.EnqueueCommandForExecution(moveCommand); } } MoveClassCommand moveClass = new MoveClassCommand(MainForm.selected1, MainForm.moveToLocation, TargetDrawing); invoker.EnqueueCommandForExecution(moveClass); MainForm.selected1 = null; MainForm.moveToLocation = MainForm.defaultLocation; } }
public void MoveClassTest() //tests moving a class { _testInvoker.Start(); Point Location1 = new Point(100, 102); AddCommand command1 = new AddCommand("Class", Location1, Location1, testDrawing); _testInvoker.EnqueueCommandForExecution(command1); System.Threading.Thread.Sleep(1000); Symbol symbol = testDrawing.FindSymbolAtPosition(Location1); Point newLocation = new Point(0, 0); ClassSymbol classSymbol = symbol as ClassSymbol; MoveClassCommand cmd = new MoveClassCommand(classSymbol, newLocation, testDrawing); _testInvoker.EnqueueCommandForExecution(cmd); System.Threading.Thread.Sleep(1000); Assert.AreEqual(newLocation, testDrawing._ClassSymbols[0].Location); }