예제 #1
0
        private SizeInt32 GetTileBufferSize(int tileColumn, int tileRow)
        {
            RectInt32 tileSourceRect = this.tileMathHelper.GetTileSourceRect(tileColumn, tileRow);
            int       width          = Int32Util.DivLog2RoundUp(tileSourceRect.Width, this.mipLevel);

            return(new SizeInt32(width, Int32Util.DivLog2RoundUp(tileSourceRect.Height, this.mipLevel)));
        }
예제 #2
0
        private void Render(Surface dst, Surface src, Rectangle rect)
        {
            ColorBgra currentPixel;

            for (int y = rect.Top; y < rect.Bottom; y++)
            {
                if (IsCancelRequested)
                {
                    return;
                }
                for (int x = rect.Left; x < rect.Right; x++)
                {
                    if ((horLoops > 1 || verLoops > 1) && !puzzleRect.Contains(x, y))
                    {
                        currentPixel   = src[x, y];
                        currentPixel.A = 0; // Delete pixels outside the puzzle border
                    }
                    else if (transparent)
                    {
                        currentPixel   = src[x, y];
                        currentPixel.A = Int32Util.ClampToByte(byte.MaxValue - puzzleSurface[x, y].A);
                    }
                    else
                    {
                        currentPixel = normalOp.Apply(src[x, y], puzzleSurface[x, y]);
                    }

                    dst[x, y] = currentPixel;
                }
            }
        }
예제 #3
0
 public static void IsClamped(int value, int min, int max, string valueName)
 {
     if (!Int32Util.SafeIsClamped(value, min, max))
     {
         IsClampedThrow(value, min, max, valueName);
     }
 }
        private void Render(Surface dst, Surface src, Rectangle rect)
        {
            if (blur != 0)
            {
                // Call the Gaussian Blur function
                blurEffect.Render(new Rectangle[] { rect }, 0, 1);
            }
            else
            {
                dst.CopySurface(shadowSurface, rect.Location, rect);
            }

            Rectangle selection  = EnvironmentParameters.GetSelection(src.Bounds).GetBoundsInt();
            Rectangle shadowRect = Rectangle.FromLTRB(
                selection.Left + margin + offsetX,
                selection.Top + margin + offsetY,
                selection.Right - margin + offsetX,
                selection.Bottom - margin + offsetY);
            ColorBgra shadowPixel;

            for (int y = rect.Top; y < rect.Bottom; y++)
            {
                if (IsCancelRequested)
                {
                    return;
                }
                for (int x = rect.Left; x < rect.Right; x++)
                {
                    shadowPixel   = dst[x, y];
                    shadowPixel.A = shadowRect.Contains(x, y) ? Int32Util.ClampToByte(shadowPixel.A * color.A / byte.MaxValue) : byte.MinValue;

                    dst[x, y] = normalOp.Apply(src[x, y], shadowPixel);
                }
            }
        }
예제 #5
0
        private IDeviceBitmap GetOrCreateDeviceBitmap(IDeviceResourceFactory factory, SizeInt32 desiredPixelSize)
        {
            base.VerifyAccess();
            IDeviceBitmap result = null;
            int           num    = Int32Util.Pow2RoundUp(desiredPixelSize.Width);
            int           num2   = Int32Util.Pow2RoundUp(desiredPixelSize.Height);
            int           width  = Math.Max(Math.Max(num, num2), 0x100);
            SizeInt32     num5   = new SizeInt32(width, width);

            while (this.deviceBitmapPool.TryDequeue(out result))
            {
                SizeInt32 pixelSize = result.PixelSize;
                if (((pixelSize.Width >= num5.Width) && (pixelSize.Width <= (num5.Width * 2))) && ((pixelSize.Height >= num5.Height) && (pixelSize.Height <= (num5.Height * 2))))
                {
                    break;
                }
                DisposableUtil.Free <IDeviceBitmap>(ref result);
            }
            if (result == null)
            {
                result = factory.CreateDeviceBitmap(desiredPixelSize, maskBitmapProperties);
                AttachedData.SetValue(result, isPooledBitmapAttachedKey, BooleanUtil.GetBoxed(true));
            }
            return(result);
        }
예제 #6
0
        void Render(Surface dst, Surface src, Rectangle rect)
        {
            Rectangle selection = EnvironmentParameters.GetSelection(src.Bounds).GetBoundsInt();

            ColorBgra sourcePixel, puzzlePixel, finalPixel;

            for (int y = rect.Top; y < rect.Bottom; y++)
            {
                if (IsCancelRequested)
                {
                    return;
                }
                for (int x = rect.Left; x < rect.Right; x++)
                {
                    int offsetX = (int)(x + selection.Width * Amount5.First / 2);
                    int offsetY = (int)(y + selection.Height * Amount5.Second / 2);

                    puzzlePixel = GetBilinearSampleMirrored(puzzleSurface, offsetX - selection.Left, offsetY - selection.Top);

                    sourcePixel = src[x, y];

                    if (Amount3)
                    {
                        sourcePixel.A = Int32Util.ClampToByte(255 - puzzlePixel.A);
                        finalPixel    = sourcePixel;
                    }
                    else
                    {
                        finalPixel = normalOp.Apply(sourcePixel, puzzlePixel);
                    }

                    dst[x, y] = finalPixel;
                }
            }
        }
예제 #7
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);
        }
        protected override void OnLayout(LayoutEventArgs levent)
        {
            int  num        = UIUtil.ScaleHeight(5);
            int  num2       = UIUtil.ScaleWidth(4);
            Size clientSize = base.ClientSize;

            this.header.SetBounds(0, 0, clientSize.Width, this.header.GetPreferredSize(new Size(clientSize.Width, 0)).Height);
            int width = UIUtil.ScaleWidth(70);
            int y     = (this.header.Bottom + num) - 1;
            int num5  = UIUtil.ScaleWidth(20);

            this.resetButtonX.SuspendLayout();
            this.resetButtonX.SetBounds(clientSize.Width - this.resetButtonX.Width, y, num5, -1, BoundsSpecified.Width | BoundsSpecified.Location);
            this.numericUpDownX.SetBounds((this.resetButtonX.Visible ? (this.resetButtonX.Left - num2) : clientSize.Width) - this.numericUpDownX.Width, y, width, -1, BoundsSpecified.Width | BoundsSpecified.Location);
            this.resetButtonX.Height = this.numericUpDownX.Height;
            this.resetButtonX.ResumeLayout();
            this.sliderX.SetBounds(0, y - (num / 2), this.numericUpDownX.Left - num2, this.numericUpDownX.Height + num);
            int num6 = num + Int32Util.Max(this.resetButtonX.Bottom, this.numericUpDownX.Bottom, this.sliderX.Bottom);

            this.resetButtonY.SetBounds(clientSize.Width - this.resetButtonY.Width, num6, num5, -1, BoundsSpecified.Width | BoundsSpecified.Location);
            this.numericUpDownY.SetBounds((this.resetButtonY.Visible ? (this.resetButtonY.Left - num2) : clientSize.Width) - this.numericUpDownY.Width, num6, width, -1, BoundsSpecified.Width | BoundsSpecified.Location);
            this.resetButtonY.Height = this.numericUpDownY.Height;
            this.resetButtonY.ResumeLayout();
            this.sliderY.SetBounds(0, num6 - (num / 2), this.numericUpDownY.Left - num2, this.numericUpDownY.Height + num);
            this.descriptionText.SetBounds(0, (string.IsNullOrEmpty(base.Description) ? 0 : num) + Int32Util.Max(this.resetButtonY.Bottom, this.sliderY.Bottom, this.numericUpDownY.Bottom), clientSize.Width, string.IsNullOrEmpty(this.descriptionText.Text) ? 0 : this.descriptionText.GetPreferredSize(new Size(clientSize.Width, 1)).Height);
            base.ClientSize = new Size(clientSize.Width, this.descriptionText.Bottom);
            base.OnLayout(levent);
        }
예제 #9
0
 public void AddRowRef(int row)
 {
     if (Int32Util.IsClamped(row, 0, this.height - 1))
     {
         this.rowRefCounts[row]++;
     }
 }
        public static Color ToGdipColor(this ColorRgba128Float color, MidpointRounding roundingMode = 1)
        {
            byte red   = Int32Util.ClampToByte((int)Math.Round((double)(color.r * 255.0), roundingMode));
            byte green = Int32Util.ClampToByte((int)Math.Round((double)(color.g * 255.0), roundingMode));
            byte blue  = Int32Util.ClampToByte((int)Math.Round((double)(color.b * 255.0), roundingMode));

            return(Color.FromArgb(Int32Util.ClampToByte((int)Math.Round((double)(color.a * 255.0), roundingMode)), red, green, blue));
        }
예제 #11
0
        private void EnsureItemIsFullyVisible(ItemType itemType, int itemIndex)
        {
            PointInt32 location = this.StackIndexToViewPoint(itemType, itemIndex);
            RectInt32  num2     = new RectInt32(location, new SizeInt32(this.ViewWidth, this.itemHeight));
            int        num3     = num2.Bottom - base.ClientSize.Height;
            int        top      = num2.Top;

            this.ScrollOffset = Int32Util.ClampSafe(this.ScrollOffset, num3, top);
        }
예제 #12
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;
        }
예제 #13
0
 public void ReleaseRowRef(int row)
 {
     if (Int32Util.IsClamped(row, 0, this.height - 1))
     {
         this.rowRefCounts[row]--;
         if ((this.rowRefCounts[row] == 0) && this.IsRowCached(row))
         {
             this.FreeRow(row);
         }
     }
 }
        private static ColorMap ComputeColorMap(double redGain, double greenGain, double blueGain)
        {
            var redMap   = new byte[256];
            var greenMap = new byte[256];
            var blueMap  = new byte[256];

            for (var i = 0; i < 256; i++)
            {
                redMap[i]   = Int32Util.ClampToByte((int)Math.Round(i * redGain));
                greenMap[i] = Int32Util.ClampToByte((int)Math.Round(i * greenGain));
                blueMap[i]  = Int32Util.ClampToByte((int)Math.Round(i * blueGain));
            }

            return(new ColorMap(redMap, greenMap, blueMap));
        }
예제 #15
0
        private void Render(Surface dst, Surface src, Rectangle rect)
        {
            ColorBgra CurrentPixel = this.backColor;

            for (int y = rect.Top; y < rect.Bottom; y++)
            {
                if (IsCancelRequested)
                {
                    return;
                }
                for (int x = rect.Left; x < rect.Right; x++)
                {
                    CurrentPixel.A = Int32Util.ClampToByte(byte.MaxValue - this.textSurface[x, y].A);
                    dst[x, y]      = CurrentPixel;
                }
            }
        }
예제 #16
0
        private void Render(Surface dst, Surface src, Rectangle rect)
        {
            ColorBgra currentPixel;

            for (int y = rect.Top; y < rect.Bottom; y++)
            {
                if (IsCancelRequested)
                {
                    return;
                }
                for (int x = rect.Left; x < rect.Right; x++)
                {
                    currentPixel   = (customColor) ? color : src[x, y];
                    currentPixel.A = Int32Util.ClampToByte(cloudSurface[x, y].A + src[x, y].A - byte.MaxValue);

                    dst[x, y] = currentPixel;
                }
            }
        }
예제 #17
0
        protected override unsafe void OnRenderContent(ISurface <ColorBgra> dstContent, PointInt32 renderOffset)
        {
            SizeInt32 num       = dstContent.Size <ColorBgra>();
            ColorBgra fillColor = base.Changes.FillColor;

            this.sampleSource.Render(dstContent, renderOffset);
            for (int i = 0; i < num.Height; i++)
            {
                ColorBgra *rowPointer = (ColorBgra *)dstContent.GetRowPointer <ColorBgra>(i);
                for (int j = 0; j < num.Width; j++)
                {
                    ColorBgra bgra2 = rowPointer[j];
                    byte      b     = Int32Util.ClampToByte(bgra2.B + (fillColor.B - this.basisColor.B));
                    byte      g     = Int32Util.ClampToByte(bgra2.G + (fillColor.G - this.basisColor.G));
                    byte      r     = Int32Util.ClampToByte(bgra2.R + (fillColor.R - this.basisColor.R));
                    byte      a     = Int32Util.ClampToByte(bgra2.A + (fillColor.A - this.basisColor.A));
                    rowPointer[j] = ColorBgra.FromBgra(b, g, r, a);
                }
            }
        }
예제 #18
0
 protected override void OnLayout(LayoutEventArgs levent)
 {
     if (base.Parent != null)
     {
         base.Parent.SuspendLayout();
         if (levent.AffectedProperty == "Font")
         {
             this.cachedMaxWidthOfComboBoxItems = null;
         }
         Size clientSize = base.ClientSize;
         int  num        = UIUtil.ScaleHeight(4);
         this.header.SetBounds(0, 0, clientSize.Width, this.header.GetPreferredSize(new Size(clientSize.Width, 0)).Height);
         this.comboBox.Location = new Point(0, this.header.Bottom + num);
         int num3 = Int32Util.ClampSafe(Math.Max(this.GetMaxWidthOfComboBoxItems(), 1) + UIUtil.ScaleWidth(30), 1, clientSize.Width);
         this.comboBox.Width = num3;
         this.comboBox.PerformLayout();
         this.descriptionText.Location = new Point(0, this.comboBox.Bottom + (string.IsNullOrEmpty(this.descriptionText.Text) ? 0 : num));
         this.descriptionText.Width    = clientSize.Width;
         this.descriptionText.Height   = string.IsNullOrEmpty(this.descriptionText.Text) ? 0 : this.descriptionText.GetPreferredSize(new Size(clientSize.Width, 1)).Height;
         base.ClientSize = new Size(clientSize.Width, this.descriptionText.Bottom);
         base.OnLayout(levent);
         base.Parent.ResumeLayout(false);
     }
 }
예제 #19
0
        public void AddToPenSize(int delta)
        {
            int newWidth = Int32Util.Clamp(BrushSize + delta, minPenSize, maxPenSize);

            BrushSize = newWidth;
        }
예제 #20
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);
        }
예제 #21
0
 private void OnScrollOffsetChanged()
 {
     this.vScrollBar.Value = Int32Util.Clamp(this.scrollOffset, this.vScrollBar.Minimum, this.vScrollBar.Maximum);
     this.ScrollOffsetChanged.Raise(this);
 }
예제 #22
0
        private void DrawToDrawingContext(IDrawingContext dc)
        {
            RectInt32 rect = base.ClientRectangle.ToRectInt32();

            dc.Clear(new ColorRgba128Float?(this.BackColor));
            using (dc.UseTranslateTransform(0.5f, 0.5f, MatrixMultiplyOrder.Append))
            {
                using (dc.UseAntialiasMode(AntialiasMode.PerPrimitive))
                {
                    RectInt32  num2      = RectInt32.Inflate(rect, -2, -2);
                    int        num3      = Math.Min(num2.Width, num2.Height);
                    PointInt32 center    = new PointInt32(num2.X + (num3 / 2), num2.Y + (num3 / 2));
                    double     radius    = ((double)num3) / 2.0;
                    double     scale     = ((double)num3) / 3.0;
                    double     num7      = ((double)num3) / 2.0;
                    double     d         = -MathUtil.DegreesToRadians(this.angle);
                    double     num9      = Math.Cos(d);
                    double     num10     = Math.Sin(d);
                    double     rx        = (this.rollAmount * Math.Cos(MathUtil.DegreesToRadians(this.rollDirection))) / 90.0;
                    double     num12     = (this.rollAmount * Math.Sin(MathUtil.DegreesToRadians(this.rollDirection))) / 90.0;
                    double     num13     = rx / (((num12 * num12) < 0.99) ? Math.Sqrt(1.0 - (num12 * num12)) : 1.0);
                    double     num14     = num12 / (((rx * rx) < 0.99) ? Math.Sqrt(1.0 - (rx * rx)) : 1.0);
                    double     thickness = (this.mouseEntered && !this.onSphere) ? 2.0 : 1.0;
                    if (this.ringOuterEllipseGeometry == null)
                    {
                        this.ringOuterEllipseGeometry = new EllipseGeometry();
                    }
                    if (this.ringInnerEllipseGeometry == null)
                    {
                        this.ringInnerEllipseGeometry = new EllipseGeometry();
                    }
                    if (this.ringFillGeometry == null)
                    {
                        this.ringFillGeometry = new CombinedGeometry(GeometryCombineMode.Exclude, this.ringOuterEllipseGeometry, this.ringInnerEllipseGeometry);
                    }
                    this.ringOuterEllipseGeometry.Center  = center;
                    this.ringOuterEllipseGeometry.RadiusX = radius - 0.5;
                    this.ringOuterEllipseGeometry.RadiusY = radius - 0.5;
                    this.ringInnerEllipseGeometry.Center  = center;
                    this.ringInnerEllipseGeometry.RadiusX = radius;
                    this.ringInnerEllipseGeometry.RadiusY = radius;
                    dc.FillGeometry(this.ringFillGeometry, ringFillBrush, null);
                    if (this.ringOutlinePen == null)
                    {
                        this.ringOutlinePen = new PaintDotNet.UI.Media.Pen();
                    }
                    this.ringOutlinePen.Brush     = ringOutlineBrush;
                    this.ringOutlinePen.Thickness = thickness;
                    dc.DrawCircle(center, radius, this.ringOutlinePen);
                    double num16 = (this.mouseEntered && !this.onSphere) ? ((double)2) : ((double)1);
                    dc.DrawLine(center.X + (scale * num9), center.Y + (scale * num10), center.X + (num7 * num9), center.Y + (num7 * num10), thetaLineBrush, num16);
                    using (dc.UseTranslateTransform((float)center.X, (float)center.Y, MatrixMultiplyOrder.Prepend))
                    {
                        double num17 = (this.angle * 3.1415926535897931) / 180.0;
                        float  num18 = (this.mouseEntered && this.onSphere) ? 1.5f : 1f;
                        int    num19 = 0x18;
                        for (int i = 0; i >= (-num19 / 2); i--)
                        {
                            double num22 = (i * 3.1415926535897931) / ((double)num19);
                            double num23 = -num17 - 3.1415926535897931;
                            double xs    = Math.Cos(num23) * Math.Cos(num22);
                            double ys    = Math.Sin(num23) * Math.Cos(num22);
                            double zs    = Math.Sin(num22);
                            double num30 = ((double)(i + (num19 / 2))) / ((double)(num19 / 2));
                            byte   index = Int32Util.ClampToByte((int)(num30 * 255.0));
                            if (this.latBrushCache[index] == null)
                            {
                                ColorBgra bgra = ColorBgra.Blend(latGradStart, latGradEnd, index);
                                this.latBrushCache[index] = SolidColorBrushCache.Get((ColorRgba128Float)bgra);
                            }
                            SolidColorBrush brush = this.latBrushCache[index];
                            for (int k = -num19 * 6; k <= (num19 * 6); k++)
                            {
                                num23 = -num17 + ((k * 3.1415926535897931) / ((double)(num19 * 6)));
                                double num33 = Math.Cos(num22);
                                double num34 = Math.Sin(num22);
                                double xe    = Math.Cos(num23) * Math.Cos(num22);
                                double ye    = Math.Sin(num23) * Math.Cos(num22);
                                double ze    = Math.Sin(num22);
                                double num35 = (this.mouseEntered && this.onSphere) ? 1.5 : 1.0;
                                this.Draw3DLine(dc, rx, -num12, scale, xs, ys, zs, xe, ye, ze, brush, num35);
                                xs = xe;
                                ys = ye;
                                zs = ze;
                            }
                        }
                        int num20 = 4;
                        for (int j = -num20; j < num20; j++)
                        {
                            double num37 = -num17 + ((j * 3.1415926535897931) / ((double)num20));
                            double num38 = -1.5707963267948966;
                            double num39 = Math.Cos(num37) * Math.Cos(num38);
                            double num40 = Math.Sin(num37) * Math.Cos(num38);
                            double num41 = Math.Sin(num38);
                            for (int m = -num20 * 4; m <= 0; m++)
                            {
                                num38 = (m * 3.1415926535897931) / ((double)(num20 * 8));
                                double num42 = Math.Cos(num37) * Math.Cos(num38);
                                double num43 = Math.Sin(num37) * Math.Cos(num38);
                                double num44 = Math.Sin(num38);
                                double num46 = (this.mouseEntered && this.onSphere) ? 2.0 : 1.0;
                                this.Draw3DLine(dc, rx, -num12, scale, num39, num40, num41, num42, num43, num44, lightBrush, num46);
                                num39 = num42;
                                num40 = num43;
                                num41 = num44;
                            }
                        }
                    }
                    dc.DrawCircle(center, scale, ringInlineBrush, thickness);
                }
            }
        }
예제 #23
0
            public static void IntrospectiveSort(TList keys, int startIndex, int length, TComparer comparer)
            {
                int depthLimit = 2 * Int32Util.Log2Floor(keys.Count);

                ListUtil.AlgorithmsWithComparer <T, TList, TComparer> .IntrospectiveSort(keys, startIndex, (startIndex + length) - 1, depthLimit, comparer);
            }
예제 #24
0
 public static byte ConvertToByte(this double d)
 {
     return(Int32Util.ClampToByte((int)Math.Round(d * byte.MaxValue)));
 }
예제 #25
0
        protected override void OnLayout(LayoutEventArgs levent)
        {
            UpdatesState currentState;
            int          bottom;

            this.layoutQueued = false;
            if (!this.setFonts && base.IsHandleCreated)
            {
                this.setFonts = true;
                this.versionNameLabel.Font = new Font(this.Font.FontFamily, this.Font.Size * 1.25f, FontStyle.Regular);
            }
            this.Text = PdnResources.GetString("UpdatesDialog.Text");
            string str = PdnResources.GetString("UpdatesDialog.CloseButton.Text");

            this.moreInfoLink.Text = PdnResources.GetString("UpdatesDialog.MoreInfoLink.Text");
            if ((this.updatesStateMachine == null) || (this.updatesStateMachine.CurrentState == null))
            {
                currentState = null;
            }
            else
            {
                currentState = (UpdatesState)this.updatesStateMachine.CurrentState;
            }
            INewVersionInfo info = currentState as INewVersionInfo;

            if (currentState == null)
            {
                this.infoText.Text            = string.Empty;
                this.continueButton.Text      = string.Empty;
                this.continueButton.Enabled   = false;
                this.continueButton.Visible   = false;
                this.moreInfoLink.Visible     = false;
                this.moreInfoLink.Enabled     = false;
                this.versionNameLabel.Visible = false;
                this.versionNameLabel.Enabled = false;
                goto Label_0265;
            }
            if (currentState is ReadyToInstallState)
            {
                ((ReadyToInstallState)currentState).InstallingOnExit = this.InstallingOnExit;
            }
            if ((currentState is ReadyToInstallState) || (currentState is UpdateAvailableState))
            {
                using (Icon icon = UIUtil.GetStockIcon(UIUtil.StockIcon.Shield, UIUtil.StockIconFlags.SmallIcon))
                {
                    this.continueButton.Image = icon.ToBitmap();
                    goto Label_017B;
                }
            }
            this.continueButton.Image = null;
Label_017B:
            this.infoText.Text          = currentState.InfoText;
            this.continueButton.Text    = currentState.ContinueButtonText;
            this.continueButton.Visible = currentState.ContinueButtonVisible;
            this.continueButton.Enabled = currentState.ContinueButtonVisible;
            this.progressBar.Style      = (currentState.MarqueeStyle == MarqueeStyle.Marquee) ? ProgressBarStyle.Marquee : ProgressBarStyle.Continuous;
            this.progressBar.Visible    = currentState.MarqueeStyle > MarqueeStyle.None;
            this.progressLabel.Visible  = this.progressBar.Visible;
            if ((this.continueButton.Enabled || (currentState is ErrorState)) || (currentState is DoneState))
            {
                str = PdnResources.GetString("UpdatesDialog.CloseButton.Text");
            }
            else
            {
                str = PdnResources.GetString("Form.CancelButton.Text");
            }
            if (info != null)
            {
                this.versionNameLabel.Text = info.NewVersionInfo.FriendlyName;
                this.moreInfoTarget        = new Uri(info.NewVersionInfo.InfoUrl);
            }
Label_0265:
            this.closeButton.Text = str;
            int  num   = UIUtil.ScaleWidth(8);
            int  num2  = UIUtil.ScaleHeight(8);
            int  x     = UIUtil.ScaleWidth(8);
            int  y     = UIUtil.ScaleHeight(8);
            int  num5  = UIUtil.ScaleWidth(8);
            int  num6  = Math.Max(0, num2);
            int  width = (base.ClientSize.Width - x) - num5;
            Size size  = UIUtil.ScaleSize(0x55, 0x18);
            int  num9  = base.IsGlassEffectivelyEnabled ? -1 : x;

            this.infoText.Location = new Point(x, y);
            this.infoText.Width    = width;
            this.infoText.Size     = this.infoText.GetPreferredSize(this.infoText.Width, 1);
            if (((currentState is UpdateAvailableState) || (currentState is DownloadingState)) || ((currentState is ReadyToInstallState) || (info != null)))
            {
                this.versionNameLabel.Size    = this.versionNameLabel.GetPreferredSize(width, 1);
                this.versionNameLabel.Enabled = true;
                this.versionNameLabel.Visible = true;
                this.moreInfoLink.Size        = this.moreInfoLink.GetPreferredSize(width, 1);
                this.moreInfoLink.Enabled     = true;
                this.moreInfoLink.Visible     = true;
            }
            else
            {
                this.versionNameLabel.Size    = new Size(width, 0);
                this.versionNameLabel.Enabled = false;
                this.versionNameLabel.Visible = false;
                this.moreInfoLink.Size        = new Size(width, 0);
                this.moreInfoLink.Enabled     = false;
                this.moreInfoLink.Visible     = false;
            }
            this.versionNameLabel.Location = new Point(this.infoText.Left, this.infoText.Bottom + num2);
            if ((width - this.versionNameLabel.Width) < (num + this.moreInfoLink.Width))
            {
                this.moreInfoLink.Location = new Point(this.versionNameLabel.Left, this.versionNameLabel.Bottom + (num2 / 2));
            }
            else
            {
                this.moreInfoLink.Location = new Point(this.versionNameLabel.Right + num, (this.versionNameLabel.Bottom - this.moreInfoLink.Height) - 1);
            }
            int num10 = this.versionNameLabel.Visible ? (this.moreInfoLink.Bottom + ((num2 * 3) / 2)) : (this.infoText.Bottom + num2);

            if (((currentState is CheckingState) || (currentState is DownloadingState)) || (currentState is ExtractingState))
            {
                if (currentState is CheckingState)
                {
                    this.progressLabel.Enabled = false;
                    this.progressLabel.Visible = false;
                }
                else
                {
                    this.progressLabel.Enabled = true;
                    this.progressLabel.Visible = true;
                }
                this.progressBar.Enabled = true;
                this.progressBar.Visible = true;
            }
            else
            {
                this.progressLabel.Enabled = false;
                this.progressLabel.Visible = false;
                this.progressBar.Enabled   = false;
                this.progressBar.Visible   = false;
            }
            this.progressLabel.Size = this.progressLabel.GetPreferredSize(width, 1);
            if (!this.progressLabel.Visible)
            {
                this.progressLabel.Width = 0;
            }
            this.progressLabel.Location = new Point((base.ClientSize.Width - num5) - this.progressLabel.Width, num10);
            this.progressBar.Location   = new Point(x, this.progressLabel.Top + ((this.progressLabel.Height - this.progressBar.Height) / 2));
            this.progressBar.Height     = UIUtil.ScaleHeight(0x12);
            this.progressBar.Width      = this.progressLabel.Visible ? ((this.progressLabel.Left - x) - num) : width;
            int[] vals  = new int[] { this.versionNameLabel.Visible ? (this.versionNameLabel.Bottom + (num2 / 2)) : 0, this.moreInfoLink.Visible ? this.moreInfoLink.Bottom : 0, this.progressLabel.Visible ? this.progressLabel.Bottom : 0, this.progressBar.Visible ? this.progressBar.Bottom : 0 };
            int   num11 = num2 + Int32Util.Max(this.infoText.Bottom, vals);

            this.separator.Location = new Point(x, num11);
            this.separator.Size     = this.separator.GetPreferredSize(width, 1);
            if ((currentState is ReadyToInstallState) || (currentState is UpdateAvailableState))
            {
                this.closeButton.Enabled    = false;
                this.closeButton.Visible    = false;
                this.continueButton.Enabled = true;
                this.continueButton.Visible = true;
                this.continueButton.Size    = size;
                this.continueButton.PerformLayout();
                this.continueButton.Location = new Point((base.ClientSize.Width - num9) - this.continueButton.Width, this.separator.Bottom + num2);
                bottom = this.continueButton.Bottom;
            }
            else
            {
                this.closeButton.Enabled = true;
                this.closeButton.Visible = true;
                this.closeButton.Size    = size;
                this.closeButton.PerformLayout();
                this.closeButton.Location   = new Point((base.ClientSize.Width - num9) - this.closeButton.Width, this.separator.Bottom + num2);
                this.continueButton.Enabled = false;
                this.continueButton.Visible = false;
                bottom = this.closeButton.Bottom;
            }
            base.ClientSize = new Size(base.ClientSize.Width, bottom + num6);
            if (base.IsGlassEffectivelyEnabled)
            {
                this.separator.Visible = false;
                base.GlassInset        = new Padding(0, 0, 0, base.ClientSize.Height - this.separator.Top);
            }
            else
            {
                this.separator.Visible = true;
                base.GlassInset        = new Padding(0);
            }
            base.OnLayout(levent);
        }
예제 #26
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;
                                }
                            }
                        }
                    }
                }
            }
예제 #27
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);
        }