Beispiel #1
0
        private void PickColor(MouseEventArgsF e)
        {
            if (this.currentSampleSize == 1)
            {
                if (!base.Document.Bounds.Contains(e.X, e.Y))
                {
                    return;
                }
            }
            else
            {
                Rectangle bounds = base.Document.Bounds;
                int       width  = (this.currentSampleSize - 1) / 2;
                bounds.Inflate(width, width);
                if (!bounds.Contains(e.X, e.Y))
                {
                    return;
                }
            }
            ColorBgra bgra = this.LiftColor(e.X, e.Y);

            if ((e.Button & MouseButtons.Left) == MouseButtons.Left)
            {
                base.ToolSettings.PrimaryColor.Value = (ColorBgra32)bgra;
            }
            else if ((e.Button & MouseButtons.Right) == MouseButtons.Right)
            {
                base.ToolSettings.SecondaryColor.Value = (ColorBgra32)bgra;
            }
        }
Beispiel #2
0
        protected override void OnMouseMove(MouseEventArgsF e)
        {
            base.OnMouseMove(e);
            PointDouble point = e.Point;
            PointDouble num2  = this.RoundMouseCanvasPoint(point);

            if (this.moveOriginMode)
            {
                PointDouble num3 = new PointDouble(num2.X - this.lastXY.X, num2.Y - this.lastXY.Y);
                for (int i = 0; i < this.tracePoints.Count; i++)
                {
                    PointDouble num5 = this.tracePoints[i];
                    num5.X += num3.X;
                    num5.Y += num3.Y;
                    this.tracePoints[i] = num5;
                }
                this.lastXY = num2;
                this.Render();
            }
            else if (this.tracking)
            {
                foreach (PointDouble num6 in e.IntermediatePoints)
                {
                    PointDouble item = this.RoundMouseCanvasPoint(num6);
                    if (item != this.tracePoints[this.tracePoints.Count - 1])
                    {
                        this.tracePoints.Add(item);
                    }
                }
                this.hasMoved = true;
                this.Render();
            }
        }
Beispiel #3
0
        protected override void OnMouseDown(MouseEventArgsF e)
        {
            base.OnMouseDown(e);
            if (this.mouseDown != MouseButtons.None)
            {
                this.moveOffsetMode = true;
            }
            else
            {
                switch (e.Button)
                {
                case MouseButtons.Left:
                    base.Cursor = this.cursorZoomIn;
                    break;

                case MouseButtons.Right:
                    base.Cursor = this.cursorZoomOut;
                    break;

                case MouseButtons.Middle:
                    base.Cursor = this.cursorZoomPan;
                    break;
                }
                this.mouseDown = e.Button;
                this.lastPt    = new PointInt32(e.X, e.Y);
                this.downPt    = this.lastPt;
                this.OnMouseMove(e);
            }
        }
Beispiel #4
0
 protected virtual void OnMouseMove(MouseEventArgsF e)
 {
     if (this.panMode || ((this.mouseDown > 0) && (UIUtil.AsyncMouseButtons != MouseButtons.None)))
     {
         this.AutoScrollIfNecessary(e.Point);
     }
 }
Beispiel #5
0
 public void RelayMouseUp(MouseEventArgsF e)
 {
     foreach (MouseButton button in WinFormsInputHelpers.FromWinFormsMouseButton(e.Button))
     {
         base.ProcessMouseUp(button);
     }
 }
Beispiel #6
0
 protected virtual void OnDocumentMouseMove(MouseEventArgsF e)
 {
     if (this.DocumentMouseMove != null)
     {
         this.DocumentMouseMove(this, e);
     }
 }
Beispiel #7
0
 protected override void OnMouseMove(MouseEventArgsF e)
 {
     base.OnMouseMove(e);
     if (this.ignoreMouseMove > 0)
     {
         this.ignoreMouseMove--;
     }
     else if (this.tracking)
     {
         Point point = new Point(e.X, e.Y);
         Size  size  = new Size(point.X - this.lastMouseXY.X, point.Y - this.lastMouseXY.Y);
         if ((size.Width != 0) || (size.Height != 0))
         {
             PointDouble documentScrollPosition = base.DocumentWorkspace.DocumentScrollPosition;
             PointDouble num2 = new PointDouble(documentScrollPosition.X - size.Width, documentScrollPosition.Y - size.Height);
             this.ignoreMouseMove++;
             base.DocumentWorkspace.DocumentScrollPosition = num2;
             this.lastMouseXY    = point;
             this.lastMouseXY.X -= size.Width;
             this.lastMouseXY.Y -= size.Height;
         }
     }
     else if (base.CanPan())
     {
         base.Cursor = this.cursorMouseUp;
     }
     else
     {
         base.Cursor = this.cursorMouseInvalid;
     }
 }
Beispiel #8
0
 protected virtual void OnDocumentMouseUp(MouseEventArgsF e)
 {
     this.CheckForFirstInputAfterGotFocus();
     if (this.DocumentMouseUp != null)
     {
         this.DocumentMouseUp(this, e);
     }
 }
Beispiel #9
0
 protected override void OnMouseMove(MouseEventArgsF e)
 {
     this.previewRenderer.BrushLocation = new PointDouble(e.Fx, e.Fy);
     this.previewRenderer.BrushSize     = (double)base.ToolSettings.PixelSampleMode.Value;
     base.OnMouseMove(e);
     if (this.mouseDown)
     {
         this.PickColor(e);
     }
 }
Beispiel #10
0
 protected override void OnMouseUp(MouseEventArgsF e)
 {
     base.OnMouseUp(e);
     if (base.CanPan())
     {
         base.Cursor = this.cursorMouseUp;
     }
     else
     {
         base.Cursor = this.cursorMouseInvalid;
     }
     this.tracking = false;
 }
Beispiel #11
0
 protected override void OnMouseUp(MouseEventArgsF e)
 {
     this.OnMouseMove(e);
     if (this.moveOriginMode)
     {
         this.moveOriginMode = false;
     }
     else
     {
         this.Done();
     }
     base.OnMouseUp(e);
     base.Cursor = this.GetCursor();
 }
Beispiel #12
0
        private void MouseMoveHandlerImpl(PointDouble docPoint, MouseButtons button, int clicks, int delta, IEnumerable <PointDouble> intermediatePoints)
        {
            if (this.RulersEnabled)
            {
                int num  = (docPoint.X > 0.0) ? ((int)Math.Truncate(docPoint.X)) : ((docPoint.X < 0.0) ? ((int)Math.Truncate((double)(docPoint.X - 1.0))) : 0);
                int num2 = (docPoint.Y > 0.0) ? ((int)Math.Truncate(docPoint.Y)) : ((docPoint.Y < 0.0) ? ((int)Math.Truncate((double)(docPoint.Y - 1.0))) : 0);
                this.topRuler.Value  = num;
                this.leftRuler.Value = num2;
                this.UpdateRulerOffsets();
            }
            MouseEventArgsF e = new MouseEventArgsF(button, clicks, docPoint.X, docPoint.Y, delta, intermediatePoints);

            this.OnDocumentMouseMove(e);
        }
Beispiel #13
0
 protected override void OnMouseDown(MouseEventArgsF e)
 {
     base.OnMouseDown(e);
     this.lastMouseXY = new Point(e.X, e.Y);
     this.tracking    = true;
     if (base.CanPan())
     {
         base.Cursor = this.cursorMouseDown;
     }
     else
     {
         base.Cursor = this.cursorMouseInvalid;
     }
 }
Beispiel #14
0
 private void MouseUp(MouseEventArgsF e)
 {
     this.mouseDown--;
     if (this.panMode)
     {
         this.Cursor = this.CurrentPanModeCursor;
     }
     else
     {
         this.OnMouseUp(e);
     }
     if (((this.mouseDown == 0) && this.panMode) && (e.Button == MouseButtons.Middle))
     {
         this.LeavePanMode();
     }
     this.lastMouseXY = new PointInt32(e.X, e.Y);
 }
Beispiel #15
0
        protected override void OnMouseMove(MouseEventArgsF e)
        {
            base.OnMouseMove(e);
            PointInt32 b = new PointInt32(e.X, e.Y);

            if (this.moveOffsetMode)
            {
                VectorInt32 num2 = (VectorInt32)(b - this.lastPt);
                this.downPt.X += num2.X;
                this.downPt.Y += num2.Y;
            }
            if ((e.Button == MouseButtons.Left) && (this.mouseDown == MouseButtons.Left))
            {
                VectorDouble num3 = (VectorDouble)(b - this.downPt);
                if (num3.Length >= 10.0)
                {
                    goto Label_00B1;
                }
            }
            if (!this.rect.HasPositiveArea)
            {
                if ((e.Button == MouseButtons.Middle) && (this.mouseDown == MouseButtons.Middle))
                {
                    PointDouble documentScrollPosition = base.DocumentWorkspace.DocumentScrollPosition;
                    documentScrollPosition.X += b.X - this.lastPt.X;
                    documentScrollPosition.Y += b.Y - this.lastPt.Y;
                    base.DocumentWorkspace.DocumentScrollPosition = documentScrollPosition;
                    base.Update();
                }
                else
                {
                    this.rect = RectInt32.Zero;
                }
                goto Label_0173;
            }
Label_00B1:
            this.rect = RectInt32Util.FromPixelPoints(this.downPt, b);
            this.rect = RectInt32.Intersect(this.rect, base.ActiveLayer.Bounds());
            this.UpdateDrawnRect();
Label_0173:
            this.lastPt = b;
        }
Beispiel #16
0
 private void MouseMove(MouseEventArgsF e)
 {
     if (this.ignoreMouseMove > 0)
     {
         this.ignoreMouseMove--;
     }
     else if (this.panTracking && ((e.Button == MouseButtons.Left) || (e.Button == MouseButtons.Middle)))
     {
         switch (UIUtil.AsyncMouseButtons)
         {
         case MouseButtons.Left:
         case MouseButtons.Middle:
         {
             PointInt32  num    = new PointInt32(e.X, e.Y);
             PointDouble center = this.DocumentWorkspace.VisibleDocumentRect.Center;
             PointDouble num4   = new PointDouble((double)(e.X - this.lastPanMouseXY.X), (double)(e.Y - this.lastPanMouseXY.Y));
             PointDouble documentScrollPosition = this.DocumentWorkspace.DocumentScrollPosition;
             if ((num4.X != 0.0) || (num4.Y != 0.0))
             {
                 documentScrollPosition.X -= num4.X;
                 documentScrollPosition.Y -= num4.Y;
                 this.lastPanMouseXY       = new PointInt32(e.X, e.Y);
                 this.lastPanMouseXY.X    -= (int)Math.Truncate(num4.X);
                 this.lastPanMouseXY.Y    -= (int)Math.Truncate(num4.Y);
                 using (this.UseIgnoreMouseMove())
                 {
                     this.DocumentWorkspace.DocumentScrollPosition = documentScrollPosition;
                 }
                 this.Update();
             }
             break;
         }
         }
     }
     else if (!this.panMode)
     {
         this.OnMouseMove(e);
     }
     this.lastMouseXY = new PointInt32(e.X, e.Y);
     this.lastButton  = e.Button;
 }
Beispiel #17
0
        protected override void OnMouseUp(MouseEventArgsF e)
        {
            base.OnMouseUp(e);
            this.OnMouseMove(e);
            bool flag = true;

            base.Cursor = this.cursorZoom;
            if (this.moveOffsetMode)
            {
                this.moveOffsetMode = false;
                flag = false;
            }
            else if ((this.mouseDown == MouseButtons.Left) || (this.mouseDown == MouseButtons.Right))
            {
                RectInt32 rect = this.rect;
                this.rect = RectInt32.Zero;
                this.UpdateDrawnRect();
                if (e.Button == MouseButtons.Left)
                {
                    VectorDouble num2 = new VectorDouble((double)rect.Width, (double)rect.Height);
                    if (num2.Length < 10.0)
                    {
                        base.DocumentWorkspace.ZoomIn();
                    }
                    else
                    {
                        base.DocumentWorkspace.ZoomToRectangle(rect);
                    }
                }
                else
                {
                    base.DocumentWorkspace.ZoomOut();
                }
                this.outline.Reset();
            }
            if (flag)
            {
                this.mouseDown = MouseButtons.None;
            }
        }
Beispiel #18
0
        protected override void OnMouseUp(MouseEventArgsF e)
        {
            base.OnMouseUp(e);
            this.mouseDown = false;
            switch (base.ToolSettings.ColorPickerClickBehavior.Value)
            {
            case ColorPickerClickBehavior.NoToolSwitch:
                break;

            case ColorPickerClickBehavior.SwitchToLastTool:
                base.DocumentWorkspace.SetToolFromType(base.DocumentWorkspace.PreviousActiveToolType);
                return;

            case ColorPickerClickBehavior.SwitchToPencilTool:
                base.DocumentWorkspace.SetToolFromType(typeof(PencilTool));
                return;

            default:
                ExceptionUtil.ThrowInternalErrorException();
                break;
            }
        }
Beispiel #19
0
 private void MouseDown(MouseEventArgsF e)
 {
     this.mouseDown++;
     this.ResetLastAutoScrollTime();
     if ((!this.panMode && (this.mouseDown == 1)) && (e.Button == MouseButtons.Middle))
     {
         this.EnterPanMode();
     }
     if (this.panMode)
     {
         this.panTracking    = true;
         this.lastPanMouseXY = new PointInt32(e.X, e.Y);
         if (this.CanPan())
         {
             this.Cursor = this.CurrentPanModeCursor;
         }
     }
     else
     {
         this.OnMouseDown(e);
     }
     this.lastMouseXY = new PointInt32(e.X, e.Y);
 }
Beispiel #20
0
        protected override void OnMouseDown(MouseEventArgsF e)
        {
            base.OnMouseDown(e);
            base.Cursor = this.GetCursor();
            PointDouble point = e.Point;
            PointDouble item  = this.RoundMouseCanvasPoint(point);

            if (this.tracking)
            {
                this.moveOriginMode = true;
                this.lastXY         = item;
                this.OnMouseMove(e);
            }
            else if (((e.Button & MouseButtons.Left) == MouseButtons.Left) || ((e.Button & MouseButtons.Right) == MouseButtons.Right))
            {
                this.tracking    = true;
                this.hasMoved    = false;
                this.startTime   = DateTime.Now;
                this.tracePoints = new SegmentedList <PointDouble>();
                this.tracePoints.Add(item);
                this.undoAction  = new SelectionHistoryMemento("sentinel", base.Image, base.DocumentWorkspace);
                this.wasNotEmpty = !base.Selection.IsEmpty;
                if (((base.ModifierKeys & Keys.Control) != Keys.None) && (e.Button == MouseButtons.Left))
                {
                    this.combineMode = SelectionCombineMode.Union;
                }
                else if (((base.ModifierKeys & Keys.Alt) != Keys.None) && (e.Button == MouseButtons.Left))
                {
                    this.combineMode = SelectionCombineMode.Exclude;
                }
                else if (((base.ModifierKeys & Keys.Control) != Keys.None) && (e.Button == MouseButtons.Right))
                {
                    this.combineMode = SelectionCombineMode.Xor;
                }
                else if (((base.ModifierKeys & Keys.Alt) != Keys.None) && (e.Button == MouseButtons.Right))
                {
                    this.combineMode = SelectionCombineMode.Intersect;
                }
                else
                {
                    this.combineMode = base.ToolSettings.Selection.CombineMode.Value;
                }
                base.DocumentWorkspace.EnableSelectionOutline = false;
                Result <GeometryList> oldSelectionGeometryLazy0 = base.Selection.GetCachedLazyGeometryList();
                this.oldSelectionGeometryLazy = oldSelectionGeometryLazy0;
                Work.QueueWorkItem(delegate {
                    Result <GeometryList> oldSelectionGeometryLazy = this.oldSelectionGeometryLazy;
                    if (oldSelectionGeometryLazy0 == oldSelectionGeometryLazy)
                    {
                        oldSelectionGeometryLazy.EnsureEvaluated();
                    }
                });
                this.newSelection.Restore(base.Selection.Save());
                switch (this.combineMode)
                {
                case SelectionCombineMode.Replace:
                    this.append = false;
                    base.Selection.Reset();
                    break;

                case SelectionCombineMode.Union:
                case SelectionCombineMode.Exclude:
                case SelectionCombineMode.Intersect:
                case SelectionCombineMode.Xor:
                    this.append = true;
                    base.Selection.ResetContinuation();
                    break;

                default:
                    throw ExceptionUtil.InvalidEnumArgumentException <SelectionCombineMode>(this.combineMode, "this.combineMode");
                }
                this.newSelectionRenderer.IsVisible = true;
                if (this.tracePoints.Count >= this.MinPointsForRender)
                {
                    this.Render();
                }
            }
        }
Beispiel #21
0
 protected virtual void OnMouseUp(MouseEventArgsF e)
 {
     this.lastButton = e.Button;
 }
Beispiel #22
0
 public void PerformMouseDown(MouseEventArgsF e)
 {
     this.DocumentCanvas.MouseLocation = e.Point;
     this.DocumentWorkspace.Focus();
     this.MouseDown(e);
 }
Beispiel #23
0
 public void PerformMouseMove(MouseEventArgsF e)
 {
     this.DocumentCanvas.MouseLocation = e.Point;
     this.MouseMove(e);
 }
Beispiel #24
0
 public void PerformMouseUp(MouseEventArgsF e)
 {
     this.MouseUp(e);
 }
Beispiel #25
0
 public void PerformDocumentMouseUp(MouseEventArgsF e)
 {
     this.OnDocumentMouseUp(e);
 }
Beispiel #26
0
 public void RelayMouseMove(MouseEventArgsF e)
 {
     base.ProcessMouseMove(e.Point, e.IntermediatePoints);
 }
Beispiel #27
0
 protected override void OnMouseMove(MouseEventArgsF e)
 {
     this.UpdateAnchor();
     base.OnMouseMove(e);
 }
Beispiel #28
0
 protected override void OnMouseDown(MouseEventArgsF e)
 {
     base.OnMouseDown(e);
     this.mouseDown = true;
     this.PickColor(e);
 }