protected override HistoryMemento OnToolUndo()
            {
                MoveSelectionTool moveSelectionTool = DocumentWorkspace.Tool as MoveSelectionTool;

                if (moveSelectionTool == null)
                {
                    throw new InvalidOperationException("Current Tool is not the MoveSelectionTool");
                }

                ContextHistoryMemento cha = new ContextHistoryMemento(DocumentWorkspace, moveSelectionTool.context, this.Name, this.Image);
                OurHistoryMementoData ohad = (OurHistoryMementoData)this.Data;
                Context newContext = ohad.context;

                moveSelectionTool.context.Dispose();
                moveSelectionTool.context = newContext;

                moveSelectionTool.DestroyNubs();

                if (moveSelectionTool.context.lifted)
                {
                    moveSelectionTool.PositionNubs(moveSelectionTool.context.currentMode);
                }

                return cha;
            }
            protected override HistoryMemento OnToolUndo()
            {
                MoveSelectionTool moveSelectionTool = DocumentWorkspace.Tool as MoveSelectionTool;

                if (moveSelectionTool == null)
                {
                    throw new InvalidOperationException("Current Tool is not the MoveSelectionTool");
                }

                ContextHistoryMemento cha  = new ContextHistoryMemento(DocumentWorkspace, moveSelectionTool.context, this.Name, this.Image);
                OurHistoryMementoData ohad = (OurHistoryMementoData)this.Data;
                Context newContext         = ohad.context;

                moveSelectionTool.context.Dispose();
                moveSelectionTool.context = newContext;

                moveSelectionTool.DestroyNubs();

                if (moveSelectionTool.context.lifted)
                {
                    moveSelectionTool.PositionNubs(moveSelectionTool.context.currentMode);
                }

                return(cha);
            }
Exemple #3
0
            protected override HistoryMemento OnToolUndo()
            {
                if (!(DocumentWorkspace.Tool is MoveTool moveTool))
                {
                    throw new InvalidOperationException("Current Tool is not the MoveTool");
                }

                ContextHistoryMemento        cha  = new ContextHistoryMemento(DocumentWorkspace, moveTool.ourContext, this.Name, this.Image);
                OurContextHistoryMementoData ohad = (OurContextHistoryMementoData)this.Data;
                Context newContext = ohad.context;

                if (moveTool.ActiveLayerIndex != this.layerIndex)
                {
                    bool oldDOLC = moveTool.deactivateOnLayerChange;
                    moveTool.deactivateOnLayerChange = false;
                    moveTool.ActiveLayerIndex        = this.layerIndex;
                    moveTool.deactivateOnLayerChange = oldDOLC;
                    moveTool.activeLayer             = (BitmapLayer)moveTool.ActiveLayer;
                    moveTool.renderArgs = new RenderArgs(moveTool.activeLayer.Surface);
                    moveTool.ClearSavedMemory();
                }

                moveTool.context.Dispose();
                moveTool.context = newContext;

                moveTool.DestroyNubs();

                if (moveTool.context.lifted)
                {
                    moveTool.PositionNubs(moveTool.context.currentMode);
                }

                return(cha);
            }
Exemple #4
0
        protected override void Drop()
        {
            RestoreSavedRegion();

            PdnRegion regionCopy = Selection.CreateRegion();

            using (PdnRegion simplifiedRegion = Utility.SimplifyAndInflateRegion(regionCopy,
                                                                                 Utility.DefaultSimplificationFactor, 2))
            {
                HistoryMemento bitmapAction2 = new BitmapHistoryMemento(Name, Image, DocumentWorkspace,
                                                                        ActiveLayerIndex, simplifiedRegion);

                bool oldHQ = this.fullQuality;
                this.fullQuality = true;
                Render(this.context.offset, true);
                this.fullQuality = oldHQ;
                this.currentHistoryMementos.Add(bitmapAction2);

                activeLayer.Invalidate(simplifiedRegion);
                Update();
            }

            regionCopy.Dispose();
            regionCopy = null;

            ContextHistoryMemento cha = new ContextHistoryMemento(this.DocumentWorkspace, this.ourContext, this.Name, this.Image);

            this.currentHistoryMementos.Add(cha);

            string        name;
            ImageResource image;

            if (didPaste)
            {
                name  = EnumLocalizer.EnumValueToLocalizedName(typeof(CommonAction), CommonAction.Paste);
                image = PdnResources.GetImageResource("Icons.MenuEditPasteIcon.png");
            }
            else
            {
                name  = this.Name;
                image = this.Image;
            }

            didPaste = false;

            SelectionHistoryMemento sha = new SelectionHistoryMemento(this.Name, this.Image, this.DocumentWorkspace);

            this.currentHistoryMementos.Add(sha);

            this.context.Dispose();
            this.context = new MoveToolContext();

            this.FlushHistoryMementos(PdnResources.GetString("MoveTool.HistoryMemento.DropPixels"));
        }
        protected override void Drop()
        {
            ContextHistoryMemento cha = new ContextHistoryMemento(this.DocumentWorkspace, this.context, this.Name, this.Image);
            this.currentHistoryMementos.Add(cha);

            SelectionHistoryMemento sha = new SelectionHistoryMemento(this.Name, this.Image, this.DocumentWorkspace);
            this.currentHistoryMementos.Add(sha);

            this.context.Dispose();
            this.context = new Context();

            this.FlushHistoryMementos(PdnResources.GetString("MoveSelectionTool.HistoryMemento.DropSelection"));
        }
        protected override void Drop()
        {
            ContextHistoryMemento cha = new ContextHistoryMemento(this.DocumentWorkspace, this.context, this.Name, this.Image);

            this.currentHistoryMementos.Add(cha);

            SelectionHistoryMemento sha = new SelectionHistoryMemento(this.Name, this.Image, this.DocumentWorkspace);

            this.currentHistoryMementos.Add(sha);

            this.context.Dispose();
            this.context = new Context();

            this.FlushHistoryMementos(PdnResources.GetString("MoveSelectionTool.HistoryMemento.DropSelection"));
        }
 protected override void PushContextHistoryMemento()
 {
     ContextHistoryMemento cha = new ContextHistoryMemento(this.DocumentWorkspace, this.context, null, null);
     this.currentHistoryMementos.Add(cha);
 }
Exemple #8
0
        protected override void PushContextHistoryMemento()
        {
            ContextHistoryMemento cha = new ContextHistoryMemento(this.DocumentWorkspace, this.ourContext, null, null);

            this.currentHistoryMementos.Add(cha);
        }
Exemple #9
0
        protected override void Drop()
        {
            RestoreSavedRegion();

            PdnRegion regionCopy = Selection.CreateRegion();

            using (PdnRegion simplifiedRegion = Utility.SimplifyAndInflateRegion(regionCopy, 
                       Utility.DefaultSimplificationFactor, 2))
            {
                HistoryMemento bitmapAction2 = new BitmapHistoryMemento(Name, Image, DocumentWorkspace, 
                    ActiveLayerIndex, simplifiedRegion);

                bool oldHQ = this.fullQuality;
                this.fullQuality = true;
                Render(this.context.offset, true);
                this.fullQuality = oldHQ;
                this.currentHistoryMementos.Add(bitmapAction2);

                activeLayer.Invalidate(simplifiedRegion);
                Update();
            }

            regionCopy.Dispose();
            regionCopy = null;

            ContextHistoryMemento cha = new ContextHistoryMemento(this.DocumentWorkspace, this.ourContext, this.Name, this.Image);
            this.currentHistoryMementos.Add(cha);

            string name;
            ImageResource image;

            if (didPaste)
            {
                name = EnumLocalizer.EnumValueToLocalizedName(typeof(CommonAction), CommonAction.Paste);
                image = PdnResources.GetImageResource("Icons.MenuEditPasteIcon.png");
            }
            else
            {
                name = this.Name;
                image = this.Image;
            }

            didPaste = false;

            SelectionHistoryMemento sha = new SelectionHistoryMemento(this.Name, this.Image, this.DocumentWorkspace);
            this.currentHistoryMementos.Add(sha);

            this.context.Dispose();
            this.context = new MoveToolContext();

            this.FlushHistoryMementos(PdnResources.GetString("MoveTool.HistoryMemento.DropPixels"));
        }
Exemple #10
0
            protected override HistoryMemento OnToolUndo()
            {
                MoveTool moveTool = DocumentWorkspace.Tool as MoveTool;

                if (moveTool == null)
                {
                    throw new InvalidOperationException("Current Tool is not the MoveTool");
                }

                ContextHistoryMemento cha = new ContextHistoryMemento(DocumentWorkspace, moveTool.ourContext, this.Name, this.Image);
                OurContextHistoryMementoData ohad = (OurContextHistoryMementoData)this.Data;
                Context newContext = ohad.context;

                if (moveTool.ActiveLayerIndex != this.layerIndex)
                {
                    bool oldDOLC = moveTool.deactivateOnLayerChange;
                    moveTool.deactivateOnLayerChange = false;
                    moveTool.ActiveLayerIndex = this.layerIndex;
                    moveTool.deactivateOnLayerChange = oldDOLC;
                    moveTool.activeLayer = (BitmapLayer)moveTool.ActiveLayer;
                    moveTool.renderArgs = new RenderArgs(moveTool.activeLayer.Surface);
                    moveTool.ClearSavedMemory();
                }

                moveTool.context.Dispose();
                moveTool.context = newContext;

                moveTool.DestroyNubs();

                if (moveTool.context.lifted)
                {
                    moveTool.PositionNubs(moveTool.context.currentMode);
                }

                return cha;
            }