private void PrePlane_D2DPaint(D2DGraphics g) { RawRectangleF rect = new RawRectangleF(0, 0, prePlane.Width, prePlane.Height); Color color = Color.Black; Color orgColor = Color.FromArgb(158, 105, 7); switch (preBtnMouseState) { case 0: color = Color.FromArgb(200, orgColor); break; case 1: color = Color.FromArgb(100, orgColor); break; case 2: color = Color.FromArgb(50, orgColor); break; } RawColor4 rawColor = GDIDataD2DUtils.TransToRawColor4(color); SharpDX.Direct2D1.Brush brush = new SolidColorBrush(g.RenderTarget, rawColor); g.RenderTarget.FillRectangle(rect, brush); }
protected override Geometry CreateHitGeometryByD2D(D2DGraphics g) { RectangleF rect = new RectangleF(0, 0, Width, Height); PathGeometry pathGeometry = new PathGeometry(D2DGraphics.d2dFactory); GeometrySink pSink = null; pSink = pathGeometry.Open(); pSink.SetFillMode(SharpDX.Direct2D1.FillMode.Winding); pSink.BeginFigure(new RawVector2(rect.Left, rect.Bottom), FigureBegin.Filled); float len = gradientSize; RawVector2[] points = { new RawVector2(rect.Left + len, rect.Top), new RawVector2(rect.Right - len, rect.Top), new RawVector2(rect.Right, rect.Bottom), }; pSink.AddLines(points); pSink.EndFigure(FigureEnd.Closed); pSink.Close(); pSink.Dispose(); return(pathGeometry); }
void FillItemGeometry(D2DGraphics g) { if (Enable == false) { color = Color.DarkGray; } g.RenderTarget.AntialiasMode = AntialiasMode.PerPrimitive; RawRectangleF rect = new RawRectangleF(1, 1, Width - 1, Height - 1); RoundedRectangle roundedRect = new RoundedRectangle() { RadiusX = this.RadiusX, RadiusY = this.RadiusY, Rect = rect }; RawColor4 rawColor = GDIDataD2DUtils.TransToRawColor4(color); SolidColorBrush brush = new SolidColorBrush(g.RenderTarget, rawColor); g.RenderTarget.FillRoundedRectangle(roundedRect, brush); rawColor = GDIDataD2DUtils.TransToRawColor4(Color.FromArgb(SideShadowAlpha, 0, 0, 0)); brush = new SolidColorBrush(g.RenderTarget, rawColor); g.RenderTarget.DrawRoundedRectangle(roundedRect, brush); }
public virtual void OnD2DPaint(ScGraphics g) { D2DGraphics d2dGraph = (D2DGraphics)g; if (d2dGraph == null) { return; } if (BackgroundColor != null && BackgroundColor.Value.A != 0) { if (BackgroundColor.Value.A == 255) { RawColor4 color = GDIDataD2DUtils.TransToRawColor4(Color.FromArgb(BackgroundColor.Value.ToArgb())); d2dGraph.RenderTarget.Clear(color); } else { d2dGraph.RenderTarget.AntialiasMode = AntialiasMode.Aliased; RawRectangleF rect = new RawRectangleF(0, 0, Width, Height); RawColor4 rawColor = GDIDataD2DUtils.TransToRawColor4(BackgroundColor.Value); SolidColorBrush brush = new SolidColorBrush(d2dGraph.RenderTarget, rawColor); d2dGraph.RenderTarget.FillRectangle(rect, brush); brush.Dispose(); } } if (D2DPaint != null) { D2DPaint(d2dGraph); } }
Geometry CreateCheckGeometry1(D2DGraphics g) { RectangleF rect = new RectangleF(FillMargin.left, FillMargin.top, Width - FillMargin.right - FillMargin.left, Height - FillMargin.bottom - FillMargin.top); float w = rect.Width / 2; float h2 = rect.Height / 2; float h4 = rect.Height / 4f; PathGeometry pathGeometry = new PathGeometry(D2DGraphics.d2dFactory); GeometrySink pSink = null; pSink = pathGeometry.Open(); pSink.SetFillMode(SharpDX.Direct2D1.FillMode.Winding); pSink.BeginFigure(new RawVector2(rect.Left, rect.Top + h2), FigureBegin.Filled); RawVector2[] points = { new RawVector2(rect.Left + w - w / 10, rect.Top + h4 * 2.7f), new RawVector2(rect.Right, rect.Top), new RawVector2(rect.Left + w, rect.Bottom), }; pSink.AddLines(points); pSink.EndFigure(FigureEnd.Closed); pSink.Close(); pSink.Dispose(); return(pathGeometry); }
private void DrawCheckLayer_D2DPaint(D2DGraphics g) { if (isChecked) { DrawCheck(g); } }
void FillIn2(D2DGraphics g, Color boxColor) { RawRectangleF rect = new RawRectangleF(0, 0, Width, Height); RadialGradientBrushProperties props2 = new RadialGradientBrushProperties() { Center = new RawVector2((rect.Left + rect.Right) / 2, (rect.Top + rect.Bottom) / 2), GradientOriginOffset = new RawVector2(0, 0), RadiusX = Width / 2, RadiusY = Height / 2 }; GradientStop[] gradientStops2 = new GradientStop[2]; gradientStops2[0].Color = GDIDataD2DUtils.TransToRawColor4(Color.FromArgb(55, boxColor.R, boxColor.G, boxColor.B)); gradientStops2[0].Position = 0f; //gradientStops2[1].Color = GDIDataD2DUtils.TransToRawColor4(Color.FromArgb(40, 0,0,255)); //gradientStops2[1].Position = 0.5f; gradientStops2[1].Color = GDIDataD2DUtils.TransToRawColor4(Color.FromArgb(55, boxColor.R, boxColor.G, boxColor.B)); gradientStops2[1].Position = 1f; // GradientStopCollection gradientStopCollection2 = new GradientStopCollection(g.RenderTarget, gradientStops2, Gamma.StandardRgb, ExtendMode.Clamp); RadialGradientBrush radialGradientBrush = new RadialGradientBrush(g.RenderTarget, props2, gradientStopCollection2); g.RenderTarget.FillRectangle(rect, radialGradientBrush); gradientStopCollection2.Dispose(); radialGradientBrush.Dispose(); }
Geometry CreateCheckGeometry0(D2DGraphics g) { RectangleF rect = new RectangleF(0, Height, Width, Height); float w = rect.Width / 2; float h = rect.Height / 4; PathGeometry pathGeometry = new PathGeometry(D2DGraphics.d2dFactory); GeometrySink pSink = null; pSink = pathGeometry.Open(); pSink.SetFillMode(SharpDX.Direct2D1.FillMode.Winding); pSink.BeginFigure(new RawVector2(rect.Left, rect.Top), FigureBegin.Filled); RawVector2[] points = { new RawVector2(rect.Left + w, rect.Top + h * 2), new RawVector2(rect.Right + w, rect.Top - h * 2), new RawVector2(rect.Left + w, rect.Bottom), }; pSink.AddLines(points); pSink.EndFigure(FigureEnd.Closed); pSink.Close(); pSink.Dispose(); return(pathGeometry); }
void FillItemGeometry(D2DGraphics g) { RectangleF rect = new RectangleF(0, 0, Width, Height); PathGeometry pathGeometry = new PathGeometry(D2DGraphics.d2dFactory); GeometrySink pSink = null; pSink = pathGeometry.Open(); pSink.SetFillMode(SharpDX.Direct2D1.FillMode.Winding); pSink.BeginFigure(new RawVector2(rect.Left, rect.Bottom), FigureBegin.Filled); float len = gradientSize; RawVector2[] points = { new RawVector2(rect.Left + len, rect.Top), new RawVector2(rect.Right - len, rect.Top), new RawVector2(rect.Right, rect.Bottom), }; pSink.AddLines(points); pSink.EndFigure(FigureEnd.Closed); pSink.Close(); pSink.Dispose(); RawColor4 rawColor = GDIDataD2DUtils.TransToRawColor4(color); SolidColorBrush brush = new SolidColorBrush(g.RenderTarget, rawColor); g.RenderTarget.FillGeometry(pathGeometry, brush); }
void PaintState2(D2DGraphics g) { g.RenderTarget.AntialiasMode = AntialiasMode.Aliased; RawRectangleF rect = new RawRectangleF(1, 1, Width - 1, Height - 1); int a = Math.Min(BoxColor.A + 100, 255); int R = Math.Max(BoxColor.R - 130, 0); int G = Math.Max(BoxColor.G - 130, 0); int B = Math.Max(BoxColor.B - 130, 0); RawColor4 rawColor = GDIDataD2DUtils.TransToRawColor4(Color.FromArgb(a, R, G, B)); SolidColorBrush brush = new SolidColorBrush(g.RenderTarget, rawColor); g.RenderTarget.DrawRectangle(rect, brush, boxSideWidth); brush.Dispose(); R = Math.Max(FillInBoxColor.R - 50, 0); G = Math.Max(FillInBoxColor.G - 50, 0); B = Math.Max(FillInBoxColor.B - 50, 0); if (IsUseInFill) { FillIn(g, Color.FromArgb(FillInBoxColor.A, R, G, B)); } if (IsUseInFill2) { FillIn2(g, Color.FromArgb(FillInBoxColor.A, R, G, B)); } }
private void ScGridViewContainer_D2DPaint(D2DGraphics g) { //g.RenderTarget.AntialiasMode = AntialiasMode.Aliased; //RawRectangleF rect = new RawRectangleF(0, 0, Width , Height - 1); //RawColor4 rawColor = GDIDataD2DUtils.TransToRawColor4(Color.FromArgb(255, 227, 228, 231)); //SolidColorBrush brush = new SolidColorBrush(g.RenderTarget, rawColor); //g.RenderTarget.FillRectangle(rect, brush); }
protected virtual Geometry CreateHitGeometryByD2D(D2DGraphics g) { IsUseOrgHitGeometry = true; RawRectangleF rc = new RawRectangleF(0, 0, Width, Height); RectangleGeometry geometry = new RectangleGeometry(D2DGraphics.d2dFactory, rc); return(geometry); }
public void CreateD2D() { d2d = (D2DGraphics)ScMgr.Graphics; if (d2d != null) { scTextRenderer = new ScTextRenderer(D2DGraphics.d2dFactory, d2d.renderTarget); } }
private void Screen2_D2DPaint(D2DGraphics g) { g.RenderTarget.AntialiasMode = AntialiasMode.Aliased; RawRectangleF rect = new RawRectangleF(0, 0, (float)Math.Ceiling(screen2.Width - 1), (float)Math.Ceiling(screen2.Height - 1)); RawColor4 rawColor = GDIDataD2DUtils.TransToRawColor4(Color.FromArgb(100, 0, 255, 0)); SolidColorBrush brush = new SolidColorBrush(g.RenderTarget, rawColor); g.RenderTarget.FillRectangle(rect, brush); }
private void TabBodyBox_D2DPaint(D2DGraphics g) { RawRectangleF rect = new RawRectangleF(0, 0, tabBodyBox.Width, tabBodyBox.Height); PathGeometry pathGeo = DrawUtils.CreateOutlineRoundRectGeometry(g, rect, 6); RawColor4 rawColor = GDIDataD2DUtils.TransToRawColor4(Color.FromArgb(255, 191, 152, 90)); SolidColorBrush brush = new SolidColorBrush(g.RenderTarget, rawColor); g.RenderTarget.FillGeometry(pathGeo, brush); }
private void ScButton_D2DPaint(D2DGraphics g) { FillItemGeometry(g); DrawString(g); if (PaintEvent != null) { RawRectangleF rect = new RawRectangleF(0, 0, Width, Height); PaintEvent(g, rect); } }
private void Selector_D2DPaint(D2DGraphics g) { if (!IsSelected) { return; } g.RenderTarget.AntialiasMode = AntialiasMode.Aliased; RawRectangleF rect = new RawRectangleF(1, 1, selector.Width - 2, selector.Height - 9); RawColor4 rawColor = GDIDataD2DUtils.TransToRawColor4(SelectorColor); SolidColorBrush brush = new SolidColorBrush(g.RenderTarget, rawColor); RoundedRectangle rounderRect = new RoundedRectangle { RadiusX = 1, RadiusY = 1, Rect = rect }; g.RenderTarget.DrawRoundedRectangle(rounderRect, brush, 2f); brush.Dispose(); // GradientStop[] gradientStops = new GradientStop[2]; gradientStops[0].Color = new RawColor4(0, 0, 0, 0.1f); gradientStops[0].Position = 0f; gradientStops[1].Color = new RawColor4(0, 0, 0, 0); gradientStops[1].Position = 1f; // GradientStopCollection gradientStopCollection = new GradientStopCollection(g.RenderTarget, gradientStops, Gamma.StandardRgb, ExtendMode.Clamp); // rect = new RawRectangleF(0, selector.Height - 9, selector.Width - 1, selector.Height - 1); LinearGradientBrushProperties props = new LinearGradientBrushProperties() { StartPoint = new RawVector2(rect.Left, rect.Top), EndPoint = new RawVector2(rect.Left, rect.Bottom) }; SharpDX.Direct2D1.LinearGradientBrush linearGradientBrush = new SharpDX.Direct2D1.LinearGradientBrush(g.RenderTarget, props, gradientStopCollection); g.RenderTarget.FillRectangle(rect, linearGradientBrush); gradientStopCollection.Dispose(); linearGradientBrush.Dispose(); //Graphics gdiGraphics = g.CreateGdiGraphics(); //gdiGraphics.SmoothingMode = SmoothingMode.HighQuality; //RectangleF rect1 = new RectangleF(0, 0, (float)Math.Ceiling(Width - 1), (float)Math.Ceiling(Height - 1)); //Pen pen = new Pen(Color.FromArgb(255, 191, 152, 90), 1f); //DrawUtils.DrawRoundRectangle(gdiGraphics, Pens.Gold, rect1, 4); //g.RelaseGdiGraphics(gdiGraphics); //pen.Dispose(); }
private void ScLayerLayoutViewerHeaderItem_D2DPaint(D2DGraphics g) { g.RenderTarget.AntialiasMode = AntialiasMode.Aliased; RawRectangleF rect = new RawRectangleF(0, 0, Width - 1, Height - 1); RawColor4 rawColor = GDIDataD2DUtils.TransToRawColor4(Color.FromArgb(55, 0, 0, 255)); SolidColorBrush brush = new SolidColorBrush(g.RenderTarget, rawColor); g.RenderTarget.FillRectangle(rect, brush); brush.Dispose(); }
private void ScTabHeadItem_D2DPaint(D2DGraphics g) { FillItemGeometry(g); DrawItemGeometry(g); Graphics gdiGraph = g.CreateGdiGraphics(); DrawString(gdiGraph); g.RelaseGdiGraphics(gdiGraph); }
private void DebugLayer_D2DPaint(D2DGraphics g) { g.RenderTarget.AntialiasMode = AntialiasMode.PerPrimitive; RawRectangleF rect = new RawRectangleF(1, 1, Width - 1, Height - 1); RawColor4 rawColor = GDIDataD2DUtils.TransToRawColor4(Color.DarkBlue); SolidColorBrush brush = new SolidColorBrush(g.RenderTarget, rawColor); //宽度 TextFormat textFormat = new TextFormat(D2DGraphics.dwriteFactory, "微软雅黑", 12) { TextAlignment = TextAlignment.Center, ParagraphAlignment = ParagraphAlignment.Center }; RawRectangleF rectw = new RawRectangleF(0, Height - 20, Width - 1, Height - 1); g.RenderTarget.DrawText(Width.ToString(), textFormat, rectw, brush); //高度 TextFormat textFormat2 = new TextFormat(D2DGraphics.dwriteFactory, "微软雅黑", 12) { TextAlignment = TextAlignment.Center, ParagraphAlignment = ParagraphAlignment.Center, FlowDirection = SharpDX.DirectWrite.FlowDirection.TopToBottom }; RawRectangleF recth = new RawRectangleF(Width - 10, 0, Width - 1, Height - 1); g.RenderTarget.DrawText(Height.ToString(), textFormat2, recth, brush); //全局坐标位置 PointF pt = parent.TransLocalToGlobal(Location); textFormat.ParagraphAlignment = ParagraphAlignment.Near; textFormat.TextAlignment = TextAlignment.Justified; RawRectangleF rectxy = new RawRectangleF(0, 0, Width - 1, 10); g.RenderTarget.DrawText(pt.ToString(), textFormat, rectxy, brush); //层类名称 string mm = this.GetType().Name; if (!string.IsNullOrWhiteSpace(Name)) { mm += "(" + Name + ")"; } textFormat.ParagraphAlignment = ParagraphAlignment.Center; textFormat.TextAlignment = TextAlignment.Center; RawRectangleF rectname = new RawRectangleF(0, 0, Width - 1, 10); g.RenderTarget.DrawText(mm, textFormat, rectxy, brush); g.RenderTarget.DrawRectangle(rect, brush, 1f); }
private void ScScrollBarSlider_D2DPaint(D2DGraphics g) { g.RenderTarget.AntialiasMode = AntialiasMode.Aliased; RawRectangleF rect = new RawRectangleF(2, 0, Width - 2, Height); RawColor4 color = GDIDataD2DUtils.TransToRawColor4(Color.FromArgb(alpha, 191, 152, 90)); SharpDX.Direct2D1.Brush brush = new SolidColorBrush(g.RenderTarget, color); g.RenderTarget.FillRectangle(rect, brush); }
private void ScShadow_D2DPaint(D2DGraphics g) { Dot9BitmapD2D dot9Bitmapshadow = GetDot9BitmapShadow(); if (dot9Bitmapshadow == null) { return; } dot9Bitmapshadow.ComputeBitmapStretch((int)Width, (int)Height); dot9Bitmapshadow.DrawTo(g); }
private void ScTextBoxEx_D2DPaint(D2DGraphics g) { g.RenderTarget.AntialiasMode = AntialiasMode.Aliased; RawRectangleF rect = new RawRectangleF(2, 2, Width - 1, Height - 1); // PathGeometry pathGeometry = new PathGeometry(D2DGraphics.d2dFactory); // PathGeometry pathGeometry = DrawUtils.CreateOutlineRoundRectGeometry(g, rect, 4); //ID2D1StrokeStyle* g_stroke_style; // 声明线条风格接口 //g_pD2DFactory->CreateStrokeStyle(D2D1::StrokeStyleProperties( // D2D1_CAP_STYLE_ROUND, // D2D1_CAP_STYLE_ROUND, // D2D1_CAP_STYLE_ROUND, // D2D1_LINE_JOIN_MITER, // 1.0f, // D2D1_DASH_STYLE_SOLID, // 有多种风格可以设置(dash,dot....) // 10.0f), // NULL, // 0, // &g_stroke_style); RoundedRectangle roundedRect = new RoundedRectangle() { RadiusX = 4, RadiusY = 4, Rect = rect }; RawColor4 rawColor = GDIDataD2DUtils.TransToRawColor4(Color.FromArgb(255, 200, 200, 200)); SolidColorBrush brush = new SolidColorBrush(g.RenderTarget, rawColor); g.RenderTarget.DrawRectangle(rect, brush, 1f); //Graphics gdiGraphics = g.CreateGdiGraphics(); //gdiGraphics.SmoothingMode = SmoothingMode.HighQuality; //RectangleF rect1 = new RectangleF(0, 0, (float)Math.Ceiling(Width - 1), (float)Math.Ceiling(Height - 1)); //Pen pen = new Pen(Color.FromArgb(255, 191, 152, 90), 1f); //DrawUtils.DrawRoundRectangle(gdiGraphics, Pens.Gold, rect1, 4); //g.RelaseGdiGraphics(gdiGraphics); // g.RenderTarget.DrawGeometry(pathGeometry, brush); }
private void RootScControl_D2DPaint(D2DGraphics g) { RawRectangleF rect = new RawRectangleF(0, 0, rootScLayer.Width, rootScLayer.Height); if (BackgroundColor != null) { RawColor4 color = GDIDataD2DUtils.TransToRawColor4(BackgroundColor.Value); g.RenderTarget.Clear(color); } else if (controlType == ControlType.UPDATELAYERFORM) { g.RenderTarget.Clear(new RawColor4(0, 0, 0, 0)); } }
private void ScLayerLayoutViewerHeaderItemContainer_D2DPaint(D2DGraphics g) { switch (StyleIdx) { case 1: g.RenderTarget.AntialiasMode = AntialiasMode.Aliased; RawRectangleF rect = new RawRectangleF(0, 0, Width, Height); RawColor4 rawColor = GDIDataD2DUtils.TransToRawColor4(BackGroundColor); SolidColorBrush brush = new SolidColorBrush(g.RenderTarget, rawColor); g.RenderTarget.FillRectangle(rect, brush); brush.Dispose(); break; } }
void _RenderByD2D(D2DGraphics graph, Rectangle refreshArea) { try { graph.BeginDraw(); reDrawTree.ReCreateReDrawTree(rootScLayer, refreshArea); reDrawTree.Draw(graph); graph.EndDraw(); } catch (Exception ex) { CreateD2D(); control.Refresh(); control.Update(); } }
void PaintState0(D2DGraphics g) { g.RenderTarget.AntialiasMode = AntialiasMode.Aliased; RawRectangleF rect = new RawRectangleF(1, 1, Width - 1, Height - 1); RawColor4 rawColor = GDIDataD2DUtils.TransToRawColor4(BoxColor); SolidColorBrush brush = new SolidColorBrush(g.RenderTarget, rawColor); g.RenderTarget.DrawRectangle(rect, brush, boxSideWidth); brush.Dispose(); if (IsUseInFill) { FillIn(g, Color.FromArgb(50, BoxColor.R, BoxColor.G, BoxColor.B)); } }
private void ScCheckBox_D2DPaint(D2DGraphics g) { switch (state) { case 0: PaintState0(g); break; case 1: PaintState1(g); break; case 2: PaintState2(g); break; } }
void _PaintByD2D(Rectangle refreshArea) { D2DGraphics d2dGraphics = (D2DGraphics)graphics; if (drawType == DrawType.NOIMAGE) { WindowRenderTarget wRT = (WindowRenderTarget)d2dGraphics.RenderTarget; WindowState wstate = wRT.CheckWindowState(); if (wstate != WindowState.Occluded) { _RenderByD2D(d2dGraphics, refreshArea); } } else { _RenderByD2D(d2dGraphics, refreshArea); } }
protected override Geometry CreateHitGeometryByD2D(D2DGraphics g) { RawRectangleF rect = new RawRectangleF( 0, 0, Width - 1, Height - 1); RoundedRectangle roundedRect = new RoundedRectangle() { RadiusX = this.RadiusX, RadiusY = this.RadiusY, Rect = rect }; RoundedRectangleGeometry roundedRectGeo = new RoundedRectangleGeometry(D2DGraphics.d2dFactory, roundedRect); return(roundedRectGeo); }