Пример #1
0
        private void UpdateAnchor()
        {
            if (base.UI != null)
            {
                base.UI.AnchorRadius = ((double)base.ToolSettings.Pen.Width.Value) / 2.0;
                switch (this.GetStaticData().anchorOffsetMode)
                {
                case AnchorOffsetMode.NotSet:
                    this.GetStaticData().anchorCenter = new PointDouble(-131072.0, -131072.0);
                    break;

                case AnchorOffsetMode.Absolute:
                    this.GetStaticData().anchorCenter = (PointDouble)this.GetStaticData().anchorOffset;
                    break;

                case AnchorOffsetMode.Relative:
                {
                    PointDouble?nullable       = base.PresentationSource.PrimaryMouseDevice.TryGetPosition(base.UI);
                    PointDouble mouseTopLeftPt = nullable.HasValue ? nullable.GetValueOrDefault() : PointDouble.Zero;
                    PointDouble mouseCenterPt  = BrushToolBase <CloneStampTool, CloneStampToolChanges, CloneStampToolUI> .GetMouseCenterPt(mouseTopLeftPt, base.CanvasView.CanvasHairWidth);

                    this.GetStaticData().anchorCenter = mouseCenterPt + this.GetStaticData().anchorOffset;
                    break;
                }

                default:
                    throw new InternalErrorException(ExceptionUtil.InvalidEnumArgumentException <AnchorOffsetMode>(this.GetStaticData().anchorOffsetMode, "this.anchorOffsetMode"));
                }
                base.UI.AnchorCenter    = this.GetStaticData().anchorCenter;
                base.UI.IsAnchorVisible = this.GetStaticData().anchorOffsetMode > AnchorOffsetMode.NotSet;
            }
        }
Пример #2
0
        protected override void OnUIDragBegin(object sender, PaintDotNet.UI.Input.MouseEventArgs e)
        {
            if (e.Source is UIElement)
            {
                bool        flag          = (base.PresentationSource.PrimaryKeyboardDevice.Modifiers & ModifierKeys.Control) == ModifierKeys.Control;
                PointDouble mouseCenterPt = BrushToolBase <CloneStampTool, CloneStampToolChanges, CloneStampToolUI> .GetMouseCenterPt(e.GetPosition(base.UI), base.CanvasView.CanvasHairWidth);

                if (flag)
                {
                    this.isHandlingDrag = true;
                    this.GetStaticData().anchorOffsetMode = AnchorOffsetMode.Absolute;
                    this.GetStaticData().anchorOffset     = (VectorDouble)mouseCenterPt;
                    this.GetStaticData().anchorLayerWeak  = new WeakReferenceT <Layer>(base.ActiveLayer);
                    this.UpdateAnchor();
                    e.Handled = true;
                }
                else if (this.GetStaticData().anchorOffsetMode == AnchorOffsetMode.NotSet)
                {
                    this.isHandlingDrag = true;
                    e.Handled           = true;
                }
                else if (this.GetStaticData().anchorOffsetMode == AnchorOffsetMode.Absolute)
                {
                    PointDouble anchorCenter = this.GetStaticData().anchorCenter;
                    this.GetStaticData().anchorOffsetMode = AnchorOffsetMode.Relative;
                    VectorDouble num4 = (VectorDouble)(((PointDouble)this.GetStaticData().anchorOffset) - mouseCenterPt);
                    this.GetStaticData().anchorOffset = num4;
                    this.UpdateAnchor();
                    PointDouble num5 = this.GetStaticData().anchorCenter;
                }
            }
            base.OnUIDragBegin(sender, e);
        }
Пример #3
0
        protected override void OnUIDragMove(object sender, PaintDotNet.UI.Input.MouseEventArgs e)
        {
            if (this.isHandlingDrag && (e.Source is UIElement))
            {
                PointDouble mouseCenterPt = BrushToolBase <CloneStampTool, CloneStampToolChanges, CloneStampToolUI> .GetMouseCenterPt(e.GetPosition(base.UI), base.CanvasView.CanvasHairWidth);

                if (this.GetStaticData().anchorOffsetMode == AnchorOffsetMode.Absolute)
                {
                    this.GetStaticData().anchorOffset = (VectorDouble)mouseCenterPt;
                    this.UpdateAnchor();
                }
                e.Handled = true;
            }
            this.UpdateAnchor();
            base.OnUIDragMove(sender, e);
        }
Пример #4
0
        protected override void OnUIDragEnd(object sender, PaintDotNet.UI.Input.MouseEventArgs e)
        {
            if (this.isHandlingDrag)
            {
                if (e.Source is UIElement)
                {
                    PointDouble mouseCenterPt = BrushToolBase <CloneStampTool, CloneStampToolChanges, CloneStampToolUI> .GetMouseCenterPt(e.GetPosition(base.UI), base.CanvasView.CanvasHairWidth);

                    if (this.GetStaticData().anchorOffsetMode == AnchorOffsetMode.Absolute)
                    {
                        this.GetStaticData().anchorOffset = (VectorDouble)mouseCenterPt;
                        this.UpdateAnchor();
                    }
                    else if (this.GetStaticData().anchorOffsetMode == AnchorOffsetMode.NotSet)
                    {
                        string message = PdnResources.GetString("CloneStampTool.Error.TriedToDrawWithoutAnchor.Text");
                        MessageBoxUtil.ErrorBox(base.DocumentWorkspace, message);
                    }
                }
                e.Handled           = true;
                this.isHandlingDrag = false;
            }
            base.OnUIDragEnd(sender, e);
        }