Example #1
0
        public override void Redo(ref MokkanList 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.ID == o.ID)
                    {
                        toDelete = true;
                        break;
                    }
                }

                if (toDelete)
                {
                    list.RemoveAt(i);
                }
            }
        }
Example #2
0
 public override void Undo(ref MokkanList list)
 {
     // Add all objects from clone list to list -
     // opposite to DeleteAll
     foreach (DrawObject o in cloneList)
     {
         list.Add(o);
     }
 }
Example #3
0
 public override void Redo(ref MokkanList list)
 {
     list.UnselectAll();
     foreach (DrawObject o in cloneObjects)
     {
         list.Add(o);
     }
     addedCount = cloneObjects.Count;
 }
Example #4
0
        public override void Undo(ref MokkanList list)
        {
            list.UnselectAll();

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

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

            // Make clone of the list selection.

            foreach (DrawObject o in mokkanList.Selection)
            {
                cloneList.Add(o.Clone());
            }
        }
Example #6
0
        /// <summary>
        /// Clone this instance
        /// </summary>
        /// <returns></returns>
        public MokkanList Clone()
        {
            MokkanList       ret  = (MokkanList)this.MemberwiseClone();
            MokkanObjectList list = new MokkanObjectList();

            foreach (DrawObject o in MokkanObjectList)
            {
                list.Add(o.Clone());
            }
            ret.MokkanObjectList = list;
            return(ret);
        }
        // Fill list from selection
        private void FillList(MokkanList mokkanList, ref List <DrawObject> listToFill)
        {
            listToFill = new List <DrawObject>();
            DrawObject changedObj;

            foreach (DrawObject o in mokkanList.Selection)
            {
                changedObj          = o.Clone();
                changedObj.Selected = false;
                listToFill.Add(changedObj);
            }
        }
Example #8
0
        // Create this command BEFORE applying Delete All function.
        public CommandDeleteAll(MokkanList mokkanList)
        {
            cloneList = new List <DrawObject>();

            // Make clone of the whole list.
            // Add objects in reverse order because mokkanList.Add
            // insert every object to the beginning.
            int n = mokkanList.Count;

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

                foreach (DrawObject o in list)
                {
                    if (o.ID == mokkanList[i].ID)
                    {
                        replacement          = o;
                        replacement.Selected = true;
                        break;
                    }
                }

                if (replacement != null)
                {
                    mokkanList.Replace(i, replacement);
                }
            }
        }
Example #10
0
 public override void Redo(ref MokkanList list)
 {
     // Clear list - make DeleteAll again
     list.Clear();
 }
Example #11
0
 public override void Redo(ref MokkanList list)
 {
     list = listAfter.Clone();
 }
Example #12
0
        public UndoManager(MokkanList mokkanList)
        {
            this._mokkanList = mokkanList;

            ClearHistory();
        }
 public override void Undo(ref MokkanList list)
 {
     // Replace all objects in the list with objects from listBefore
     ReplaceObjects(list, listBefore);
 }
Example #14
0
 public override void Undo(ref MokkanList list)
 {
     list.DeleteLastAddedObjects(addedCount);
 }
 // Create this command BEFORE operation.
 public CommandChangeState(MokkanList mokkanList)
 {
     // Keep objects state before operation.
     FillList(mokkanList, ref listBefore);
 }
 // Call this function AFTER operation.
 public void NewState(MokkanList mokkanList)
 {
     // Keep objects state after operation.
     FillList(mokkanList, ref listAfter);
 }
Example #17
0
 // Create this command BEFORE operation.
 public CommandChange(MokkanList mokkanList)
 {
     // Keep objects state before operation.
     listBefore = mokkanList.Clone();
 }
 public override void Redo(ref MokkanList list)
 {
     // Replace all objects in the list with objects from listAfter
     ReplaceObjects(list, listAfter);
 }
Example #19
0
 // Call this function AFTER operation.
 public void NewState(MokkanList mokkanList)
 {
     // Keep objects state after operation.
     listAfter = mokkanList.Clone();
 }
Example #20
0
 public override void Undo(ref MokkanList list)
 {
     list = listBefore.Clone();
 }
Example #21
0
 // This command is used to make Redo operation.
 // It makes original command again.
 public abstract void Redo(ref MokkanList list);