Beispiel #1
0
        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();
                }
            }
        }
Beispiel #2
0
        void AddChildReDrawScLayer(ScDrawNode parentDrawNode, RectangleF parentClipRect)
        {
            ScLayer parentScLayer = parentDrawNode.layer;

            _AddChildReDrawScLayer(parentDrawNode, parentClipRect, parentScLayer.controls);
            _AddChildReDrawScLayer(parentDrawNode, parentClipRect, parentScLayer.DirectClipChildLayerList);
        }
Beispiel #3
0
        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();
        }
Beispiel #4
0
        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();
        }
Beispiel #5
0
        public ScDrawNode ReCreateReDrawTree(ScLayer rootLayer, Rectangle refreshArea)
        {
            if (rootLayer.Visible == false)
            {
                return(null);
            }

            scmgr = rootLayer.ScMgr;

            RectangleF clipRect = new RectangleF(refreshArea.X, refreshArea.Y, refreshArea.Width, refreshArea.Height);

            root = _AddChildReDrawScLayer(null, clipRect, new List <ScLayer> {
                rootLayer
            });

            return(root);
        }
Beispiel #6
0
        void GDIPaintLayer(GDIGraphics g, ScDrawNode node)
        {
            if (node == null)
            {
                return;
            }

            ScLayer layer = node.layer;

            g.SetClip(node.clipRect);
            g.Transform = node.m;
            layer.OnGDIPaint(g);
            g.ResetTransform();
            g.ResetClip();

            node.m.Dispose();
        }
Beispiel #7
0
        public GDILayer PushLayer(GDIGraphics g, ScDrawNode node)
        {
            ScLayer  sclayer  = node.layer;
            GDILayer gdiLayer = new GDILayer(g);

            GDILayerParameters layerParameters = new GDILayerParameters();

            layerParameters.ContentBounds     = sclayer.DrawBox;
            layerParameters.MaskAntialiasMode = GDIAntialiasMode.PerPrimitive;
            layerParameters.Opacity           = sclayer.Opacity;

            layerParameters.ClipRect = new RectangleF(
                (int)(node.clipRect.X - sclayer.DrawBox.X - 1), (int)(node.clipRect.Y - sclayer.DrawBox.Y - 1),
                (int)(node.clipRect.Width + 2), (int)(node.clipRect.Height + 2));


            Matrix m = new Matrix();

            m.Translate(-sclayer.DrawBox.X, -sclayer.DrawBox.Y);
            m.Multiply(sclayer.GlobalMatrix);
            node.m         = m;
            node.rootLayer = node.layer;

            if (!sclayer.Parent.IsComputedStraight)
            {
                m = new Matrix();
                m.Translate(-sclayer.Parent.DrawBox.X, -sclayer.Parent.DrawBox.Y);
                m.Multiply(sclayer.GlobalMatrix);

                layerParameters.GeometricMask = sclayer.CreateTransLastHitGeometryForGDI(m);
                m.Dispose();
            }
            else
            {
                layerParameters.GeometricMask  = sclayer.TransLastHitGraphicsPath;
                layerParameters.parentClipRect = node.clipRect;
            }

            node.clipRect = layerParameters.ClipRect;

            layerParameters.sclayer = sclayer;

            g.PushLayer(layerParameters, gdiLayer);
            return(gdiLayer);
        }
Beispiel #8
0
        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();
                }
            }
        }
Beispiel #9
0
        ScDrawNode _AddChildReDrawScLayer(ScDrawNode parentDrawNode, RectangleF parentClipRect, List <ScLayer> childLayerList)
        {
            if (childLayerList == null)
            {
                return(null);
            }

            RectangleF rect;
            ScDrawNode drawNode = null;

            foreach (ScLayer childLayer in childLayerList)
            {
                if (childLayer.Visible == false ||
                    childLayer.IsNotAtRootDrawBoxBound)
                {
                    continue;
                }

                rect = childLayer.DrawBox;
                ScDrawNode clipDrawNode;
                RectangleF clipRect;

                clipDrawNode = parentDrawNode;
                clipRect     = parentClipRect;

                if (clipRect.IntersectsWith(rect))
                {
                    rect.Intersect(clipRect);

                    drawNode          = new ScDrawNode();
                    drawNode.layer    = childLayer;
                    drawNode.clipRect = rect;
                    drawNode.parent   = clipDrawNode;

                    if (clipDrawNode != null)
                    {
                        clipDrawNode.nodes.Add(drawNode);
                    }

                    //子层完全覆盖了父层,父层将不再绘制
                    if (childLayer.BackgroundColor != null &&
                        childLayer.BackgroundColor.Value.A == 255 &&
                        childLayer.IsComputedStraight && clipDrawNode.clipRect.Equals(rect))
                    {
                        clipDrawNode.isRender = false;

                        for (ScDrawNode parentNode = clipDrawNode.parent; parentNode != null; parentNode = parentNode.parent)
                        {
                            if (!parentNode.clipRect.Equals(rect) || parentNode.layer.IsComputedStraight)
                            {
                                break;
                            }

                            parentNode.isRender = false;
                        }
                    }

                    AddChildReDrawScLayer(drawNode, drawNode.clipRect);
                }
            }

            return(drawNode);
        }