예제 #1
0
        protected override void OnLayout(LayoutEventArgs levent)
        {
            int num;

            if (this.historyStack == null)
            {
                num = 0;
            }
            else
            {
                num = this.historyStack.UndoStack.Count + this.historyStack.RedoStack.Count;
            }
            int num2 = num * this.itemHeight;

            if (num2 > base.ClientSize.Height)
            {
                this.vScrollBar.Visible     = true;
                this.vScrollBar.Location    = new PointInt32(base.ClientSize.Width - this.vScrollBar.Width, 0).ToGdipPoint();
                this.vScrollBar.Height      = base.ClientSize.Height;
                this.vScrollBar.Minimum     = 0;
                this.vScrollBar.Maximum     = num2;
                this.vScrollBar.LargeChange = base.ClientSize.Height;
                this.vScrollBar.SmallChange = this.itemHeight;
            }
            else
            {
                this.vScrollBar.Visible = false;
            }
            if (this.historyStack != null)
            {
                this.ScrollOffset = Int32Util.Clamp(this.ScrollOffset, this.MinScrollOffset, this.MaxScrollOffset);
            }
            base.OnLayout(levent);
        }
예제 #2
0
        public void AddToGridSize(int delta)
        {
            int newWidth = Int32Util.Clamp(GridWidth + delta, minGridSize, maxGridSize);

            GridWidth = newWidth;

            int newHeight = Int32Util.Clamp(GridHeight + delta, minGridSize, maxGridSize);

            GridHeight = newHeight;
        }
예제 #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);
        }
예제 #4
0
 private void OnScrollOffsetChanged()
 {
     this.vScrollBar.Value = Int32Util.Clamp(this.scrollOffset, this.vScrollBar.Minimum, this.vScrollBar.Maximum);
     this.ScrollOffsetChanged.Raise(this);
 }
예제 #5
0
            public unsafe void DrawScansNearestNeighbor(int cpuNumber)
            {
                int       logicalCpuCount = Processor.LogicalCpuCount;
                void *    voidStar        = this.src.Scan0.VoidStar;
                int       stride          = this.src.Stride;
                RectInt32 b = this.dst.Bounds <ColorBgra>();

                for (int i = cpuNumber; i < this.dstScans.Length; i += logicalCpuCount)
                {
                    RectInt32 num5 = RectInt32.Intersect(this.dstScans[i], b);
                    if ((num5.Width != 0) && (num5.Height != 0))
                    {
                        PointDouble pt = new PointDouble((double)num5.X, (double)num5.Y);
                        pt.X += 0.5;
                        pt.Y += 0.5;
                        pt    = this.inverse.Transform(pt);
                        pt.X -= this.boundsX;
                        pt.Y -= this.boundsY;
                        pt.X -= 0.5;
                        pt.Y -= 0.5;
                        int num7 = (int)(pt.X * 16384.0);
                        int num8 = (int)(pt.Y * 16384.0);
                        for (int j = num5.Y; j < (num5.Y + num5.Height); j++)
                        {
                            int num10 = num7;
                            int num11 = num8;
                            num7 += this.fp_dsxddy;
                            num8 += this.fp_dsyddy;
                            if (j >= 0)
                            {
                                int        x            = num5.X;
                                ColorBgra *pointAddress = this.dst.GetPointAddress(x, j);
                                ColorBgra *bgraPtr2     = pointAddress + num5.Width;
                                int        num13        = num10 + (this.fp_dsxddx * (num5.Width - 1));
                                int        num14        = num11 + (this.fp_dsyddx * (num5.Width - 1));
                                while (pointAddress < bgraPtr2)
                                {
                                    int num15 = (num10 + 0x1fff) >> 14;
                                    int num16 = (num11 + 0x1fff) >> 14;
                                    int num17 = Int32Util.Clamp(num15, 0, this.src.Width - 1);
                                    int y     = Int32Util.Clamp(num16, 0, this.src.Height - 1);
                                    pointAddress[0] = this.src.GetPointUnchecked(num17, y);
                                    pointAddress++;
                                    num10 += this.fp_dsxddx;
                                    num11 += this.fp_dsyddx;
                                    if ((num17 == num15) && (y == num16))
                                    {
                                        break;
                                    }
                                }
                                ColorBgra *bgraPtr3 = pointAddress;
                                pointAddress = bgraPtr2 - 1;
                                while (pointAddress >= bgraPtr3)
                                {
                                    int num19 = (num13 + 0x1fff) >> 14;
                                    int num20 = (num14 + 0x1fff) >> 14;
                                    int num21 = Int32Util.Clamp(num19, 0, this.src.Width - 1);
                                    int num22 = Int32Util.Clamp(num20, 0, this.src.Height - 1);
                                    pointAddress[0] = this.src.GetPointUnchecked(num21, num22);
                                    if ((num21 == num19) && (num22 == num20))
                                    {
                                        break;
                                    }
                                    pointAddress--;
                                    num13 -= this.fp_dsxddx;
                                    num14 -= this.fp_dsyddx;
                                }
                                ColorBgra *bgraPtr4 = pointAddress;
                                while (bgraPtr3 < bgraPtr4)
                                {
                                    int num23 = (num10 + 0x1fff) >> 14;
                                    int num24 = (num11 + 0x1fff) >> 14;
                                    bgraPtr3->Bgra = (((IntPtr)(num23 * sizeof(ColorBgra))) + (voidStar + (num24 * stride))).Bgra;
                                    bgraPtr3++;
                                    num10 += this.fp_dsxddx;
                                    num11 += this.fp_dsyddx;
                                }
                            }
                        }
                    }
                }
            }
예제 #6
0
        public void AddToPenSize(int delta)
        {
            int newWidth = Int32Util.Clamp(BrushSize + delta, minPenSize, maxPenSize);

            BrushSize = newWidth;
        }
예제 #7
0
        protected override void OnLayout(LayoutEventArgs levent)
        {
            int  num15;
            int  num16;
            int  y    = UIUtil.ScaleWidth(8);
            int  x    = UIUtil.ScaleHeight(8);
            Size size = UIUtil.ScaleSize(0x55, 0x18);

            this.errorIconBox.Location = new Point(x, y);
            this.errorIconBox.Size     = this.errorIconBox.Image.Size;
            this.errorIconBox.PerformLayout();
            this.messageLabel.Location = new Point(this.errorIconBox.Right + x, this.errorIconBox.Top);
            this.messageLabel.Width    = (base.ClientSize.Width - this.messageLabel.Left) - x;
            this.messageLabel.Height   = this.messageLabel.GetPreferredSize(new Size(this.messageLabel.Width, 1)).Height;
            bool flag = !string.IsNullOrWhiteSpace(this.message2Label.Text);

            this.message2Label.Location = new Point(this.messageLabel.Left, this.messageLabel.Bottom + (flag ? y : 0));
            this.message2Label.Width    = (base.ClientSize.Width - this.message2Label.Left) - x;
            this.message2Label.Height   = flag ? this.message2Label.GetPreferredSize(new Size(this.message2Label.Width, 1)).Height : 0;
            int num3 = y + Math.Max(this.errorIconBox.Bottom, this.message2Label.Bottom);

            this.bottomSeparator.Location = new Point(x, num3);
            int width = base.ClientSize.Width - (2 * x);

            this.bottomSeparator.Width = width;
            this.bottomSeparator.Size  = this.bottomSeparator.GetPreferredSize(new Size(width, 1));
            this.button2.Size          = size;
            this.button2.PerformLayout();
            int num5 = this.bottomSeparator.Bottom + y;

            this.button2.Location = new Point((base.ClientSize.Width - x) - this.button2.Width, num5);
            int num6 = this.bottomSeparator.Bottom + y;

            this.button1.Size = size;
            this.button1.PerformLayout();
            int top = this.button2.Top;

            this.button1.Location   = new Point((this.button2.Left - x) - this.button1.Width, top);
            this.detailsButton.Size = size;
            this.detailsButton.PerformLayout();
            int num8 = this.bottomSeparator.Bottom + y;

            this.detailsButton.Location = new Point(x, num8);
            int num9 = y + Int32Util.Max(this.detailsButton.Bottom, this.button2.Bottom, this.button1.Bottom);

            this.copyToClipboardButton.Location = new Point(x, num9);
            this.copyToClipboardButton.Size     = size;
            this.copyToClipboardButton.PerformLayout();
            this.copyToClipboardButton.Size = this.copyToClipboardButton.GetPreferredSize(this.copyToClipboardButton.Size);
            this.folderIconBox.Size         = UIUtil.ScaleSize(this.folderIconBox.Image.Size);
            this.folderIconBox.Location     = new Point(this.copyToClipboardButton.Right + x, this.copyToClipboardButton.Top + ((this.copyToClipboardButton.Height - this.folderIconBox.Height) / 2));
            this.openFolderLink.Size        = this.openFolderLink.GetPreferredSize(new Size(1, 1));
            this.openFolderLink.Location    = new Point(this.folderIconBox.Right + (x / 2), this.folderIconBox.Top + ((this.folderIconBox.Height - this.openFolderLink.Height) / 2));
            int num10 = UIUtil.ScaleHeight(250);

            if (this.crashLogTextBox.Visible)
            {
                int num19 = y + Int32Util.Max(this.copyToClipboardButton.Bottom, this.folderIconBox.Bottom, this.openFolderLink.Bottom);
                this.crashLogTextBox.Location = new Point(x, num19);
                this.crashLogTextBox.Width    = base.ClientSize.Width - (2 * x);
                int num20 = (base.ClientSize.Height - y) - this.crashLogTextBox.Top;
                this.crashLogTextBox.Height = Math.Max(num10, num20);
            }
            int num11 = y + Int32Util.Max(this.detailsButton.Bottom, this.button1.Bottom, this.button2.Bottom, this.crashLogTextBox.Visible ? this.crashLogTextBox.Bottom : 0);
            int num12 = (((x + (this.detailsButton.Visible ? (this.detailsButton.Width + x) : 0)) + (this.button1.Visible ? (this.button1.Width + x) : 0)) + this.button2.Width) + x;
            int num13 = (x + (this.copyToClipboardButton.Visible ? (this.copyToClipboardButton.Width + x) : 0)) + (this.openFolderLink.Visible ? (this.openFolderLink.Width + x) : 0);
            int num14 = Math.Max(num12, num13);

            if (this.crashLogTextBox.Visible)
            {
                num15 = (num11 - this.crashLogTextBox.Height) + num10;
                num16 = 0x7d0;
            }
            else
            {
                num15 = num11;
                num16 = num11;
            }
            int[] vals   = new int[] { base.ClientSize.Width };
            int   num17  = Int32Util.Max(num14, vals);
            int   height = Int32Util.Clamp(base.ClientSize.Height, num15, num16);

            base.ClientSize    = new Size(num17, height);
            this.minClientSize = new Size(num14, num15);
            this.maxClientSize = new Size(0x7d0, num16);
            base.OnLayout(levent);
        }