public ChangeRepresentationObject MakeChangeRepresentationObjectForEdit(ChangeRepresentationObject undostruct) { ChangeRepresentationObject ResizeStruct = new ChangeRepresentationObject(); ResizeStruct.Action = ActionType.Edit; if (undostruct.shape.GetType().Equals(typeof(Path))) { Path p = (Path)undostruct.shape; EllipseGeometry eg = (EllipseGeometry)p.Data; ResizeStruct.height = eg.RadiusY; ResizeStruct.Width = eg.RadiusX; } else { ResizeStruct.height = undostruct.shape.Height; ResizeStruct.Width = undostruct.shape.Width; } ResizeStruct.brush = undostruct.shape.Fill; ResizeStruct.shape = undostruct.shape; ResizeStruct.borderThickness = undostruct.shape.StrokeThickness; ResizeStruct.brushborder = undostruct.shape.Stroke; return(ResizeStruct); }
public void RedoPushInUnDoForDelete(Shape ApbOrDevice) { ChangeRepresentationObject dataobject = new ChangeRepresentationObject(); dataobject.Action = ActionType.Delete; dataobject.disablepoints = ApbOrDevice.Name; dataobject.shape = ApbOrDevice; _RedoActionsCollection.Push(dataobject); }
public ChangeRepresentationObject MakeChangeRepresentationObjectForDelete(Shape ApbOrDevice) { ChangeRepresentationObject dataobject = new ChangeRepresentationObject(); dataobject.Action = ActionType.Delete; dataobject.shape = ApbOrDevice; dataobject.disablepoints = ApbOrDevice.Name; return(dataobject); }
public void InsertObjectforUndoRedo(ChangeRepresentationObject dataobject) { _UndoActionsCollection.Push(dataobject); _RedoActionsCollection.Clear(); if (EnableDisableUndoRedoFeature != null) { EnableDisableUndoRedoFeature(null, null); } }
public void RedoPushInUnDoForEdit(ChangeRepresentationObject undostruct) { ChangeRepresentationObject EditStruct = new ChangeRepresentationObject(); EditStruct.Action = ActionType.Edit; if (undostruct.shape.GetType().Equals(typeof(Path))) { Path p = (Path)undostruct.shape; EllipseGeometry eg = (EllipseGeometry)p.Data; EditStruct.height = eg.RadiusY; EditStruct.Width = eg.RadiusX; } else { EditStruct.height = undostruct.shape.Height; EditStruct.Width = undostruct.shape.Width; } EditStruct.brush = undostruct.shape.Fill; EditStruct.shape = undostruct.shape; EditStruct.brushborder = undostruct.shape.Stroke; EditStruct.borderThickness = undostruct.shape.StrokeThickness; _RedoActionsCollection.Push(EditStruct); }
public void Undo(int level) { for (int i = 1; i <= level; i++) { if (_UndoActionsCollection.Count == 0) { return; } ChangeRepresentationObject Undostruct = _UndoActionsCollection.Pop(); if (Undostruct.Action == ActionType.Delete) { Container.Children.Add(Undostruct.shape); this.RedoPushInUnDoForDelete(Undostruct.shape); } else if (Undostruct.Action == ActionType.Insert) { Container.Children.Remove(Undostruct.shape); this.RedoPushInUnDoForInsert(Undostruct.shape); if (Undostruct.shape.GetType().Equals(typeof(System.Windows.Shapes.Polygon))) { System.Windows.Shapes.Polygon poly = (System.Windows.Shapes.Polygon)Undostruct.shape; foreach (Shape shape in Container.Children) { if (shape.GetType().Equals(typeof(System.Windows.Shapes.Path))) { Path shapetemp = (Path)shape; EllipseGeometry temp = (EllipseGeometry)shapetemp.Data; foreach (System.Windows.Point p in poly.Points) { if (temp.Center == p) { shape.Name = "enabled"; } } } } } } else if (Undostruct.Action == ActionType.Edit) { if (_UndoActionsCollection.Count != 0) { this.RedoPushInUnDoForEdit(Undostruct); if (Undostruct.shape.GetType().Equals(typeof(Path))) { Path tempPath = (Path)Undostruct.shape; EllipseGeometry tempeg = (EllipseGeometry)tempPath.Data; tempeg.RadiusY = Undostruct.height; tempeg.RadiusX = Undostruct.Width; tempPath.Fill = Undostruct.brush; tempPath.Data = tempeg; tempPath.Stroke = Undostruct.brushborder; tempPath.StrokeThickness = Undostruct.borderThickness; Undostruct.shape = tempPath; } else if (Undostruct.shape.GetType().Equals(typeof(System.Windows.Shapes.Polygon))) { Undostruct.shape.Fill = Undostruct.brush; Undostruct.shape.Stroke = Undostruct.brushborder; Undostruct.shape.StrokeThickness = Undostruct.borderThickness; } else { Undostruct.shape.Height = Undostruct.height; Undostruct.shape.Width = Undostruct.Width; Undostruct.shape.Fill = Undostruct.brush; Undostruct.shape.Stroke = Undostruct.brushborder; Undostruct.shape.StrokeThickness = Undostruct.borderThickness; } } } else if (Undostruct.Action == ActionType.Clear) { foreach (Shape shape in Undostruct.ShapesCollection) { if (!Container.Children.Contains(shape)) { Container.Children.Add(shape); } } _RedoActionsCollection.Push(Undostruct); } } if (EnableDisableUndoRedoFeature != null) { EnableDisableUndoRedoFeature(null, null); } }