예제 #1
0
        protected override void OnRender(IDrawingContext dc, RectFloat clipRect, CanvasView canvasView)
        {
            RectDouble cursorBounds      = this.CursorBounds;
            RectDouble cursorOutlineRect = this.GetCursorOutlineRect(canvasView, cursorBounds);
            double     opacity           = this.opacityAnimation.Value;

            dc.FillRectangle(cursorBounds, SolidColorBrushCache.Get((ColorRgba128Float)Colors.Black, opacity));
            double canvasHairWidth = canvasView.CanvasHairWidth;
            double thickness       = 1.0 * canvasHairWidth;

            dc.DrawRectangle(cursorOutlineRect, SolidColorBrushCache.Get((ColorRgba128Float)Colors.White, opacity), thickness);
            base.OnRender(dc, clipRect, canvasView);
        }
예제 #2
0
 protected override void OnRender(IDrawingContext dc, RectFloat clipRect, CanvasView canvasView)
 {
     if ((this.brushSize > 0.0) && (this.brushAlpha > 0))
     {
         double     opacity         = ((double)this.brushAlpha) / 255.0;
         Brush      brush           = SolidColorBrushCache.Get((ColorRgba128Float)ColorBgra.White, opacity);
         Brush      brush2          = SolidColorBrushCache.Get((ColorRgba128Float)ColorBgra.Black, opacity);
         double     canvasHairWidth = canvasView.CanvasHairWidth;
         RectDouble brushRect       = this.BrushRect;
         brushRect.Inflate((double)(-canvasHairWidth * 2.0), (double)(-canvasHairWidth * 2.0));
         if (brushRect.HasPositiveArea)
         {
             this.ellipseGeometryInner.RadiusX  = this.brushSize - (canvasHairWidth * 2.0);
             this.ellipseGeometryInner.RadiusY  = this.brushSize - (canvasHairWidth * 2.0);
             this.ellipseGeometryMiddle.RadiusX = this.brushSize - canvasHairWidth;
             this.ellipseGeometryMiddle.RadiusY = this.brushSize - canvasHairWidth;
             this.ellipseGeometryOuter.RadiusX  = this.brushSize;
             this.ellipseGeometryOuter.RadiusY  = this.brushSize;
             using (dc.UseTranslateTransform(-((VectorFloat)this.brushLocation), MatrixMultiplyOrder.Prepend))
             {
                 using (CastOrRefHolder <IDrawingContext2> holder = dc.TryCastOrCreateRef <IDrawingContext2>())
                 {
                     if (holder.HasRef)
                     {
                         this.ellipseRealizationInner            = this.ellipseRealizationInner ?? new StrokedGeometryRealization(this.ellipseGeometryInner);
                         this.ellipseRealizationMiddle           = this.ellipseRealizationMiddle ?? new StrokedGeometryRealization(this.ellipseGeometryMiddle);
                         this.ellipseRealizationOuter            = this.ellipseRealizationOuter ?? new StrokedGeometryRealization(this.ellipseGeometryOuter);
                         this.ellipseRealizationInner.Thickness  = canvasHairWidth;
                         this.ellipseRealizationMiddle.Thickness = canvasHairWidth;
                         this.ellipseRealizationOuter.Thickness  = canvasHairWidth;
                         holder.ObjectRef.DrawGeometryRealization(this.ellipseRealizationInner, brush);
                         holder.ObjectRef.DrawGeometryRealization(this.ellipseRealizationMiddle, brush2);
                         holder.ObjectRef.DrawGeometryRealization(this.ellipseRealizationOuter, brush);
                     }
                     else
                     {
                         dc.DrawGeometry(this.ellipseGeometryInner, brush, canvasHairWidth);
                         dc.DrawGeometry(this.ellipseGeometryMiddle, brush2, canvasHairWidth);
                         dc.DrawGeometry(this.ellipseGeometryOuter, brush, canvasHairWidth);
                     }
                 }
             }
         }
     }
     base.OnRender(dc, clipRect, canvasView);
 }
예제 #3
0
 protected override void OnRender(IDrawingContext dc, RectFloat clipRect)
 {
     using (dc.UseAntialiasMode(AntialiasMode.Aliased))
     {
         SizeInt32 num;
         Size      clientSize = base.ClientSize;
         if ((clientSize.Width < 2) || (clientSize.Height < 2))
         {
             num = new SizeInt32(3, 3);
         }
         else
         {
             num = new SizeInt32(clientSize.Width, clientSize.Height);
         }
         dc.Clear(new ColorRgba128Float?((ColorRgba128Float)PaintDotNet.Imaging.SystemColors.Window));
         int    num2 = (int)(this.tolerance * 100f);
         string text = string.Format(percentageFormat, num2);
         if (this.textLayout == null)
         {
             this.textLayout = UIText.CreateLayout(dc, text, this.Font, null, HotkeyRenderMode.Ignore, 65535.0, 65535.0);
             this.textLayout.ParagraphAlignment = ParagraphAlignment.Center;
             this.textLayout.FontSize          *= 0.9;
         }
         else
         {
             this.textLayout.Text = text;
         }
         this.textLayout.MaxWidth  = num.Width - 6;
         this.textLayout.MaxHeight = num.Height - 6;
         PointDouble origin = new PointDouble(3.0, 3.0);
         dc.DrawTextLayout(origin, this.textLayout, SolidColorBrushCache.Get(base.Enabled ? ((ColorRgba128Float)PaintDotNet.Imaging.SystemColors.WindowText) : ((ColorRgba128Float)PaintDotNet.Imaging.SystemColors.GrayText)), DrawTextOptions.None);
         RectDouble rect = new RectDouble(0.0, 0.0, (double)num.Width, (double)num.Height);
         RectDouble num5 = RectDouble.Inflate(rect, -0.5, -0.5);
         dc.DrawRectangle(num5, SolidColorBrushCache.Get(base.Enabled ? ((ColorRgba128Float)PaintDotNet.Imaging.SystemColors.ControlDark) : ((ColorRgba128Float)PaintDotNet.Imaging.SystemColors.ControlDark)), 1.0);
         RectDouble num6 = new RectDouble(1.0, 1.0, (num.Width - 2.0) * this.tolerance, (double)(num.Height - 2));
         PaintDotNet.UI.Media.Brush brush = SolidColorBrushCache.Get(base.Enabled ? (this.hovering ? ((ColorRgba128Float)PaintDotNet.Imaging.SystemColors.HotTrack) : ((ColorRgba128Float)PaintDotNet.Imaging.SystemColors.Highlight)) : ((ColorRgba128Float)PaintDotNet.Imaging.SystemColors.Control));
         dc.FillRectangle(num6, brush);
         using (dc.UseAxisAlignedClip((RectFloat)num6, AntialiasMode.PerPrimitive))
         {
             dc.DrawTextLayout(origin, this.textLayout, SolidColorBrushCache.Get(base.Enabled ? ((ColorRgba128Float)PaintDotNet.Imaging.SystemColors.HighlightText) : ((ColorRgba128Float)PaintDotNet.Imaging.SystemColors.GrayText)), DrawTextOptions.None);
         }
     }
     base.OnRender(dc, clipRect);
 }
예제 #4
0
        private Brush CreateBrush(double centerX, double centerY, double radiusX, double radiusY)
        {
            if (!base.Antialiased)
            {
                return(SolidColorBrushCache.Get((ColorRgba128Float)Colors.White));
            }
            GradientStopCollection gradientStopCollection = new GradientStopCollection(0x20);

            for (int i = 0; i < 0x20; i++)
            {
                double num2;
                switch (i)
                {
                case 0:
                    num2 = 0.0;
                    break;

                case 0x1f:
                    num2 = 1.0;
                    break;

                default:
                    num2 = ((double)i) / 31.0;
                    break;
                }
                double       gradientStopAlpha = this.GetGradientStopAlpha(num2);
                GradientStop item = new GradientStop(new ColorRgba128Float((ColorRgba128Float)Colors.White, (float)gradientStopAlpha), num2);
                gradientStopCollection.Add(item);
            }
            gradientStopCollection.Freeze();
            RadialGradientBrush brush = new RadialGradientBrush(gradientStopCollection)
            {
                ColorInterpolationMode = ColorInterpolationMode.ScRgbLinearInterpolation,
                GradientOrigin         = PointDouble.Zero,
                RadiusX = radiusX,
                RadiusY = radiusY,
                Center  = new PointDouble(centerX, centerY)
            };

            brush.Freeze();
            return(brush);
        }
예제 #5
0
 protected override void OnRender(IDrawingContext dc, RectFloat clipRect, CanvasView canvasView)
 {
     if ((this.brushSize > 0.0) && (this.brushAlpha > 0))
     {
         double     opacity         = ((double)this.brushAlpha) / 255.0;
         Brush      brush           = SolidColorBrushCache.Get((ColorRgba128Float)ColorBgra.White, opacity);
         Brush      brush2          = SolidColorBrushCache.Get((ColorRgba128Float)ColorBgra.Black, opacity);
         double     canvasHairWidth = canvasView.CanvasHairWidth;
         RectDouble brushRect       = this.BrushRect;
         brushRect.Inflate(-canvasHairWidth, -canvasHairWidth);
         if (brushRect.HasPositiveArea)
         {
             RectFloat num4 = (RectFloat)brushRect;
             using (dc.UseAntialiasMode(AntialiasMode.Aliased))
             {
                 dc.DrawRectangle(brushRect, brush2, canvasHairWidth * 3.0);
                 dc.DrawRectangle(brushRect, brush, canvasHairWidth);
             }
         }
     }
     base.OnRender(dc, clipRect, canvasView);
 }
예제 #6
0
        private void Initialize()
        {
            if ((this.allShapePropertyValuesMap == null) && (this.allShapePropertyValuesArray != null))
            {
                this.allShapePropertyValuesMap = ShapePropertyValuesUtil.ToReadOnlyMap(this.allShapePropertyValuesArray);
            }
            PaintDotNet.UI.Media.DashStyle style = DashStyleUtil.ToMedia(this.PenDashStyle);
            this.outlinePen = new Pen {
                Brush     = SolidColorBrushCache.Get((ColorRgba128Float)Colors.White),
                Thickness = this.PenWidth,
                LineJoin  = PenLineJoin.Miter,
                DashStyle = style
            }.EnsureFrozen <Pen>();
            RectDouble   baseBounds = this.BaseBounds;
            VectorDouble txScale    = this.Transform.GetScale();
            VectorDouble num3       = (VectorDouble)(this.EndPoint - this.StartPoint);
            PointDouble  endPoint   = new PointDouble(this.StartPoint.X + (num3.X * txScale.X), this.StartPoint.Y + (num3.Y * txScale.Y));
            Dictionary <string, object> settingValues = (from gsp in this.Shape.RenderSettingPaths select KeyValuePairUtil.Create <string, object>(gsp, base.GetDrawingSettingValue(gsp))).ToDictionary <string, object>();

            PaintDotNet.Shapes.ShapeRenderParameters renderParams = new PaintDotNet.Shapes.ShapeRenderParameters(this.StartPoint, endPoint, txScale, settingValues, null);
            this.shapePropertySchema = this.Shape.CreatePropertyCollection(renderParams);
            foreach (Property property in this.shapePropertySchema)
            {
                property.ValueChanged += delegate(object s, ValueEventArgs <object> e) {
                    throw new ReadOnlyException();
                };
                property.ReadOnlyChanged += delegate(object s, ValueEventArgs <bool> e) {
                    throw new ReadOnlyException();
                };
            }
            this.shapeRenderParams = new PaintDotNet.Shapes.ShapeRenderParameters(this.StartPoint, endPoint, txScale, settingValues, this.ShapePropertyValues);
            this.shapeRenderData   = LazyResult.New <PaintDotNet.Shapes.ShapeRenderData>(delegate {
                PaintDotNet.Shapes.ShapeRenderData renderData = this.Shape.CreateRenderData(this.shapeRenderParams);
                Matrix3x2Double matrix = Matrix3x2Double.ScalingAt(1.0 / Math.Abs(txScale.X), 1.0 / Math.Abs(txScale.Y), this.StartPoint.X, this.StartPoint.Y);
                return(PaintDotNet.Shapes.ShapeRenderData.Transform(PaintDotNet.Shapes.ShapeRenderData.Transform(renderData, matrix), this.transform));
            }, LazyThreadSafetyMode.ExecutionAndPublication, new SingleUseCriticalSection());
        }
예제 #7
0
        private ImageResource CreateImageResource(int width, int height, double borderSize)
        {
            ImageResource resource2;
            double        x = borderSize / 2.0;

            using (ISurface <ColorBgra> surface = SurfaceAllocator.Bgra.Allocate(width, height, AllocationOptions.ZeroFillNotRequired))
            {
                using (IDrawingContext context = DrawingContext.FromSurface(surface, AlphaMode.Premultiplied, FactorySource.PerThread))
                {
                    RectDouble num4;
                    context.Clear(null);
                    RectDouble num2        = new RectDouble(x, x, width - borderSize, height - borderSize);
                    double     aspectRatio = this.AspectRatio;
                    if (aspectRatio > 1.0)
                    {
                        double num5 = num2.Height / aspectRatio;
                        num4 = new RectDouble(num2.X, num2.Y + ((num2.Height - num5) / 2.0), num2.Width, num5);
                    }
                    else if (aspectRatio < 1.0)
                    {
                        double num6 = num2.Width * aspectRatio;
                        num4 = new RectDouble(num2.X + ((num2.Width - num6) / 2.0), num2.Y, num6, num2.Height);
                    }
                    else
                    {
                        num4 = num2;
                    }
                    IDictionary <string, object> settingValues = (from p in this.RenderSettingPaths select KeyValuePairUtil.Create <string, object>(p, AppSettings.Instance[ConvertToolsPathToToolDefaultsPath(p)].Value)).ToDictionary <string, object>();
                    ShapeRenderParameters        renderParams  = new ShapeRenderParameters(num4.TopLeft, num4.BottomRight, new VectorDouble(1.0, 1.0), settingValues, null);
                    PropertyCollection           properties    = this.CreatePropertyCollection(renderParams);
                    this.OnSetImagePropertyCollectionValues(renderParams, properties);
                    IDictionary <object, object> propertyValues = (from p in properties select KeyValuePairUtil.Create <object, object>(p.GetOriginalNameValue(), p.Value)).ToDictionary <object, object>();
                    ShapeRenderParameters        parameters2    = new ShapeRenderParameters(num4.TopLeft, num4.BottomRight, new VectorDouble(1.0, 1.0), settingValues, propertyValues);
                    ShapeRenderData            data             = this.CreateImageRenderData(parameters2);
                    PaintDotNet.UI.Media.Brush brush            = SolidColorBrushCache.Get((ColorRgba128Float)ColorBgra.FromUInt32(0xff5894c1));
                    if (data.InteriorFill != null)
                    {
                        context.FillGeometry(data.InteriorFill.Geometry, SolidColorBrushCache.Get((ColorRgba128Float)Colors.White), null);
                        LinearGradientBrush brush2 = new LinearGradientBrush {
                            StartPoint = num4.TopLeft,
                            EndPoint   = num4.BottomRight
                        };
                        brush2.GradientStops.Add(new GradientStop((ColorRgba128Float)ColorBgra32.FromUInt32(0xffc0e1f3), 0.0));
                        brush2.GradientStops.Add(new GradientStop((ColorRgba128Float)ColorBgra32.FromUInt32(0xffe0eff8), 1.0));
                        context.FillGeometry(data.InteriorFill.Geometry, brush2, null);
                    }
                    if ((data.InteriorFill != null) && (data.OutlineDraw != null))
                    {
                        RenderLayer layer = RenderLayerCache.Get();
                        using (context.UseLayer(layer, null, data.InteriorFill.Geometry, AntialiasMode.PerPrimitive, null, 1.0, null, LayerOptions.None))
                        {
                            context.DrawGeometry(data.OutlineDraw.Geometry, SolidColorBrushCache.Get((ColorRgba128Float)Colors.White), 3.0);
                        }
                        RenderLayerCache.Return(layer);
                    }
                    if (data.OutlineDraw != null)
                    {
                        context.DrawGeometry(data.OutlineDraw.Geometry, brush, 1.0);
                    }
                    if (data.OutlineFill != null)
                    {
                        context.FillGeometry(data.OutlineFill.Geometry, brush, null);
                    }
                    string imageStringOverlay = this.ImageStringOverlay;
                    if (imageStringOverlay != string.Empty)
                    {
                        double     num7       = (width * 7.0) / 16.0;
                        double     fontSize   = UIUtil.ScaleWidth(num7);
                        TextLayout textLayout = new TextLayout(imageStringOverlay, "Arial", FontWeight.Normal, PaintDotNet.DirectWrite.FontStyle.Normal, FontStretch.Normal, fontSize)
                        {
                            ParagraphAlignment = ParagraphAlignment.Center,
                            TextAlignment      = PaintDotNet.DirectWrite.TextAlignment.Center,
                            MaxWidth           = width - 2,
                            MaxHeight          = height - 2
                        };
                        context.DrawTextLayout(new PointDouble(1.0, 1.0), textLayout, SolidColorBrushCache.Get((ColorRgba128Float)ColorBgra.FromUInt32(0xff5894c1)), DrawTextOptions.None);
                    }
                }
                surface.ConvertFromPremultipliedAlpha();
                using (System.Drawing.Bitmap bitmap = surface.CreateAliasedGdipBitmap())
                {
                    System.Drawing.Bitmap image = new System.Drawing.Bitmap(bitmap);
                    resource2 = ImageResource.FromImage(image);
                }
            }
            return(resource2);
        }
예제 #8
0
        private unsafe void RenderTileWorkItem(PointInt32 tileOffset)
        {
            IBitmap <ColorPbgra32> bitmap;
            bool      isCancelled = false;
            bool      flag        = false;
            Exception error       = null;

            isCancelled |= this.IsTileRenderingCancelled(tileOffset);
            if (isCancelled)
            {
                bitmap = null;
            }
            else
            {
                RectInt32 tileSourceRect = this.tileMathHelper.GetTileSourceRect(tileOffset);
                SizeInt32 tileBufferSize = this.GetTileBufferSize(tileOffset);
                bitmap = RetryManager.Eval <IBitmap <ColorPbgra32> >(3, () => BitmapAllocator.Pbgra32.Allocate(tileBufferSize, AllocationOptions.Default), delegate(Exception _) {
                    CleanupManager.RequestCleanup();
                    Thread.Sleep(200);
                    CleanupManager.WaitForPendingCleanup();
                }, delegate(AggregateException ex) {
                    throw new AggregateException($"could not allocate a bitmap of size {tileBufferSize.Width} x {tileBufferSize.Height}", ex).Flatten();
                });
                if (this.source != null)
                {
                    try
                    {
                        isCancelled |= this.IsTileRenderingCancelled(tileOffset);
                        if (!isCancelled)
                        {
                            using (IBitmapLock <ColorPbgra32> @lock = bitmap.Lock <ColorPbgra32>(BitmapLockOptions.ReadWrite))
                            {
                                if (this.mipLevel == 0)
                                {
                                    this.source.CopyPixels(new RectInt32?(tileSourceRect), @lock);
                                    RenderingKernels.ConvertBgra32ToPbgra32((uint *)@lock.Scan0, tileBufferSize.Width, tileBufferSize.Height, @lock.Stride);
                                    flag = true;
                                }
                                else
                                {
                                    BitmapInterpolationMode linear;
                                    if (!this.isHighQuality)
                                    {
                                        linear = BitmapInterpolationMode.Linear;
                                    }
                                    else if (this.mipLevel == 1)
                                    {
                                        linear = BitmapInterpolationMode.Linear;
                                    }
                                    else
                                    {
                                        linear = BitmapInterpolationMode.Fant;
                                    }
                                    IImagingFactory    instance    = ImagingFactory.Instance;
                                    ICancellationToken cancelToken = CancellationTokenUtil.Create((Func <bool>)(() => (isCancelled | this.IsTileRenderingCancelled(tileOffset))));
                                    int copyHeightLog2             = Math.Max(3, 7 - this.mipLevel);
                                    using (ClippedBitmapSource <ColorBgra32> source2 = new ClippedBitmapSource <ColorBgra32>(this.source, tileSourceRect))
                                    {
                                        using (CancellableBitmapSource <ColorBgra32> source3 = new CancellableBitmapSource <ColorBgra32>(source2, r => this.tileMathHelper.EnumerateTilesClippedToSourceRect(r), null, cancelToken))
                                        {
                                            using (IBitmapSource <ColorPbgra32> source4 = CreateBufferedTileScaler(instance, source3, tileBufferSize.Width, tileBufferSize.Height, linear))
                                            {
                                                using (CancellableBitmapSource <ColorPbgra32> source5 = new CancellableBitmapSource <ColorPbgra32>(source4, r => TileRectSplitter(r, ((int)1) << copyHeightLog2), null, cancelToken))
                                                {
                                                    try
                                                    {
                                                        source5.CopyPixels <ColorPbgra32>(@lock);
                                                        flag = true;
                                                    }
                                                    catch (OperationCanceledException exception2)
                                                    {
                                                        error       = exception2;
                                                        isCancelled = true;
                                                    }
                                                    catch (Exception exception3)
                                                    {
                                                        error = exception3;
                                                        throw;
                                                    }
                                                }
                                            }
                                        }
                                    }
                                }
                                isCancelled |= this.IsTileRenderingCancelled(tileOffset);
                                if (isCancelled)
                                {
                                    flag = false;
                                }
                            }
                            if (!flag)
                            {
                                DisposableUtil.Free <IBitmap <ColorPbgra32> >(ref bitmap);
                            }
                        }
                    }
                    catch (OperationCanceledException exception4)
                    {
                        error       = exception4;
                        isCancelled = true;
                    }
                    catch (Exception exception5)
                    {
                        error        = exception5;
                        isCancelled |= this.IsTileRenderingCancelled(tileOffset);
                        if (!isCancelled)
                        {
                            using (IDrawingContext context = DrawingContext.FromBitmap(bitmap, FactorySource.PerThread))
                            {
                                context.Clear(new ColorRgba128Float?((ColorRgba128Float)Colors.White));
                                string text = exception5.ToString();
                                using (ISystemFonts fonts = new SystemFonts(true))
                                {
                                    TextLayout textLayout = UIText.CreateLayout(context, text, fonts.Caption, null, HotkeyRenderMode.Ignore, (double)bitmap.Size.Width, 65535.0);
                                    textLayout.FontSize    *= 0.6;
                                    textLayout.WordWrapping = WordWrapping.Wrap;
                                    context.DrawTextLayout(PointDouble.Zero, textLayout, SolidColorBrushCache.Get((ColorRgba128Float)Colors.Black), DrawTextOptions.None);
                                }
                            }
                            flag = true;
                        }
                    }
                }
            }
            isCancelled |= this.IsTileRenderingCancelled(tileOffset);
            if (isCancelled)
            {
                DisposableUtil.Free <IBitmap <ColorPbgra32> >(ref bitmap);
            }
            RenderedTileInfo info = new RenderedTileInfo(bitmap, !isCancelled && (bitmap > null), error);

            if (!this.tilesRenderedQueue.TryEnqueue(tileOffset, info))
            {
                ExceptionUtil.ThrowInternalErrorException("Could not enqueue to this.tilesRenderedQueue");
            }
            if (Interlocked.Exchange(ref this.isProcessTileRenderedQueueQueued, 1) == 0)
            {
                this.syncContext.Post(this.processTileRenderedQueueCallback);
            }
        }
예제 #9
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);
                }
            }
        }