コード例 #1
0
ファイル: CommandDelete.cs プロジェクト: congkhanguyen/Mokkan
        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);
                }
            }
        }
コード例 #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);
     }
 }
コード例 #3
0
ファイル: CommandAdd.cs プロジェクト: congkhanguyen/Mokkan
 public override void Redo(ref MokkanList list)
 {
     list.UnselectAll();
     foreach (DrawObject o in cloneObjects)
     {
         list.Add(o);
     }
     addedCount = cloneObjects.Count;
 }
コード例 #4
0
ファイル: CommandDelete.cs プロジェクト: congkhanguyen/Mokkan
        public override void Undo(ref MokkanList list)
        {
            list.UnselectAll();

            // Add all objects from cloneList to list.
            foreach (DrawObject o in cloneList)
            {
                list.Add(o);
            }
        }
コード例 #5
0
ファイル: CommandDelete.cs プロジェクト: congkhanguyen/Mokkan
        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());
            }
        }
コード例 #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);
        }
コード例 #7
0
        // 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);
            }
        }
コード例 #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());
            }
        }
コード例 #9
0
        // 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);
                }
            }
        }
コード例 #10
0
 public override void Redo(ref MokkanList list)
 {
     // Clear list - make DeleteAll again
     list.Clear();
 }
コード例 #11
0
 public override void Redo(ref MokkanList list)
 {
     list = listAfter.Clone();
 }
コード例 #12
0
        public UndoManager(MokkanList mokkanList)
        {
            this._mokkanList = mokkanList;

            ClearHistory();
        }
コード例 #13
0
 public override void Undo(ref MokkanList list)
 {
     // Replace all objects in the list with objects from listBefore
     ReplaceObjects(list, listBefore);
 }
コード例 #14
0
ファイル: CommandAdd.cs プロジェクト: congkhanguyen/Mokkan
 public override void Undo(ref MokkanList list)
 {
     list.DeleteLastAddedObjects(addedCount);
 }
コード例 #15
0
 // Create this command BEFORE operation.
 public CommandChangeState(MokkanList mokkanList)
 {
     // Keep objects state before operation.
     FillList(mokkanList, ref listBefore);
 }
コード例 #16
0
 // Call this function AFTER operation.
 public void NewState(MokkanList mokkanList)
 {
     // Keep objects state after operation.
     FillList(mokkanList, ref listAfter);
 }
コード例 #17
0
 // Create this command BEFORE operation.
 public CommandChange(MokkanList mokkanList)
 {
     // Keep objects state before operation.
     listBefore = mokkanList.Clone();
 }
コード例 #18
0
 public override void Redo(ref MokkanList list)
 {
     // Replace all objects in the list with objects from listAfter
     ReplaceObjects(list, listAfter);
 }
コード例 #19
0
 // Call this function AFTER operation.
 public void NewState(MokkanList mokkanList)
 {
     // Keep objects state after operation.
     listAfter = mokkanList.Clone();
 }
コード例 #20
0
 public override void Undo(ref MokkanList list)
 {
     list = listBefore.Clone();
 }
コード例 #21
0
ファイル: Command.cs プロジェクト: congkhanguyen/Mokkan
 // This command is used to make Redo operation.
 // It makes original command again.
 public abstract void Redo(ref MokkanList list);