public void SelectDrawObj(DrawObj drawObj)
 {
     if (FindDrawObj(drawObj.Name) != null)
     {
         _selectDrawObj = drawObj;
     }
 }
        private void Redo(ActionType type, DrawObj drawObj)
        {
            switch (type)
            {
            case ActionType.Add:
                DoUndoRedoAdd(OperationType.Undo, ActionType.Add, drawObj);
                break;

            case ActionType.Delete:
                DoUndoRedoDelete(OperationType.Undo, ActionType.Delete, drawObj);
                break;

            case ActionType.Move:
                DoUndoRedoMove(OperationType.Undo, drawObj);
                break;

            case ActionType.Rotate:
                DoUndoRedoRotate(OperationType.Undo, drawObj);
                break;

            case ActionType.Zoom:
                DoUndoRedoZoom(OperationType.Undo, drawObj);
                break;
            }
        }
 private void DoRotate(DrawObj drawObj, double rotateAngle)
 {
     if (drawObj != null)
     {
         Console.WriteLine("Rotate {0} from {1} to {2} ", drawObj.Name, drawObj.RotateAngle, rotateAngle);
         drawObj.RotateAngle = rotateAngle;
     }
 }
 private void DoZoom(DrawObj drawObj, double zoomScale)
 {
     if (drawObj != null)
     {
         Console.WriteLine("Zoom {0} from {1} to {2} ", drawObj.Name, drawObj.ZoomScale, zoomScale);
         drawObj.ZoomScale = zoomScale;
     }
 }
 private void DoMove(DrawObj drawObj, double offset)
 {
     if (drawObj != null)
     {
         Console.WriteLine("Move {0} from {1} to {2} ", drawObj.Name, drawObj.Offset, offset);
         drawObj.Offset = offset;
     }
 }
        private DrawObj DoAdd()
        {
            var drawObj = new DrawObj("DrawObj" + count);

            count = count + 1;

            AddNewObjToList(drawObj);
            return(drawObj);
        }
        private void DoUndoRedoZoom(OperationType operationType, DrawObj drawObj)
        {
            var findObj = FindDrawObj(drawObj.Name);

            if (findObj != null)
            {
                AddActionToList(operationType, ActionType.Zoom, findObj);
                DoZoom(findObj, drawObj.ZoomScale);
            }
        }
        private void DoUndoRedoRotate(OperationType operationType, DrawObj drawObj)
        {
            var findObj = FindDrawObj(drawObj.Name);

            if (findObj != null)
            {
                AddActionToList(operationType, ActionType.Rotate, findObj);
                DoRotate(findObj, drawObj.RotateAngle);
            }
        }
        private void DoUndoRedoMove(OperationType operationType, DrawObj drawObj)
        {
            var findObj = FindDrawObj(drawObj.Name);

            if (findObj != null)
            {
                AddActionToList(operationType, ActionType.Move, findObj);
                DoMove(findObj, drawObj.Offset);
            }
        }
        public DrawObjManager()
        {
            _drawObjList = new List <DrawObj>();

            _undoList = new List <DrawObjAction>();
            _redoList = new List <DrawObjAction>();

            _selectDrawObj = null;
            count          = 0;
        }
예제 #11
0
        public object Clone()
        {
            var other = new DrawObj(Name)
            {
                Offset      = Offset,
                RotateAngle = RotateAngle,
                ZoomScale   = ZoomScale
            };

            return(other);
        }
        private void DoDelete(DrawObj drawObj)
        {
            if (drawObj != null)
            {
                Console.WriteLine("Delete " + drawObj.Name);
                _drawObjList.Remove(drawObj);

                if (_drawObjList.Count > 0)
                {
                    SelectDrawObj(_drawObjList.First());
                }
            }
        }
        private void AddActionToList(OperationType operationType, ActionType type, DrawObj drawObj)
        {
            if (drawObj != null)
            {
                switch (operationType)
                {
                case OperationType.Normal:
                    AddUndoAction(new DrawObjAction(type, drawObj));
                    EmptyRedoAction();
                    break
                    ;

                case OperationType.Undo:
                    AddUndoAction(new DrawObjAction(type, drawObj));
                    break;

                case OperationType.Redo:
                    AddRedoAction(new DrawObjAction(type, drawObj));
                    break;
                }
            }
        }
        private void DoUndoRedoDelete(OperationType operationType, ActionType actionType, DrawObj drawObj)
        {
            var findObj = FindDrawObj(drawObj.Name);

            if (findObj != null)
            {
                AddActionToList(operationType, actionType, findObj);
                DoDelete(findObj);
            }
        }
        private void DoUndoRedoAdd(OperationType operationType, ActionType actionType, DrawObj drawObj)
        {
            var cloneObj = drawObj.Clone() as DrawObj;

            AddNewObjToList(cloneObj);
            AddActionToList(operationType, actionType, cloneObj);
        }
 private void AddNewObjToList(DrawObj drawObj)
 {
     Console.WriteLine("Add " + drawObj.Name);
     _drawObjList.Add(drawObj);
     SelectDrawObj(drawObj);
 }