private void DrawText(ChartControl chartControl) { if (Font == null || string.IsNullOrEmpty(DisplayText)) { return; } Rect outLineRect = GetCurrentRect(layoutRect, outlinePadding); // this will add padding to layoutRect for us SharpDX.RectangleF outlineRectDx = new SharpDX.RectangleF((float)outLineRect.X, (float)outLineRect.Y, (float)outLineRect.Width, (float)outLineRect.Height); textBrushDevice.RenderTarget = RenderTarget; areaBrushDevice.RenderTarget = RenderTarget; OutlineStroke.RenderTarget = RenderTarget; SharpDX.Direct2D1.Brush tmpBrush; if (AreaBrush != null) { SolidColorBrush tmpOb = areaBrushDevice.Brush as SolidColorBrush; SolidColorBrush tmpNb = AreaBrush as SolidColorBrush; // if brush not set, set brush. else if brush set and changed, change brush. if not SolidColorBrush always change brush if (tmpNb == null || tmpOb == null || tmpOb.Color != tmpNb.Color || Math.Abs(tmpOb.Opacity - tmpNb.Opacity) > 0.1) { Brush brushCopy = AreaBrush.Clone(); brushCopy.Opacity = areaOpacity / 100d; areaBrushDevice.Brush = brushCopy; } areaBrushDevice.RenderTarget = RenderTarget; tmpBrush = IsInHitTest ? chartControl.SelectionBrush : areaBrushDevice.BrushDX; RenderTarget.FillRectangle(outlineRectDx, tmpBrush); } else { areaBrushDevice.RenderTarget = null; } if (OutlineStroke.StrokeStyle != null && (OutlineStroke.Brush != null || !OutlineStroke.Brush.IsTransparent())) { tmpBrush = IsInHitTest ? chartControl.SelectionBrush : OutlineStroke.BrushDX; if (tmpBrush != null) { RenderTarget.DrawRectangle(outlineRectDx, tmpBrush, OutlineStroke.Width, OutlineStroke.StrokeStyle); } } textBrushDevice.RenderTarget = RenderTarget; SolidColorBrush tmpOtb = textBrushDevice.Brush as SolidColorBrush; SolidColorBrush tmpNtb = TextBrush as SolidColorBrush; // if brush not set, set brush. else if brush set and changed, change brush. if not SolidColorBrush always change brush if (tmpNtb == null || tmpOtb == null || tmpOtb.Color != tmpNtb.Color || Math.Abs(tmpOtb.Opacity - tmpNtb.Opacity) > 0.1) { textBrushDevice.Brush = TextBrush; } // when drawing the actual text layout, add padding again, we dont want text right on the edges of our outline rect tmpBrush = IsInHitTest ? chartControl.SelectionBrush : textBrushDevice.BrushDX; RenderTarget.DrawTextLayout(new SharpDX.Vector2(outlineRectDx.X + outlinePadding, outlineRectDx.Y + outlinePadding), cachedTextLayout, tmpBrush, SharpDX.Direct2D1.DrawTextOptions.NoSnap); }
public override void OnRender(ChartControl chartControl, ChartScale chartScale) { ChartPanel panel = chartControl.ChartPanels[PanelIndex]; UpdateArcGeometry(chartControl, panel, chartScale); base.OnRender(chartControl, chartScale); RenderTarget.AntialiasMode = SharpDX.Direct2D1.AntialiasMode.PerPrimitive; if (AreaBrush != null && !IsInHitTest) { areaBrushDevice.RenderTarget = RenderTarget; if (areaBrushDevice.Brush == null) { Brush brushCopy = AreaBrush.Clone(); brushCopy.Opacity = areaOpacity / 100d; areaBrushDevice.Brush = brushCopy; } RenderTarget.FillGeometry(arcGeometry, areaBrushDevice.BrushDX); } ArcStroke.RenderTarget = RenderTarget; SharpDX.Direct2D1.Brush tmpBrush = IsInHitTest ? chartControl.SelectionBrush : ArcStroke.BrushDX; RenderTarget.DrawGeometry(arcGeometry, tmpBrush, ArcStroke.Width, ArcStroke.StrokeStyle); }