public override void Undo(Layers list) { // Add all objects from clone list to list - // opposite to DeleteAll foreach (DrawObject o in cloneList) { list[list.ActiveLayerIndex].Graphics.Add(o); } }
public DrawArea() { // create list of Layers, with one default active visible layer _layers = new Layers(); _layers.CreateNewLayer("Default"); _panning = false; _panX = 0; _panY = 0; // This call is required by the Windows.Forms Form Designer. InitializeComponent(); }
// Create this command BEFORE applying Delete All function. public CommandDeleteAll(Layers list) { cloneList = new List<DrawObject>(); // Make clone of the whole list. // Add objects in reverse order because GraphicsList.Add // insert every object to the beginning. int n = list[list.ActiveLayerIndex].Graphics.Count; for ( int i = n - 1; i >= 0; i-- ) { cloneList.Add(list[list.ActiveLayerIndex].Graphics[i].Clone()); } }
public LayerDialog(Layers _layers) { InitializeComponent(); for (int i = 0; i < _layers.Count; i++) { LayerEdit le = new LayerEdit(); le.LayerName = ((Layer)_layers[i]).LayerName; le.LayerVisible = ((Layer)_layers[i]).IsVisible; le.LayerActive = ((Layer)_layers[i]).IsActive; layerList.Add(le); } dgvLayers.DataSource = layerList; dgvLayers.Columns[0].HeaderText = "Layer Name"; dgvLayers.Columns[1].HeaderText = "New Layer"; dgvLayers.Columns[2].HeaderText = "Active"; dgvLayers.Columns[3].HeaderText = "Deleted"; dgvLayers.Columns[4].HeaderText = "Visible"; }
public UndoManager(Layers layerList) { this.layers = layerList; ClearHistory(); }
// This command is used to make Redo operation. // It makes original command again. //public abstract void Redo(GraphicsList list); public abstract void Redo(Layers list);
// This function is used to make Undo operation. // It makes action opposite to the original command. //public abstract void Undo(GraphicsList list); public abstract void Undo(Layers list);
public override void Redo(Layers list) { // Replace all objects in the list with objects from listAfter ReplaceObjects(list[activeLayer].Graphics, listAfter); }
public override void Undo(Layers list) { // Replace all objects in the list with objects from listBefore ReplaceObjects(list[activeLayer].Graphics, listBefore); }
// Call this function AFTER operation. public void NewState(Layers layerList) { // Keep objects state after operation. FillList(layerList[activeLayer].Graphics, ref listAfter); }
// Create this command BEFORE operation. public CommandChangeState(Layers layerList) { // Keep objects state before operation. activeLayer = layerList.ActiveLayerIndex; FillList(layerList[activeLayer].Graphics, ref listBefore); }
public override void Redo(Layers list) { // Clear list - make DeleteAll again list[list.ActiveLayerIndex].Graphics.Clear(); }
/// <summary> /// Redo last Add command /// </summary> /// <param name="list">Layers collection</param> public override void Redo(Layers list) { list[list.ActiveLayerIndex].Graphics.UnselectAll(); list[list.ActiveLayerIndex].Graphics.Add(drawObject); }
/// <summary> /// Undo last Add command /// </summary> /// <param name="list">Layers collection</param> public override void Undo(Layers list) { list[list.ActiveLayerIndex].Graphics.DeleteLastAddedObject(); }