Ejemplo n.º 1
0
        /// <summary>
        /// check anything, include focus, ....
        /// </summary>
        /// <param name="undo"></param>
        /// <returns></returns>
        public bool isAnythingSame(UndoItem undo)
        {
            if (this.getHightlightCount() != undo.getHightlightCount())
            {
                return(false);
            }

            if (this.SnapshotItems.Count != undo.SnapshotItems.Count)
            {
                return(false);
            }
            DiagramEntity entity = this.getHightlightEntity();
            DiagramEntity item   = undo.getHightlightEntity();

            if (entity == item)  //all null
            {
                return(isEqual(undo));
            }
            if (entity != null && item != null)
            {
                if (!entity.isEqual(item))
                {
                    return(false);
                }
            }
            return(isEqual(undo));
        }
Ejemplo n.º 2
0
        /// <summary>
        /// check if give item is same as mine
        /// </summary>
        /// <param name="item"></param>
        /// <returns></returns>
        public bool isEqualWithoutFunctionCheck(UndoItem item)
        {
            //if (this.EditorPropertiesEnabled != item.EditorPropertiesEnabled)
            //     return false;
            if (this.EditorBackColor != item.EditorBackColor)
            {
                return(false);
            }
            if (this.EditorBorderColor != item.EditorBorderColor)
            {
                return(false);
            }
            if (this.EditorInterCharDelay != item.EditorInterCharDelay)
            {
                return(false);
            }
            if (this.EditorSensitivity != item.EditorSensitivity)
            {
                return(false);
            }
            if (this.EditorTouchDelay != item.EditorTouchDelay)
            {
                return(false);
            }
            //if (this.RecordForFocus != item.RecordForFocus)
            //    return false;

            List <object> mine = this.SnapshotItems;


            List <object> items = item.SnapshotItems;

            if (mine.Count != items.Count)
            {
                return(false);
            }

            List <object> entries = new List <object>();

            for (int i = 0; i < mine.Count; i++)
            {
                entries.Add(mine[i]);
            }

            for (int i = 0; i < items.Count; i++)
            {
                object obj = findSameItem(items[i], entries);
                if (obj != null)
                {
                    entries.Remove(obj);
                }
            }
            if (entries.Count > 0)
            {
                return(false);
            }
            return(true);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// check if give item is same as mine
        /// </summary>
        /// <param name="item"></param>
        /// <returns></returns>
        public bool isEqual(UndoItem item)
        {
            if (!isEqualWithoutFunctionCheck(item))
            {
                return(false);
            }

            if (this.RecordForFocus != item.RecordForFocus)
            {
                return(false);
            }

            return(true);
        }
Ejemplo n.º 4
0
        /// <summary>
        /// remove all new undo after give undoitem
        /// </summary>
        /// <param name="lastUndo">The last undo</param>
        public void removeNewUndo(UndoItem lastUndo)
        {
            if (lastUndo == null)
            {
                m_objs.UndoStack.Clear();
                return;
            }
            int n = m_objs.UndoStack.IndexOf(lastUndo);

            if (n < 0)
            {
                return;
            }
            int ncount = m_objs.UndoStack.Count;

            for (int i = n + 1; i < ncount; i++)
            {
                m_objs.UndoStack.RemoveAt(n + 1);
            }
        }
Ejemplo n.º 5
0
        public UndoItem clone()
        {
            UndoItem undo = new UndoItem();

            undo.EditorBackColor         = this.EditorBackColor;
            undo.EditorBorderColor       = this.EditorBorderColor;
            undo.EditorInterCharDelay    = this.EditorInterCharDelay;
            undo.EditorPropertiesEnabled = this.EditorPropertiesEnabled;
            undo.EditorSensitivity       = this.EditorSensitivity;
            undo.EditorTouchDelay        = this.EditorTouchDelay;
            undo.RecordForFocus          = this.RecordForFocus;

            List <object> items = this.SnapshotItems;

            for (int i = 0; i < items.Count; i++)
            {
                undo.SnapshotItems.Add(((DiagramEntity)items[i]).Clone());
            }
            return(undo);
        }