Beispiel #1
0
        public PreviewStarBurst(PreviewPoint point1, ElementNode selectedNode, double zoomLevel)
        {
            ZoomLevel    = zoomLevel;
            _topLeft     = PointToZoomPoint(point1);
            _topRight    = new PreviewPoint(_topLeft);
            _bottomLeft  = new PreviewPoint(_topLeft);
            _bottomRight = new PreviewPoint(_topLeft);

            _strings = new List <PreviewBaseShape>();

            if (selectedNode != null)
            {
                List <ElementNode> children = PreviewTools.GetLeafNodes(selectedNode);
                int stringCount             = PreviewTools.GetParentNodes(selectedNode).Count();
                if (stringCount >= 4)
                {
                    int spokePixelCount = 0;
                    foreach (ElementNode node in selectedNode.Children)
                    {
                        spokePixelCount = Math.Max(spokePixelCount, node.Children.Count());
                    }

                    StringType = StringTypes.Pixel;

                    foreach (ElementNode node in selectedNode.Children)
                    {
                        PreviewLine line;
                        line = new PreviewLine(new PreviewPoint(10, 10), new PreviewPoint(20, 20), spokePixelCount, node, ZoomLevel);

                        line.PixelColor = Color.White;
                        _strings.Add(line);
                    }
                }
            }

            if (_strings.Count == 0)
            {
                // Just add lines, they will be layed out in Layout()
                StringType = StringTypes.Standard;
                for (int i = 0; i < 8; i++)
                {
                    PreviewLine line;
                    line            = new PreviewLine(new PreviewPoint(10, 10), new PreviewPoint(20, 20), 10, selectedNode, ZoomLevel);
                    line.PixelColor = Color.White;
                    line.StringType = StringTypes.Standard;
                    _strings.Add(line);
                }
            }

            Layout();
        }
Beispiel #2
0
        /// <inheritdoc />
        internal sealed override void Reconfigure(ElementNode node)
        {
            _pixels.Clear();
            _strings = new List <PreviewBaseShape>();

            if (node != null)
            {
                //List<ElementNode> children = PreviewTools.GetLeafNodes(node);
                int stringCount = PreviewTools.GetParentNodes(node).Count();
                if (stringCount >= 4)
                {
                    int spokePixelCount = 0;
                    foreach (ElementNode n in node.Children)
                    {
                        spokePixelCount = Math.Max(spokePixelCount, n.Children.Count());
                    }

                    StringType = StringTypes.Pixel;

                    foreach (ElementNode n in node.Children)
                    {
                        var line = new PreviewLine(new PreviewPoint(10, 10), new PreviewPoint(20, 20), spokePixelCount, n, ZoomLevel);

                        line.PixelColor = Color.White;
                        _strings.Add(line);
                    }
                }
            }

            if (_strings.Count == 0)
            {
                // Just add lines, they will be layed out in Layout()
                StringType = StringTypes.Standard;
                for (int i = 0; i < 8; i++)
                {
                    PreviewLine line;
                    line            = new PreviewLine(new PreviewPoint(10, 10), new PreviewPoint(20, 20), 10, node, ZoomLevel);
                    line.PixelColor = Color.White;
                    line.StringType = StringTypes.Standard;
                    _strings.Add(line);
                }
            }

            Layout();
        }
Beispiel #3
0
        public PreviewRectangle(PreviewPoint point1, ElementNode selectedNode, double zoomLevel)
        {
            ZoomLevel    = zoomLevel;
            _topLeft     = PointToZoomPoint(point1);
            _topRight    = new PreviewPoint(_topLeft);
            _bottomLeft  = new PreviewPoint(_topLeft);
            _bottomRight = new PreviewPoint(_topLeft);

            _strings = new List <PreviewBaseShape>();

            if (selectedNode != null)
            {
                List <ElementNode> parents = PreviewTools.GetParentNodes(selectedNode);
                // Do we have the 4 sides of the rectangle defined in our elements?
                if (parents.Count() == 4)
                {
                    foreach (ElementNode pixelString in parents)
                    {
                        PreviewLine line = new PreviewLine(new PreviewPoint(10, 10), new PreviewPoint(20, 20), pixelString.Children.Count(), pixelString, ZoomLevel);
                        line.PixelColor = Color.White;
                        _strings.Add(line);
                    }
                }
                else
                {
                    List <ElementNode> children = PreviewTools.GetLeafNodes(selectedNode);
                    if (children.Count >= 8)
                    {
                        int increment  = children.Count / 4;
                        int pixelsLeft = children.Count;

                        StringType = StringTypes.Pixel;

                        // Just add lines, they will be layed out in Layout()
                        for (int i = 0; i < 4; i++)
                        {
                            PreviewLine line;
                            if (pixelsLeft >= increment)
                            {
                                line = new PreviewLine(new PreviewPoint(10, 10), new PreviewPoint(20, 20), increment, null, ZoomLevel);
                            }
                            else
                            {
                                line = new PreviewLine(new PreviewPoint(10, 10), new PreviewPoint(20, 20), pixelsLeft, null, ZoomLevel);
                            }
                            line.PixelColor = Color.White;
                            _strings.Add(line);

                            pixelsLeft -= increment;
                        }

                        int pixelNum = 0;
                        foreach (PreviewPixel pixel in Pixels)
                        {
                            pixel.Node   = children[pixelNum];
                            pixel.NodeId = children[pixelNum].Id;
                            pixelNum++;
                        }
                    }
                }
            }

            if (_strings.Count == 0)
            {
                // Just add lines, they will be layed out in Layout()
                for (int i = 0; i < 4; i++)
                {
                    PreviewLine line;
                    line            = new PreviewLine(new PreviewPoint(10, 10), new PreviewPoint(20, 20), 10, selectedNode, ZoomLevel);
                    line.PixelColor = Color.White;
                    _strings.Add(line);
                }
            }

            Layout();
        }
Beispiel #4
0
        /// <inheritdoc />
        internal sealed override void Reconfigure(ElementNode node)
        {
            _strings = new List <PreviewBaseShape>();

            if (node != null)
            {
                List <ElementNode> parents = PreviewTools.GetParentNodes(node);
                // Do we have the 4 sides of the rectangle defined in our elements?
                if (parents.Count() == 4)
                {
                    foreach (ElementNode pixelString in parents)
                    {
                        PreviewLine line = new PreviewLine(new PreviewPoint(10, 10), new PreviewPoint(20, 20), pixelString.Children.Count(), pixelString, ZoomLevel);
                        line.PixelColor = Color.White;
                        _strings.Add(line);
                    }
                }
                else
                {
                    List <ElementNode> children = PreviewTools.GetLeafNodes(node);
                    if (children.Count >= 8)
                    {
                        int increment  = children.Count / 4;
                        int pixelsLeft = children.Count;

                        StringType = StringTypes.Pixel;

                        // Just add lines, they will be layed out in Layout()
                        for (int i = 0; i < 4; i++)
                        {
                            PreviewLine line;
                            if (pixelsLeft >= increment)
                            {
                                line = new PreviewLine(new PreviewPoint(10, 10), new PreviewPoint(20, 20), increment, null, ZoomLevel);
                            }
                            else
                            {
                                line = new PreviewLine(new PreviewPoint(10, 10), new PreviewPoint(20, 20), pixelsLeft, null, ZoomLevel);
                            }
                            line.PixelColor = Color.White;
                            _strings.Add(line);

                            pixelsLeft -= increment;
                        }

                        int pixelNum = 0;
                        foreach (PreviewPixel pixel in Pixels)
                        {
                            pixel.Node   = children[pixelNum];
                            pixel.NodeId = children[pixelNum].Id;
                            pixelNum++;
                        }
                    }
                }
            }

            if (_strings.Count == 0)
            {
                // Just add lines, they will be layed out in Layout()
                for (int i = 0; i < 4; i++)
                {
                    PreviewLine line;
                    line            = new PreviewLine(new PreviewPoint(10, 10), new PreviewPoint(20, 20), 10, node, ZoomLevel);
                    line.PixelColor = Color.White;
                    _strings.Add(line);
                }
            }

            Layout();
        }