public void Redo(GraphicsList list) { // Delete from list all objects kept in cloneList int n = list.Count; for ( int i = n - 1; i >= 0; i-- ) { bool toDelete = false; IDrawObject objectToDelete = list[i]; foreach(IDrawObject o in cloneList) { if (objectToDelete.Property.Id == o.Property.Id) { toDelete = true; break; } } if ( toDelete ) { list.RemoveAt(i); } } }
public void Undo(GraphicsList list) { // Add all objects from clone list to list - // opposite to DeleteAll foreach (IDrawObject o in cloneList) { list.Add(o); } }
// Fill list from selection private void FillList(GraphicsList graphicsList, ref List<IDrawObject> listToFill) { listToFill = new List<IDrawObject>(); foreach (IDrawObject o in graphicsList.Selection) { listToFill.Add(o.Clone()); } }
public void Undo(GraphicsList list) { list.UnselectAll(); // Add all objects from cloneList to list. foreach(IDrawObject o in cloneList) { list.Add(o); } }
List<IDrawObject> cloneList; // contains selected items which are deleted // Create this command BEFORE applying Delete All function. public TrackDelete(GraphicsList graphicsList) { cloneList = new List<IDrawObject>(); // Make clone of the list selection. foreach(IDrawObject o in graphicsList.Selection) { cloneList.Add(o.Clone()); } }
// Create this command BEFORE applying Delete All function. public TrackDeleteAll(GraphicsList graphicsList) { cloneList = new List<IDrawObject>(); // Make clone of the whole list. // Add objects in reverse order because GraphicsList.Add // insert every object to the beginning. int n = graphicsList.Count; for ( int i = n - 1; i >= 0; i-- ) { cloneList.Add(graphicsList[i].Clone()); } }
// Replace objects in graphicsList with objects from list private void ReplaceObjects(GraphicsList graphicsList, List<IDrawObject> list) { for ( int i = 0; i < graphicsList.Count; i++ ) { IDrawObject replacement = null; foreach (IDrawObject o in list) { if (o.Property.Id == graphicsList[i].Property.Id) { replacement = o; break; } } if ( replacement != null ) { graphicsList.Replace(i, replacement); } } }
private void Init() { SetStyle(ControlStyles.AllPaintingInWmPaint | ControlStyles.UserPaint | ControlStyles.OptimizedDoubleBuffer | ControlStyles.SupportsTransparentBackColor | ControlStyles.Opaque, true); ActiveToolBox = ToolBoxType.Pointer; GraphicsCollection = new GraphicsList(); }
public void Redo(GraphicsList list) { // Replace all objects in the list with objects from listAfter ReplaceObjects(list, listAfter); }
public void Undo(GraphicsList list) { // Replace all objects in the list with objects from listBefore ReplaceObjects(list, listBefore); }
// Call this function AFTER operation. public void NewState(GraphicsList graphicsList) { // Keep objects state after operation. FillList(graphicsList, ref listAfter); }
// Create this command BEFORE operation. public TrackChangeState(GraphicsList graphicsList) { // Keep objects state before operation. FillList(graphicsList, ref listBefore); }
public void Redo(GraphicsList list) { // Clear list - make DeleteAll again list.Clear(); }
public void Redo(GraphicsList list) { list.UnselectAll(); list.Add(drawObject); }
public void Undo(GraphicsList list) { list.DeleteLastAddedObject(); }