private void OnCanvasViewIsHighQualityScalingEnabledChanged(object sender, ValueChangedEventArgs <bool> e)
 {
     if (!base.CheckAccess())
     {
         PaintDotNet.Canvas.Canvas owner = base.Owner;
         if ((owner != null) && (owner.Dispatcher != null))
         {
             try
             {
                 object[] args = new object[] { sender, e };
                 base.Owner.Dispatcher.BeginInvoke(new Action <object, ValueChangedEventArgs <bool> >(this.OnCanvasViewIsHighQualityScalingEnabledChanged), args);
             }
             catch (Exception)
             {
             }
         }
     }
     else if (!base.IsDisposed)
     {
         CanvasView key = (CanvasView)sender;
         if (this.documentCanvasLayerViews.ContainsKey(key))
         {
             this.RecreateDocumentCanvasLayerView(key);
             key.Invalidate(key.GetCanvasBounds());
         }
     }
 }
Beispiel #2
0
 private void OnCanvasChanged(PaintDotNet.Canvas.Canvas oldValue, PaintDotNet.Canvas.Canvas newValue)
 {
     if (oldValue != null)
     {
         oldValue.Invalidated -= new EventHandler <CanvasInvalidatedEventArgs>(this.OnCanvasInvalidated);
     }
     if (newValue != null)
     {
         newValue.Invalidated += new EventHandler <CanvasInvalidatedEventArgs>(this.OnCanvasInvalidated);
     }
     this.CanvasChanged.Raise <PaintDotNet.Canvas.Canvas>(this, oldValue, newValue);
 }
Beispiel #3
0
        private bool OnLayoutImpl()
        {
            Rectangle clientRectangle = base.ClientRectangle;
            Size      size            = clientRectangle.Size;

            if ((size.Width >= 0) && (size.Height >= 0))
            {
                RectDouble viewportRect = clientRectangle.ToRectDouble();
                SizeDouble num2         = size.ToSizeDouble();
                int        horizontalScrollBarHeight     = SystemInformation.HorizontalScrollBarHeight;
                int        verticalScrollBarWidth        = SystemInformation.VerticalScrollBarWidth;
                PaintDotNet.Canvas.Canvas     canvas     = this.canvasControl.Canvas;
                PaintDotNet.Canvas.CanvasView canvasView = this.canvasControl.CanvasView;
                SizeDouble      canvasSize              = canvasView.CanvasSize;
                RectDouble      canvasBounds            = canvasView.GetCanvasBounds();
                SizeDouble      viewportSize            = canvasView.ViewportSize;
                SizeDouble      num9                    = canvasView.ViewportCanvasBounds.Size;
                PointDouble     viewportCanvasOffset    = canvasView.ViewportCanvasOffset;
                PointDouble     viewportCanvasOffsetMin = canvasView.ViewportCanvasOffsetMin;
                PointDouble     viewportCanvasOffsetMax = canvasView.ViewportCanvasOffsetMax;
                SizeDouble      num14                   = canvasView.ConvertViewportToCanvas(viewportRect).Size;
                SizeDouble      num15                   = new SizeDouble(Math.Max((double)0.0, (double)(num2.Width - verticalScrollBarWidth)), Math.Max((double)0.0, (double)(num2.Height - horizontalScrollBarHeight)));
                RectDouble      num16                   = new RectDouble(viewportRect.Location, num15);
                SizeDouble      num18                   = canvasView.ConvertViewportToCanvas(num16).Size;
                ThicknessDouble frameCanvasPadding      = canvasView.FrameCanvasPadding;
                RectDouble      framedCanvasBounds      = canvasView.FramedCanvasBounds;
                bool            flag                    = false;
                bool            flag2                   = false;
                if ((this.canvasControl == null) || (canvasView.ScaleBasis == ScaleBasis.FitToViewport))
                {
                    flag  = false;
                    flag2 = false;
                }
                else
                {
                    if (framedCanvasBounds.Width > num14.Width)
                    {
                        flag = true;
                        if (framedCanvasBounds.Height > num18.Height)
                        {
                            flag2 = true;
                        }
                    }
                    if (framedCanvasBounds.Height > num14.Height)
                    {
                        flag2 = true;
                        if (framedCanvasBounds.Width > num18.Width)
                        {
                            flag = true;
                        }
                    }
                }
                int       num21      = size.Width - (flag2 ? verticalScrollBarWidth : 0);
                int       width      = Math.Max(0, num21);
                int       num23      = size.Height - (flag ? horizontalScrollBarHeight : 0);
                int       height     = Math.Max(0, num23);
                Rectangle rectangle2 = new Rectangle(0, 0, width, height);
                double    scaleRatio = canvasView.ScaleRatio;
                this.canvasControl.Bounds = rectangle2;
                this.canvasControl.PerformLayout();
                canvasView.CoerceValue(PaintDotNet.Canvas.CanvasView.ScaleRatioProperty);
                if ((canvasView.ScaleRatio != scaleRatio) || (canvasView.ViewportSize != viewportSize))
                {
                    return(false);
                }
                if (flag)
                {
                    Rectangle newBounds      = new Rectangle(0, size.Height - horizontalScrollBarHeight, size.Width - (flag2 ? verticalScrollBarWidth : 0), horizontalScrollBarHeight);
                    int       min            = this.ConvertToScrollBar(viewportCanvasOffsetMin.X);
                    int       max            = this.ConvertToScrollBar(viewportCanvasOffsetMax.X + num9.Width);
                    int       newLargeChange = this.ConvertToScrollBar(num9.Width);
                    int       newSmallChange = this.ConvertToScrollBar(num9.Width / 10.0);
                    int       newValue       = Int32Util.Clamp(this.ConvertToScrollBar(viewportCanvasOffset.X), min, max);
                    UpdateScrollBar(this.hScrollBar, newBounds, min, max, newLargeChange, newSmallChange, newValue);
                }
                if (flag2)
                {
                    Rectangle rectangle4 = new Rectangle(size.Width - verticalScrollBarWidth, 0, verticalScrollBarWidth, size.Height - (flag ? horizontalScrollBarHeight : 0));
                    int       num31      = this.ConvertToScrollBar(viewportCanvasOffsetMin.Y);
                    int       num32      = this.ConvertToScrollBar(viewportCanvasOffsetMax.Y + num9.Height);
                    int       num33      = this.ConvertToScrollBar(num9.Height);
                    int       num34      = this.ConvertToScrollBar(num9.Height / 10.0);
                    int       num35      = Int32Util.Clamp(this.ConvertToScrollBar(viewportCanvasOffset.Y), num31, num32);
                    UpdateScrollBar(this.vScrollBar, rectangle4, num31, num32, num33, num34, num35);
                }
                this.hScrollBar.Visible = flag;
                this.vScrollBar.Visible = flag2;
            }
            return(true);
        }
Beispiel #4
0
 protected virtual void OnCanvasChanged(PaintDotNet.Canvas.Canvas oldValue, PaintDotNet.Canvas.Canvas newValue)
 {
 }