コード例 #1
0
ファイル: TrackDelete.cs プロジェクト: dalinhuang/tdcodes
        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);
                }
            }
        }
コード例 #2
0
ファイル: TrackDeleteAll.cs プロジェクト: dalinhuang/tdcodes
 public void Undo(GraphicsList list)
 {
     // Add all objects from clone list to list -
     // opposite to DeleteAll
     foreach (IDrawObject o in cloneList)
     {
         list.Add(o);
     }
 }
コード例 #3
0
        // 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());
            }
        }
コード例 #4
0
ファイル: TrackDelete.cs プロジェクト: dalinhuang/tdcodes
        public void Undo(GraphicsList list)
        {
            list.UnselectAll();

            // Add all objects from cloneList to list.
            foreach(IDrawObject o in cloneList)
            {
                list.Add(o);
            }
        }
コード例 #5
0
ファイル: TrackDelete.cs プロジェクト: dalinhuang/tdcodes
        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());
            }
        }
コード例 #6
0
ファイル: TrackDeleteAll.cs プロジェクト: dalinhuang/tdcodes
        // 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());
            }
        }
コード例 #7
0
        // 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);
                }
            }
        }
コード例 #8
0
ファイル: DrawArea.cs プロジェクト: dalinhuang/tdcodes
 private void Init()
 {
     SetStyle(ControlStyles.AllPaintingInWmPaint |
         ControlStyles.UserPaint |
         ControlStyles.OptimizedDoubleBuffer |
         ControlStyles.SupportsTransparentBackColor |
         ControlStyles.Opaque, true);
     ActiveToolBox = ToolBoxType.Pointer;
     GraphicsCollection = new GraphicsList();
 }
コード例 #9
0
 public void Redo(GraphicsList list)
 {
     // Replace all objects in the list with objects from listAfter
     ReplaceObjects(list, listAfter);
 }
コード例 #10
0
 public void Undo(GraphicsList list)
 {
     // Replace all objects in the list with objects from listBefore
     ReplaceObjects(list, listBefore);
 }
コード例 #11
0
 // Call this function AFTER operation.
 public void NewState(GraphicsList graphicsList)
 {
     // Keep objects state after operation.
     FillList(graphicsList, ref listAfter);
 }
コード例 #12
0
 // Create this command BEFORE operation.
 public TrackChangeState(GraphicsList graphicsList)
 {
     // Keep objects state before operation.
     FillList(graphicsList, ref listBefore);
 }
コード例 #13
0
ファイル: TrackDeleteAll.cs プロジェクト: dalinhuang/tdcodes
 public void Redo(GraphicsList list)
 {
     // Clear list - make DeleteAll again
     list.Clear();
 }
コード例 #14
0
ファイル: TrackAdd.cs プロジェクト: dalinhuang/tdcodes
 public void Redo(GraphicsList list)
 {
     list.UnselectAll();
     list.Add(drawObject);
 }
コード例 #15
0
ファイル: TrackAdd.cs プロジェクト: dalinhuang/tdcodes
 public void Undo(GraphicsList list)
 {
     list.DeleteLastAddedObject();
 }