void DrawChildNodeD2D(ScDrawNode parent, ScGraphics g) { Layer d2dLayer; foreach (ScDrawNode node in parent.nodes) { if (node.layer.IsComputedStraight) { if (node.isRender && node.layer.IsRender) { D2DPaint(g, node); } DrawChildNodeD2D(node, g); } else { d2dLayer = PushLayer((D2DGraphics)g, node.layer); D2DPaint(g, node); DrawChildNodeD2D(node, g); PopLayer((D2DGraphics)g); d2dLayer.Dispose(); } } }
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); } }
void GDIPaint(ScGraphics g, ScDrawNode node) { if (node == null) { return; } ScLayer layer = node.layer; if (node.rootLayer == null) { g.SetClip(node.clipRect); g.Transform = layer.GlobalMatrix; g.layer = layer; layer.OnGDIPaint(g); } else { ScLayer rootLayer = node.rootLayer; Matrix m = new Matrix(); m.Translate(-rootLayer.DrawBox.X, -rootLayer.DrawBox.Y); m.Multiply(layer.GlobalMatrix); g.SetClip(node.clipRect); g.Transform = m; g.layer = layer; layer.OnGDIPaint(g); m.Dispose(); } g.layer = null; g.ResetTransform(); g.ResetClip(); }
public void Draw(ScGraphics g) { if (root == null) { return; } g.SetClip(root.clipRect); switch (g.GetGraphicsType()) { case GraphicsType.D2D: if (root.isRender) { D2DPaint(g, root); } DrawChildNodeD2D(root, g); break; case GraphicsType.GDIPLUS: RunGDIPaint(g); break; } g.ResetClip(); }
void RunGDIPaint(ScGraphics g) { ScMgr scmgr = root.layer.ScMgr; scmgr.ClearBitmapRect(root.clipRect); GDIPaint(g, root); DrawChildNodeGDI(root, g); }
void CreateGDIDiver() { if (drawType == DrawType.NOIMAGE) { graphics = new GDIGraphics(control); } else { graphics = new GDIGraphics(bitmap); } }
void D2DPaint(ScGraphics g, ScDrawNode node) { ScLayer layer = node.layer; g.SetClip(node.clipRect); g.Transform = layer.GlobalMatrix; g.layer = layer; layer.OnD2DPaint(g); g.layer = null; g.ResetTransform(); g.ResetClip(); }
bool CreateD2D() { foreach (var item in dot9BitmaShadowDict) { item.Value.Dispose(); } dot9BitmaShadowDict.Clear(); // if (graphics != null) { graphics.Dispose(); } if (cacheRootScLayer != null) { rootScLayer = cacheRootScLayer; } if (drawType == DrawType.NOIMAGE && (control.Width <= 0 || control.Height <= 0)) { rootScLayer = null; return(false); } else if (drawType != DrawType.NOIMAGE && (bitmap.Width <= 0 || bitmap.Height <= 0)) { rootScLayer = null; return(false); } if (drawType == DrawType.NOIMAGE) { graphics = new D2DGraphics(control); } else { graphics = new D2DGraphics(wicBitmap); } foreach (ScLayer layer in rebulidLayerList) { layer.ScReBulid(); } return(true); }
void DrawChildNodeGDI(ScDrawNode parent, ScGraphics g) { GDILayer gdiLayer; foreach (ScDrawNode node in parent.nodes) { if (node.layer.IsComputedStraight) { GDIPaint(g, node); DrawChildNodeGDI(node, g); } else { gdiLayer = PushLayer((GDIGraphics)g, node); GDIPaintLayer((GDIGraphics)g, node); DrawChildNodeGDI(node, g); PopLayer((GDIGraphics)g); gdiLayer.Dispose(); } } }
public virtual void OnGDIPaint(ScGraphics g) { GDIPaint?.Invoke((GDIGraphics)g); }