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 MoveLineTest() //tests moving a line to a new location after it's connected class is moved { _testInvoker.Start(); Point Location1 = new Point(100, 102); Point Location2 = new Point(100, 110); AddCommand command3 = new AddCommand("Binary", Location1, Location2, testDrawing); _testInvoker.EnqueueCommandForExecution(command3); System.Threading.Thread.Sleep(1000); Point newLocation = new Point(0, 0); if (testDrawing._RelationShipLines[0].Location1 == Location1 || testDrawing._RelationShipLines[0].Location2 == Location1) { MoveLineCommand moveCommand = new MoveLineCommand(testDrawing._RelationShipLines[0], Location1, newLocation, testDrawing); _testInvoker.EnqueueCommandForExecution(moveCommand); } System.Threading.Thread.Sleep(1000); Assert.AreEqual(newLocation, testDrawing._RelationShipLines[0].Location1); }