Пример #1
0
 public RectFloat GetRenderBounds(float strokeWidth, IStrokeStyleSource strokeStyle)
 {
     using (IStrokeStyle style = (strokeStyle == null) ? null : strokeStyle.CreateResource <IStrokeStyle>())
     {
         return(this.GetPerThreadDirect2DGeometry().GetWidenedBounds(strokeWidth, style, null, null));
     }
 }
Пример #2
0
 public void Draw(IDrawingContext dc, IBrush brush, float strokeWidth, IStrokeStyle strokeStyle)
 {
     if ((this.basis != null) && ((this.basisUsage & BasisUsage.DrawWithRelativeTransform) == BasisUsage.DrawWithRelativeTransform))
     {
         using (dc.UseTransformMultiply((Matrix3x2Float)this.basisRelativeTx.Value, MatrixMultiplyOrder.Prepend))
         {
             this.basis.Draw(dc, brush, strokeWidth, strokeStyle);
             return;
         }
     }
     dc.DrawGeometry(this.GetPerThreadDirect2DGeometry(), brush, strokeWidth, strokeStyle);
 }
Пример #3
0
 public void Widen(ISimplifiedGeometrySink geometrySink, float strokeWidth, IStrokeStyle strokeStyle, Matrix3x2Float?worldTransform, float?flatteningTolerance)
 {
     base.innerRefT.Widen(geometrySink, strokeWidth, strokeStyle, worldTransform, flatteningTolerance);
 }
Пример #4
0
 public bool StrokeContainsPoint(PointFloat point, float strokeWidth, IStrokeStyle strokeStyle, Matrix3x2Float?worldTransform, float?flatteningTolerance) =>
 base.innerRefT.StrokeContainsPoint(point, strokeWidth, strokeStyle, worldTransform, flatteningTolerance);
Пример #5
0
 public RectFloat GetWidenedBounds(float strokeWidth, IStrokeStyle strokeStyle, Matrix3x2Float?worldTransform, float?flatteningTolerance) =>
 base.innerRefT.GetWidenedBounds(strokeWidth, strokeStyle, worldTransform, flatteningTolerance);
Пример #6
0
 public void DrawGeometry(IGeometry geometry, IBrush brush, float strokeWidth, IStrokeStyle strokeStyle)
 {
     base.innerRefT.DrawGeometry(geometry, brush, strokeWidth, strokeStyle);
 }
Пример #7
0
 public void DrawEllipse(EllipseFloat ellipse, IBrush brush, float strokeWidth, IStrokeStyle strokeStyle)
 {
     base.innerRefT.DrawEllipse(ellipse, brush, strokeWidth, strokeStyle);
 }
Пример #8
0
 public void DrawRoundedRectangle(RoundedRectFloat roundedRect, IBrush brush, float strokeWidth, IStrokeStyle strokeStyle)
 {
     base.innerRefT.DrawRoundedRectangle(roundedRect, brush, strokeWidth, strokeStyle);
 }
Пример #9
0
 public void DrawLine(PointFloat point0, PointFloat point1, IBrush brush, float strokeWidth, IStrokeStyle strokeStyle)
 {
     base.innerRefT.DrawLine(point0, point1, brush, strokeWidth, strokeStyle);
 }
Пример #10
0
 public IGeometryRealization CreateStrokedGeometryRealization(IGeometry geometry, float strokeWidth, IStrokeStyle strokeStyle, float?flatteningTolerance) =>
 base.innerRefT.CreateStrokedGeometryRealization(geometry, strokeWidth, strokeStyle, flatteningTolerance);
Пример #11
0
        public DrawEllipse() : base()
        {
            StrokeStyleProperties style = new StrokeStyleProperties(dashCap: CapStyle.Triangle, miterLimit: 10.0f, dashStyle: DashStyle.DashDotDot);

            _dashDotDotStyle = Direct2dFactory.CreateStrokeStyle(style);
        }
 public static IStrokeStyle CreateRef(this IStrokeStyle objectRef) =>
 ((IStrokeStyle)objectRef.CreateRef(typeof(IStrokeStyle)));
Пример #13
0
 private void RenderSelection(IDrawingContext dc, float scale, PointFloat offset, SelectionRenderParameters renderParams, Result <IGeometry> lazyGeometry, IBrush interiorBrush, IBrush outlineBrush, IStrokeStyle outlineStrokeStyle, AntialiasMode antialiasMode)
 {
     using (dc.UseScaleTransform(scale, scale, MatrixMultiplyOrder.Prepend))
     {
         using (dc.UseTranslateTransform(offset.X, offset.Y, MatrixMultiplyOrder.Prepend))
         {
             if (renderParams.IsInteriorFilled && (interiorBrush != null))
             {
                 using (dc.UseAntialiasMode(AntialiasMode.Aliased))
                 {
                     dc.FillGeometry(lazyGeometry.Value, interiorBrush, null);
                 }
             }
             if (renderParams.IsOutlineEnabled && (outlineBrush != null))
             {
                 float strokeWidth = this.outlineStrokeWidthPx / scale;
                 using (dc.UseAntialiasMode(antialiasMode))
                 {
                     using (dc.UseTranslateTransform(0.5f, 0.5f, MatrixMultiplyOrder.Append))
                     {
                         dc.DrawGeometry(lazyGeometry.Value, outlineBrush, strokeWidth, outlineStrokeStyle);
                     }
                 }
             }
         }
     }
 }
Пример #14
0
        private void RedrawOnBackgroundThread()
        {
            if (base.CheckAccess())
            {
                ExceptionUtil.ThrowInvalidOperationException();
            }
            if (this.redrawThreadFactory == null)
            {
                this.redrawThreadFactory = new Direct2DFactory(Direct2DFactoryType.MultiThreaded, DebugLevel.None);
            }
            if ((this.redrawThreadGeometryCache == null) || (this.redrawThreadGeometryCache.SelectionSnapshot != this.redrawRenderParams.SelectionSnapshot))
            {
                DisposableUtil.Free <SelectionGeometryCache>(ref this.redrawThreadGeometryCache);
                this.redrawThreadGeometryCache = new SelectionGeometryCache(this.redrawThreadFactory, this.redrawRenderParams.SelectionSnapshot);
            }
            double      scaleRatio           = this.redrawRenderParams.ScaleRatio;
            PointDouble location             = this.redrawRenderParams.ViewportCanvasBounds.Location;
            SizeDouble  viewportSize         = this.redrawRenderParams.ViewportSize;
            SizeInt32   num5                 = SizeDouble.Ceiling(viewportSize);
            RectDouble  b                    = RectDouble.Inflate(CanvasCoordinateConversions.ConvertExtentToViewport(CanvasCoordinateConversions.ConvertCanvasToExtent(this.redrawRenderParams.SelectionSnapshot.GeometryList.Value.Bounds, scaleRatio), scaleRatio, location), (double)this.outlineStrokeWidthPx, (double)this.outlineStrokeWidthPx);
            RectDouble  a                    = new RectDouble(PointDouble.Zero, viewportSize);
            RectDouble  renderViewportBounds = RectDouble.Intersect(a, b);
            RectInt32   viewportRect         = renderViewportBounds.Int32Bound;
            RectDouble  extentRect           = CanvasCoordinateConversions.ConvertViewportToExtent(viewportRect, scaleRatio, location);
            RectDouble  renderCanvasBounds   = CanvasCoordinateConversions.ConvertExtentToCanvas(extentRect, scaleRatio);

            if (!viewportRect.HasPositiveArea)
            {
                base.SyncContext.Post((SendOrPostCallback)(_ => this.EndRedraw(renderViewportBounds, RectFloat.Zero, null, null)));
            }
            else
            {
                IBitmap <ColorAlpha8> interiorMask;
                float                   scale;
                PointFloat              offset;
                Result <IGeometry>      lazyGeometry;
                IBitmap <ColorAlpha8>[] dashedOutlineMasks;
                RectFloat               maskSourceRect;
                SelectionSnapshot       selectionSnapshot         = this.redrawRenderParams.SelectionSnapshot;
                SelectionGeometryCache  redrawThreadGeometryCache = this.redrawThreadGeometryCache;
                bool flag = this.redrawRenderParams.SelectionRenderingQuality == SelectionRenderingQuality.Aliased;
                if (!flag)
                {
                    lazyGeometry = redrawThreadGeometryCache.Geometry;
                }
                else
                {
                    bool flag3 = selectionSnapshot.IsRectilinear.Value;
                    bool flag4 = selectionSnapshot.IsPixelated.Value;
                    if (flag3 & flag4)
                    {
                        lazyGeometry = redrawThreadGeometryCache.Geometry;
                    }
                    else
                    {
                        lazyGeometry = redrawThreadGeometryCache.PixelatedGeometry;
                    }
                }
                bool          flag2         = !flag && this.redrawRenderParams.IsOutlineAntialiased;
                AntialiasMode antialiasMode = ((flag || !flag2) || selectionSnapshot.IsRectilinear.Value) ? AntialiasMode.Aliased : AntialiasMode.PerPrimitive;
                if (this.CanContinueRedrawing(null, null))
                {
                    scale = (float)this.redrawRenderParams.ScaleRatio;
                    float x = -((float)renderCanvasBounds.X);
                    float y = -((float)renderCanvasBounds.Y);
                    offset       = new PointFloat(x, y);
                    interiorMask = BitmapAllocator.Alpha8.Allocate(viewportRect.Size, AllocationOptions.ZeroFillNotRequired);
                    try
                    {
                        RetryManager.RunMemorySensitiveOperation(delegate {
                            using (IDrawingContext context = DrawingContext.FromBitmap(this.redrawThreadFactory, interiorMask))
                            {
                                context.Clear(null);
                                IBrush interiorBrush = context.GetCachedOrCreateResource <IBrush>(whiteBrush);
                                this.RenderSelection(context, scale, offset, this.redrawRenderParams, lazyGeometry, interiorBrush, null, null, antialiasMode);
                            }
                        });
                    }
                    catch (OutOfMemoryException)
                    {
                    }
                    if (this.CanContinueRedrawing(interiorMask, null))
                    {
                        int num15;
                        dashedOutlineMasks = new IBitmap <ColorAlpha8> [SelectionCanvasLayer.DashLength];
                        for (int i = 0; i < dashedOutlineMasks.Length; i = num15)
                        {
                            if ((!this.redrawRenderParams.IsOutlineAnimated && (i != 0)) && (i != (SelectionCanvasLayer.DashLength / 2)))
                            {
                                dashedOutlineMasks[i] = null;
                            }
                            else
                            {
                                dashedOutlineMasks[i] = BitmapAllocator.Alpha8.Allocate(viewportRect.Size, AllocationOptions.ZeroFillNotRequired);
                                try
                                {
                                    RetryManager.RunMemorySensitiveOperation(delegate {
                                        using (IDrawingContext context = DrawingContext.FromBitmap(this.redrawThreadFactory, dashedOutlineMasks[i]))
                                        {
                                            context.Clear(null);
                                            StrokeStyle resourceSource      = SelectionCanvasLayer.GetDashedStrokeStyle(i);
                                            IStrokeStyle outlineStrokeStyle = context.GetCachedOrCreateResource <IStrokeStyle>(resourceSource);
                                            IBrush cachedOrCreateResource   = context.GetCachedOrCreateResource <IBrush>(whiteBrush);
                                            this.RenderSelection(context, scale, offset, this.redrawRenderParams, lazyGeometry, null, cachedOrCreateResource, outlineStrokeStyle, antialiasMode);
                                        }
                                    });
                                }
                                catch (OutOfMemoryException)
                                {
                                }
                                if (!this.CanContinueRedrawing(interiorMask, dashedOutlineMasks))
                                {
                                    return;
                                }
                            }
                            num15 = i + 1;
                        }
                        maskSourceRect = new RectFloat(PointFloat.Zero, interiorMask.Size);
                        base.SyncContext.Post(_ => this.EndRedraw(renderCanvasBounds, maskSourceRect, interiorMask, dashedOutlineMasks), null);
                    }
                }
            }
        }