예제 #1
0
        public override void Redo(MapObjects list)
        {
            // Delete from list all objects kept in cloneList

            int n = list.Count;

            for (int i = n - 1; i >= 0; i--)
            {
                bool       toDelete       = false;
                DrawObject objectToDelete = list[i];

                foreach (DrawObject o in cloneList)
                {
                    if (objectToDelete.GetProperty().ID == o.GetProperty().ID)
                    {
                        toDelete = true;
                        break;
                    }
                }

                if (toDelete)
                {
                    list.RemoveAt(i);
                }
            }
        }
예제 #2
0
 public override void Undo(MapObjects list)
 {
     // Add all objects from clone list to list -
     // opposite to DeleteAll
     foreach (DrawObject o in cloneList)
     {
         list.Add(o);
     }
 }
예제 #3
0
        // Fill list from selection
        private void FillList(MapObjects graphicsList, ref List <DrawObject> listToFill)
        {
            listToFill = new List <DrawObject>();

            foreach (DrawObject o in graphicsList.Selection)
            {
                listToFill.Add(o.Clone());
            }
        }
예제 #4
0
        public override void Undo(MapObjects list)
        {
            list.UnselectAll();

            // Add all objects from cloneList to list.
            foreach (DrawObject o in cloneList)
            {
                list.Add(o);
            }
        }
예제 #5
0
        List <DrawObject> cloneList;    // contains selected items which are deleted

        // Create this command BEFORE applying Delete All function.
        public CommandDelete(MapObjects graphicsList)
        {
            cloneList = new List <DrawObject>();

            // Make clone of the list selection.

            foreach (DrawObject o in graphicsList.Selection)
            {
                cloneList.Add(o.Clone());
            }
        }
예제 #6
0
        // Create this command BEFORE applying Delete All function.
        public CommandDeleteAll(MapObjects graphicsList)
        {
            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 = graphicsList.Count;

            for (int i = n - 1; i >= 0; i--)
            {
                cloneList.Add(graphicsList[i].Clone());
            }
        }
예제 #7
0
        // Replace objects in graphicsList with objects from list
        private void ReplaceObjects(MapObjects graphicsList, List <DrawObject> list)
        {
            for (int i = 0; i < graphicsList.Count; i++)
            {
                DrawObject replacement = null;

                foreach (DrawObject o in list)
                {
                    if (o.GetProperty().ID == graphicsList[i].GetProperty().ID)
                    {
                        replacement = o;
                        break;
                    }
                }

                if (replacement != null)
                {
                    graphicsList.Replace(i, replacement);
                }
            }
        }
예제 #8
0
 // This command is used to make Redo operation.
 // It makes original command again.
 public abstract void Redo(MapObjects list);
예제 #9
0
 public override void Redo(MapObjects list)
 {
     list.UnselectAll();
     list.Add(drawObject);
 }
예제 #10
0
 public override void Undo(MapObjects list)
 {
     list.DeleteLastAddedObject();
 }
예제 #11
0
 public override void Redo(MapObjects list)
 {
     // Clear list - make DeleteAll again
     list.Clear();
 }
예제 #12
0
        public UndoManager(MapObjects graphicsList)
        {
            this.graphicsList = graphicsList;

            ClearHistory();
        }
예제 #13
0
 public override void Redo(MapObjects list)
 {
     // Replace all objects in the list with objects from listAfter
     ReplaceObjects(list, listAfter);
 }
예제 #14
0
 public override void Undo(MapObjects list)
 {
     // Replace all objects in the list with objects from listBefore
     ReplaceObjects(list, listBefore);
 }
예제 #15
0
 // Call this function AFTER operation.
 public void NewState(MapObjects graphicsList)
 {
     // Keep objects state after operation.
     FillList(graphicsList, ref listAfter);
 }
예제 #16
0
 // Create this command BEFORE operation.
 public CommandChangeState(MapObjects graphicsList)
 {
     // Keep objects state before operation.
     FillList(graphicsList, ref listBefore);
 }