示例#1
0
        private void Activate()
        {
            Debug.Assert(this.active != true, "already active!");
            this.active = true;

            this.handCursor          = new Cursor(PdnResources.GetResourceStream("Cursors.PanToolCursor.cur"));
            this.handCursorMouseDown = new Cursor(PdnResources.GetResourceStream("Cursors.PanToolCursorMouseDown.cur"));
            this.handCursorInvalid   = new Cursor(PdnResources.GetResourceStream("Cursors.PanToolCursorInvalid.cur"));

            this.panTracking = false;
            this.panMode     = false;
            this.mouseDown   = 0;
            this.savedTiles  = null;
            this.saveRegion  = null;

            this.scratchSurface = DocumentWorkspace.BorrowScratchSurface(this.GetType().Name + ": Tool.Activate()");
#if DEBUG
            this.haveClearedScratch = false;
#endif

            Selection.Changing += new EventHandler(SelectionChangingHandler);
            Selection.Changed  += new EventHandler(SelectionChangedHandler);
            HistoryStack.ExecutingHistoryMemento += new ExecutingHistoryMementoEventHandler(ExecutingHistoryMemento);
            HistoryStack.ExecutedHistoryMemento  += new ExecutedHistoryMementoEventHandler(ExecutedHistoryMemento);
            HistoryStack.FinishedStepGroup       += new EventHandler(FinishedHistoryStepGroup);

            this.trackingNub         = new MoveNubRenderer(this.RendererList);
            this.trackingNub.Visible = false;
            this.trackingNub.Size    = new SizeF(10, 10);
            this.trackingNub.Shape   = MoveNubShape.Compass;
            this.RendererList.Add(this.trackingNub, false);

            OnActivate();
        }
示例#2
0
        private void Deactivate()
        {
            Debug.Assert(this.active != false, "not active!");

            this.active = false;

            Selection.Changing -= new EventHandler(SelectionChangingHandler);
            Selection.Changed  -= new EventHandler(SelectionChangedHandler);

            HistoryStack.ExecutingHistoryMemento -= new ExecutingHistoryMementoEventHandler(ExecutingHistoryMemento);
            HistoryStack.ExecutedHistoryMemento  -= new ExecutedHistoryMementoEventHandler(ExecutedHistoryMemento);
            HistoryStack.FinishedStepGroup       -= new EventHandler(FinishedHistoryStepGroup);

            OnDeactivate();

            this.RendererList.Remove(this.trackingNub);
            this.trackingNub.Dispose();
            this.trackingNub = null;

            DocumentWorkspace.ReturnScratchSurface(this.scratchSurface);
            this.scratchSurface = null;

            if (this.saveRegion != null)
            {
                this.saveRegion.Dispose();
                this.saveRegion = null;
            }

            this.savedTiles = null;

            if (this.handCursor != null)
            {
                this.handCursor.Dispose();
                this.handCursor = null;
            }

            if (this.handCursorMouseDown != null)
            {
                this.handCursorMouseDown.Dispose();
                this.handCursorMouseDown = null;
            }

            if (this.handCursorInvalid != null)
            {
                this.handCursorInvalid.Dispose();
                this.handCursorInvalid = null;
            }
        }