private void _backward() { List <object> deletedList = new List <object>(); try { int lastIndex = MyBoardObjects.Count - 1; object obj = MyBoardObjects[lastIndex]; if (obj is MySketch) { MySketch tempSketch = obj as MySketch; int no_lines = tempSketch.pointsSet.Count - 1; ///<summary>To removet the no_lines number of lines</summary> MyBoard.Children.RemoveRange(MyBoard.Children.Count - no_lines, no_lines - 1); deletedList.Add(MyBoardObjects[lastIndex]); MyBoardObjects.RemoveAt(lastIndex); } else { deletedList.Add(MyBoardObjects[lastIndex]); MyBoardObjects.RemoveAt(lastIndex); MyBoard.Children.RemoveAt(MyBoard.Children.Count - 1); } deletedObjects.Push(deletedList); } catch (Exception) { } }
/// <summary> /// Remove the substroke and delete the parent shape if it is empty. /// </summary> protected override void performActual() { _shape.RemoveSubstroke(_substroke); if (_shape.IsEmpty) { MySketch.RemoveShape(_shape); } }
private void _forward() { List <object> lastObj; if (deletedObjects.Count == 0) { return; } lastObj = deletedObjects.Pop(); foreach (object obj in lastObj) { if (obj is MySketch) { MySketch mySketch = obj as MySketch; PointCollection points = mySketch.pointsSet; try { addLines(points); MyBoardObjects.Add(mySketch); } catch (Exception) { } } else if (obj is MyRectangle) { MyRectangle myrect = obj as MyRectangle; try { MyBoard.Children.Add(myrect.rect); MyBoardObjects.Add(myrect); } catch (Exception) { } } else if (obj is MyLine) { MyLine myline = obj as MyLine; try { MyBoard.Children.Add(myline._line); MyBoardObjects.Add(myline); } catch (Exception) { } } else if (obj is MyEllipse) { MyEllipse myelli = obj as MyEllipse; try { MyBoard.Children.Add(myelli.ellipse); MyBoardObjects.Add(myelli); } catch (Exception) { } } else { } } }
private object getSketch(object sender, MouseButtonEventArgs e) { PointCollection pointsColl = new PointCollection() { _start }; MySketch mysketch = new MySketch(pointsColl); MyBoardObjects.Add(mysketch); return(pointsColl); }
/// <summary> /// Make the substroke trade. /// </summary> protected override void performActual() { foreach (EndPoint endpoint in _gem.Endpoints) { endpoint.ConnectedShape = null; } Shape victim = _gem.ParentShape; if (victim != null) { victim.RemoveSubstroke(_gem); } _thief.AddSubstroke(_gem); if (victim != null && victim.Substrokes.Length == 0) { MySketch.RemoveShape(victim); } MySketch.CheckConsistency(); }
/// <summary> /// Connects the shapes and the endpoint's connected shape. /// </summary> protected override void performActual() { MySketch.connectShapes(_endpoint.ParentShape, _toConnect); _endpoint.ConnectedShape = _toConnect; }