Exemple #1
0
        protected override void OnDeactivate()
        {
            if (!this.mouseUp)
            {
                StaticData sd = GetStaticData();
                Point lastXY = Point.Empty;

                if (sd != null)
                {
                    lastXY = sd.lastMoved;
                }

                OnMouseUp(new MouseEventArgs(MouseButtons.Left, 0, lastXY.X, lastXY.Y, 0));
            } 
            
            AppEnvironment.PenInfoChanged -= new EventHandler(Environment_PenInfoChanged);

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

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

            if (cursorMouseDown != null)
            {
                cursorMouseDown.Dispose();
                cursorMouseDown = null;
            }

            if (cursorMouseUp != null)
            {
                cursorMouseUp.Dispose();
                cursorMouseUp = null;
            }

            if (cursorMouseDownSetSource != null)
            {
                cursorMouseDownSetSource.Dispose();
                cursorMouseDownSetSource = null;
            }
            
            base.OnDeactivate();
        }
Exemple #2
0
        protected override void OnActivate()
        {
            base.OnActivate();
            
            cursorMouseDown = new Cursor(PdnResources.GetResourceStream("Cursors.GenericToolCursorMouseDown.cur"));
            cursorMouseDownSetSource = new Cursor(PdnResources.GetResourceStream("Cursors.CloneStampToolCursorSetSource.cur"));
            cursorMouseUp = new Cursor(PdnResources.GetResourceStream("Cursors.CloneStampToolCursor.cur"));
            this.Cursor = cursorMouseUp;

            this.rendererDst = new BrushPreviewRenderer(this.RendererList);
            this.RendererList.Add(this.rendererDst, false);

            this.rendererSrc = new BrushPreviewRenderer(this.RendererList);
            this.rendererSrc.BrushLocation = GetStaticData().takeFrom;
            this.rendererSrc.BrushSize = AppEnvironment.PenInfo.Width / 2.0f;
            this.rendererSrc.Visible = (GetStaticData().takeFrom != Point.Empty);
            this.RendererList.Add(this.rendererSrc, false);

            if (ActiveLayer != null)
            {
                switchedTo = true;
                historyRects = new Vector<Rectangle>();

                if (GetStaticData().wr != null && GetStaticData().wr.IsAlive)
                {
                    takeFromLayer = (BitmapLayer)GetStaticData().wr.Target;
                }
                else
                {
                    takeFromLayer = null;
                }
            }

            AppEnvironment.PenInfoChanged += new EventHandler(Environment_PenInfoChanged);
        }