Inheritance: VixenModules.Preview.VixenPreview.Shapes.PreviewBaseShape
Ejemplo n.º 1
0
 public override void Layout()
 {
     if (StringOrientation == StringOrientations.Vertical)
     {
         int    width          = _bottomRight.X - _topLeft.X;
         int    height         = _bottomRight.Y - _topLeft.Y;
         double stringXSpacing = (double)width / (double)(StringCount - 1);
         int    x = _topLeft.X;
         int    y = _topLeft.Y;
         for (int stringNum = 0; stringNum < StringCount; stringNum++)
         {
             PreviewLine line = _strings[stringNum] as PreviewLine;
             line.SetPoint0(x, y + height);
             line.SetPoint1(x, y);
             line.Layout();
             x += (int)stringXSpacing;
         }
     }
     else
     {
         int    width          = _bottomRight.X - _bottomLeft.X;
         int    height         = _bottomLeft.Y - _topLeft.Y;
         double stringYSpacing = (double)height / (double)(StringCount - 1);
         int    x = _bottomLeft.X;
         int    y = _bottomLeft.Y;
         for (int stringNum = 0; stringNum < StringCount; stringNum++)
         {
             PreviewLine line = _strings[stringNum] as PreviewLine;
             line.SetPoint0(x, y);
             line.SetPoint1(x + width, y);
             line.Layout();
             y -= (int)stringYSpacing;
         }
     }
 }
Ejemplo n.º 2
0
 /// <inheritdoc />
 internal sealed override void Reconfigure(ElementNode node)
 {
     if (node != null)
     {
         if (node.Children.Count() > 0 && PreviewTools.GetLeafNodes(node).Count == 0)
         {
             StringType = StringTypes.Pixel;
             _strings   = new List <PreviewBaseShape>();
             foreach (ElementNode child in node.Children)
             {
                 int         pixelCount = child.Children.Count();
                 PreviewLine line       = new PreviewLine(new PreviewPoint(10, 10), new PreviewPoint(10, 10), pixelCount, child, ZoomLevel);
                 line.Parent = this;
                 _strings.Add(line);
             }
             _stringCount = _strings.Count;
             creating     = false;
         }
         else
         {
             StringType = StringTypes.Standard;
         }
     }
     Layout();
 }
Ejemplo n.º 3
0
        public PreviewPixelGrid(PreviewPoint point1, ElementNode selectedNode, double zoomLevel)
        {
            ZoomLevel    = zoomLevel;
            _topRight    = PointToZoomPoint(point1);
            _topLeft     = PointToZoomPoint(point1);
            _bottomRight = new PreviewPoint(_topLeft.X, _topLeft.Y);
            _bottomLeft  = new PreviewPoint(_bottomRight);

            int defaultStringCount     = 16;
            int defaultLightsPerString = 50;

            _strings = new List <PreviewBaseShape>();

            int childLightCount;

            if (IsPixelGridSelected(selectedNode, out childLightCount))
            {
                StringType = StringTypes.Pixel;
                foreach (ElementNode child in selectedNode.Children)
                {
                    PreviewLine line = new PreviewLine(new PreviewPoint(10, 10), new PreviewPoint(10, 10), childLightCount, child, ZoomLevel);
                    _strings.Add(line);
                }
                LightsPerString = childLightCount;
            }
            else if (IsStandardGridSelected(selectedNode))
            {
                StringType = StringTypes.Standard;
                foreach (ElementNode child in selectedNode.Children)
                {
                    PreviewLine line = new PreviewLine(new PreviewPoint(10, 10), new PreviewPoint(10, 10), defaultLightsPerString, child, ZoomLevel);
                    _strings.Add(line);
                }
            }
            else
            {
                // Just add the pixels, we don't care where they go... they get positioned in Layout()
                for (int stringNum = 0; stringNum < defaultStringCount; stringNum++)
                {
                    PreviewLine line = new PreviewLine(new PreviewPoint(10, 10), new PreviewPoint(10, 10), defaultLightsPerString, null, ZoomLevel);
                    _strings.Add(line);
                }
            }
            if (childLightCount == -1)
            {
                LightsPerString = defaultLightsPerString;
            }
            StringCount = _strings.Count();

            if (selectedNode.Properties.Contains(OrientationDescriptor._typeId))
            {
                var m = selectedNode.Properties.Get(OrientationDescriptor._typeId) as OrientationModule;
                if (m.Orientation == Orientation.Horizontal)
                {
                    _stringOrientation = StringOrientations.Horizontal;
                }
            }
            // Lay out the pixels
            Layout();
        }
Ejemplo n.º 4
0
        //const int InitialStringLength = 20;

        public PreviewIcicle(PreviewPoint point1, PreviewPoint point2, ElementNode selectedNode, double zoomLevel)
        {
            // If we are creating this fresh, we need to know so we can add strings, etc. as drawn.
            creating    = true;
            initialNode = selectedNode;

            ZoomLevel = zoomLevel;
            AddPoint(PointToZoomPoint(point1));
            AddPoint(PointToZoomPoint(point2));

            if (selectedNode != null)
            {
                if (selectedNode.Children.Count() > 0 && PreviewTools.GetLeafNodes(selectedNode).Count == 0)
                {
                    StringType = StringTypes.Pixel;
                    _strings   = new List <PreviewBaseShape>();
                    foreach (ElementNode child in selectedNode.Children)
                    {
                        int         pixelCount = child.Children.Count();
                        PreviewLine line       = new PreviewLine(new PreviewPoint(10, 10), new PreviewPoint(10, 10), pixelCount, child, ZoomLevel);
                        line.Parent = this;
                        _strings.Add(line);
                    }
                    _stringCount = _strings.Count;
                    creating     = false;
                }
                else
                {
                    StringType = StringTypes.Standard;
                }
            }
            Layout();
        }
Ejemplo n.º 5
0
        //const int InitialStringLength = 20;

		public PreviewIcicle(PreviewPoint point1, PreviewPoint point2, ElementNode selectedNode, double zoomLevel)
		{
            // If we are creating this fresh, we need to know so we can add strings, etc. as drawn.
            creating = true;
            initialNode = selectedNode;

			ZoomLevel = zoomLevel;
			AddPoint(PointToZoomPoint(point1));
			AddPoint(PointToZoomPoint(point2));

			if (selectedNode != null) {
				if (selectedNode.Children.Count() > 0 && PreviewTools.GetLeafNodes(selectedNode).Count == 0) 
				{
					StringType = StringTypes.Pixel;
                    _strings = new List<PreviewBaseShape>();
                    foreach (ElementNode child in selectedNode.Children)
                    {
                        int pixelCount = child.Children.Count();
                        PreviewLine line = new PreviewLine(new PreviewPoint(10, 10), new PreviewPoint(10, 10), pixelCount, child, ZoomLevel);
                        line.Parent = this;
                        _strings.Add(line);
                    }
                    _stringCount = _strings.Count;
                    creating = false;
				} else
                {
					StringType = StringTypes.Standard;
				}
			}
			Layout();
		}
Ejemplo n.º 6
0
 public override void Match(PreviewBaseShape matchShape)
 {
     PreviewLine shape = (matchShape as PreviewLine);
     PixelSize = shape.PixelSize;
     _points[1].X = _points[0].X + (shape._points[1].X - shape._points[0].X);
     _points[1].Y = _points[0].Y + (shape._points[1].Y - shape._points[0].Y);
     Layout();
 }
Ejemplo n.º 7
0
        /// <inheritdoc />
        internal sealed override void Reconfigure(ElementNode node)
        {
            _strings = new List <PreviewBaseShape>();
            _pixels.Clear();

            if (node != null)
            {
                List <ElementNode> children = PreviewTools.GetLeafNodes(node);
                if (children.Count >= 6)
                //
                {
                    int increment  = children.Count / 3;
                    int pixelsLeft = children.Count;

                    StringType = StringTypes.Pixel;

                    // Just add lines, they will be layed out in Layout()
                    for (int i = 0; i < 3; 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 < 3; 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();
        }
Ejemplo n.º 8
0
        public override void Layout()
        {
            if (_topLeft != null && _bottomRight != null)
            {
                if (Direction == Directions.CounterClockwise)
                {
                    // Start in the lower left corner and move counter clockwise around the rectangle.
                    PreviewLine line = Strings[0] as PreviewLine;
                    line.Point1 = BottomLeftPoint;
                    line.Point2 = BottomRightPoint;
                    line.Layout();

                    line = Strings[1] as PreviewLine;
                    var ySpacing = (BottomRightPoint.Y - TopRightPoint.Y) / (line.PixelCount + 1);

                    line.Point1 = new Point(BottomRightPoint.X, BottomRightPoint.Y - ySpacing);
                    line.Point2 = new Point(TopRightPoint.X, TopRightPoint.Y + ySpacing);
                    line.Layout();

                    line        = Strings[2] as PreviewLine;
                    line.Point1 = TopRightPoint;
                    line.Point2 = TopLeftPoint;
                    line.Layout();

                    line        = Strings[3] as PreviewLine;
                    line.Point1 = new Point(TopLeftPoint.X, TopLeftPoint.Y + ySpacing);
                    line.Point2 = new Point(BottomLeftPoint.X, BottomLeftPoint.Y - ySpacing);
                    line.Layout();
                }
                else
                {
                    // Start in the lower left corner and move clockwise around the rectangle.
                    PreviewLine line = Strings[0] as PreviewLine;
                    line.Point1 = BottomLeftPoint;
                    line.Point2 = TopLeftPoint;
                    line.Layout();

                    line = Strings[1] as PreviewLine;
                    var xSpacing = (TopRightPoint.X - TopLeftPoint.X) / (line.PixelCount + 1);
                    line.Point1 = new Point(TopLeftPoint.X + xSpacing, TopLeftPoint.Y);
                    line.Point2 = new Point(TopRightPoint.X - xSpacing, TopRightPoint.Y);
                    line.Layout();


                    line        = Strings[2] as PreviewLine;
                    line.Point1 = TopRightPoint;
                    line.Point2 = BottomRightPoint;
                    line.Layout();

                    line        = Strings[3] as PreviewLine;
                    line.Point1 = new Point(BottomRightPoint.X - xSpacing, BottomRightPoint.Y);
                    line.Point2 = new Point(BottomLeftPoint.X + xSpacing, BottomLeftPoint.Y);
                    line.Layout();
                }
            }
        }
Ejemplo n.º 9
0
		public PreviewTriangle(PreviewPoint point1, ElementNode selectedNode, double zoomLevel)
		{
			ZoomLevel = zoomLevel;
			_bottomRightPoint = PointToZoomPoint(point1);
			_point1 = new PreviewPoint(_bottomRightPoint);
			_point2 = new PreviewPoint(_bottomRightPoint);
			_point3 = new PreviewPoint(_bottomRightPoint);

			_strings = new List<PreviewBaseShape>();

			if (selectedNode != null) {
				List<ElementNode> children = PreviewTools.GetLeafNodes(selectedNode);
				if (children.Count >= 6)
                    //
				{
					int increment = children.Count/3;
					int pixelsLeft = children.Count;

					StringType = StringTypes.Pixel;

					// Just add lines, they will be layed out in Layout()
					for (int i = 0; i < 3; 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 < 3; 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();
		}
Ejemplo n.º 10
0
        public PreviewRectangle(PreviewPoint point1, ElementNode selectedNode)
        {
            _topLeft = point1;
            _topRight = new PreviewPoint(point1);
            _bottomLeft = new PreviewPoint(point1);
            _bottomRight = new PreviewPoint(point1);

            _strings = new List<PreviewBaseShape>();

            if (selectedNode != null) {
                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);
                        }
                        else {
                            line = new PreviewLine(new PreviewPoint(10, 10), new PreviewPoint(20, 20), pixelsLeft, null);
                        }
                        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);
                    line.PixelColor = Color.White;
                    _strings.Add(line);
                }
            }

            Layout();

            //DoResize += new ResizeEvent(OnResize);
        }
Ejemplo n.º 11
0
        /// <inheritdoc />
        internal sealed override void Reconfigure(ElementNode node)
        {
            int defaultStringCount     = 16;
            int defaultLightsPerString = 50;

            _strings = new List <PreviewBaseShape>();
            _pixels.Clear();

            int childLightCount;

            if (IsPixelGridSelected(node, out childLightCount))
            {
                StringType = StringTypes.Pixel;
                foreach (ElementNode child in node.Children)
                {
                    PreviewLine line = new PreviewLine(new PreviewPoint(10, 10), new PreviewPoint(10, 10), childLightCount, child, ZoomLevel);
                    _strings.Add(line);
                }
                LightsPerString = childLightCount;
            }
            else if (IsStandardGridSelected(node))
            {
                StringType = StringTypes.Standard;
                foreach (ElementNode child in node.Children)
                {
                    PreviewLine line = new PreviewLine(new PreviewPoint(10, 10), new PreviewPoint(10, 10), defaultLightsPerString, child, ZoomLevel);
                    _strings.Add(line);
                }
            }
            else
            {
                // Just add the pixels, we don't care where they go... they get positioned in Layout()
                for (int stringNum = 0; stringNum < defaultStringCount; stringNum++)
                {
                    PreviewLine line = new PreviewLine(new PreviewPoint(10, 10), new PreviewPoint(10, 10), defaultLightsPerString, null, ZoomLevel);
                    _strings.Add(line);
                }
            }
            if (childLightCount == -1)
            {
                LightsPerString = defaultLightsPerString;
            }
            StringCount = _strings.Count();

            if (node != null && node.Properties.Contains(OrientationDescriptor._typeId))
            {
                var m = node.Properties.Get(OrientationDescriptor._typeId) as OrientationModule;
                if (m.Orientation == Orientation.Horizontal)
                {
                    _stringOrientation = StringOrientations.Horizontal;
                }
            }
            // Lay out the pixels
            Layout();
        }
Ejemplo n.º 12
0
        public override object Clone()
        {
            PreviewLine newLine = (PreviewLine)this.MemberwiseClone();

            newLine._pixels = new List <PreviewPixel>();

            foreach (PreviewPixel pixel in _pixels)
            {
                newLine.AddPixel(pixel.X, pixel.Y);
            }
            return(newLine);
        }
Ejemplo n.º 13
0
        public PreviewMegaTree(PreviewPoint point1, ElementNode selectedNode)
        {
            _topLeft     = point1;
            _bottomRight = new PreviewPoint(_topLeft.X, _topLeft.Y);

            _stringCount     = 16;
            _topWidth        = 20;
            _topHeight       = _topWidth / 2;
            _baseHeight      = 40;
            _lightsPerString = 50;
            _degrees         = 360;

            _strings = new List <PreviewBaseShape>();

            int childLightCount;

            if (IsPixelTreeSelected(selectedNode, out childLightCount))
            {
                StringType       = StringTypes.Pixel;
                _lightsPerString = childLightCount;
                foreach (ElementNode child in selectedNode.Children)
                {
                    PreviewLine line = new PreviewLine(new PreviewPoint(10, 10), new PreviewPoint(10, 10), _lightsPerString, child);
                    _strings.Add(line);
                }
                _stringCount = _strings.Count;
            }
            else if (IsStandardTreeSelected(selectedNode))
            {
                StringType = StringTypes.Standard;
                foreach (ElementNode child in selectedNode.Children)
                {
                    PreviewLine line = new PreviewLine(new PreviewPoint(10, 10), new PreviewPoint(10, 10), _lightsPerString, child);
                    _strings.Add(line);
                }
                _stringCount = _strings.Count;
            }
            else
            {
                // Just add the pixels, we don't care where they go... they get positioned in Layout()
                for (int stringNum = 0; stringNum < _stringCount; stringNum++)
                {
                    PreviewLine line = new PreviewLine(new PreviewPoint(10, 10), new PreviewPoint(10, 10), _lightsPerString, null);
                    _strings.Add(line);
                }
            }

            // Lay out the pixels
            Layout();

            //DoResize += new ResizeEvent(OnResize);
        }
Ejemplo n.º 14
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();
        }
Ejemplo n.º 15
0
        public PreviewPixelGrid(PreviewPoint point1, ElementNode selectedNode, double zoomLevel)
        {
            ZoomLevel    = zoomLevel;
            _topRight    = PointToZoomPoint(point1);
            _topLeft     = PointToZoomPoint(point1);
            _bottomRight = new PreviewPoint(_topLeft.X, _topLeft.Y);
            _bottomLeft  = new PreviewPoint(_bottomRight);

            int defaultStringCount     = 16;
            int defaultLightsPerString = 50;

            _strings = new List <PreviewBaseShape>();

            int childLightCount;

            if (IsPixelGridSelected(selectedNode, out childLightCount))
            {
                StringType = StringTypes.Pixel;
                foreach (ElementNode child in selectedNode.Children)
                {
                    PreviewLine line = new PreviewLine(new PreviewPoint(10, 10), new PreviewPoint(10, 10), childLightCount, child, ZoomLevel);
                    _strings.Add(line);
                }
                LightsPerString = childLightCount;
            }
            else if (IsStandardGridSelected(selectedNode))
            {
                StringType = StringTypes.Standard;
                foreach (ElementNode child in selectedNode.Children)
                {
                    PreviewLine line = new PreviewLine(new PreviewPoint(10, 10), new PreviewPoint(10, 10), defaultLightsPerString, child, ZoomLevel);
                    _strings.Add(line);
                }
            }
            else
            {
                // Just add the pixels, we don't care where they go... they get positioned in Layout()
                for (int stringNum = 0; stringNum < defaultStringCount; stringNum++)
                {
                    PreviewLine line = new PreviewLine(new PreviewPoint(10, 10), new PreviewPoint(10, 10), defaultLightsPerString, null, ZoomLevel);
                    _strings.Add(line);
                }
            }

            StringCount = _strings.Count();

            // Lay out the pixels
            Layout();
        }
Ejemplo n.º 16
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();
        }
Ejemplo n.º 17
0
        public override void Layout()
        {
            if (_bottomRight != null && _topLeft != null)
            {
                int width  = _bottomRight.X - _topLeft.X;
                int height = _bottomRight.Y - _topLeft.Y;

                List <Point> _topEllipsePoints;
                List <Point> _baseEllipsePoints;

                double _topLeftOffset  = _topLeft.X + (width / 2) - (_topWidth / 2);
                double bottomTopOffset = _bottomRight.Y - _baseHeight;

                double totalStringsInEllipse = Math.Ceiling((360d / Convert.ToDouble(_degrees)) * Convert.ToDouble(StringCount));

                _topEllipsePoints = PreviewTools.GetEllipsePoints(_topLeftOffset,
                                                                  _topLeft.Y,
                                                                  _topWidth,
                                                                  _topHeight,
                                                                  totalStringsInEllipse,
                                                                  _degrees,
                                                                  0);
                _baseEllipsePoints = PreviewTools.GetEllipsePoints(_topLeft.X,
                                                                   bottomTopOffset,
                                                                   width,
                                                                   _baseHeight,
                                                                   totalStringsInEllipse,
                                                                   _degrees,
                                                                   0);

                for (int stringNum = 0; stringNum < (int)_stringCount; stringNum++)
                {
                    if (stringNum < StringCount && stringNum < _topEllipsePoints.Count())
                    {
                        Point topPixel  = _topEllipsePoints[_stringCount - 1 - stringNum];
                        Point basePixel = _baseEllipsePoints[_stringCount - 1 - stringNum];

                        PreviewLine line = _strings[stringNum] as PreviewLine;
                        line.SetPoint0(basePixel.X, basePixel.Y);
                        line.SetPoint1(topPixel.X, topPixel.Y);
                        line.Layout();
                    }
                }

                SetPixelZoom();
            }
        }
Ejemplo n.º 18
0
		public override object Clone()
		{
			PreviewLine newLine = (PreviewLine) this.MemberwiseClone();

			newLine._pixels = new List<PreviewPixel>();

			foreach (PreviewPixel pixel in _pixels) {
				newLine._pixels.Add(pixel.Clone());
			}

			newLine._points = new List<PreviewPoint>();
			foreach (var previewPoint in _points)
			{
				newLine._points.Add(previewPoint.Copy());
			}
			return newLine;
		}
Ejemplo n.º 19
0
        public PreviewPixelGrid(PreviewPoint point1, ElementNode selectedNode, double zoomLevel)
        {
            ZoomLevel = zoomLevel;
            _topRight = PointToZoomPoint(point1);
            _topLeft = PointToZoomPoint(point1);
            _bottomRight = new PreviewPoint(_topLeft.X, _topLeft.Y);
            _bottomLeft = new PreviewPoint(_bottomRight);

            int defaultStringCount = 16;
            int defaultLightsPerString = 50;

            _strings = new List<PreviewBaseShape>();

            int childLightCount;
            if (IsPixelGridSelected(selectedNode, out childLightCount)) {
                StringType = StringTypes.Pixel;
                foreach (ElementNode child in selectedNode.Children) {
                    PreviewLine line = new PreviewLine(new PreviewPoint(10, 10), new PreviewPoint(10, 10), childLightCount, child, ZoomLevel);
                    _strings.Add(line);
                }
                LightsPerString = childLightCount;
            }
            else if (IsStandardGridSelected(selectedNode)) {
                StringType = StringTypes.Standard;
                foreach (ElementNode child in selectedNode.Children) {
                    PreviewLine line = new PreviewLine(new PreviewPoint(10, 10), new PreviewPoint(10, 10), defaultLightsPerString, child, ZoomLevel);
                    _strings.Add(line);
                }
            }
            else {
                // Just add the pixels, we don't care where they go... they get positioned in Layout()
                for (int stringNum = 0; stringNum < defaultStringCount; stringNum++) {
                    PreviewLine line = new PreviewLine(new PreviewPoint(10, 10), new PreviewPoint(10, 10), defaultLightsPerString, null, ZoomLevel);
                    _strings.Add(line);
                }
            }
            if (childLightCount == -1)
            {
                LightsPerString = defaultLightsPerString;
            }
            StringCount = _strings.Count();

            // Lay out the pixels
            Layout();
        }
Ejemplo n.º 20
0
        public PreviewMegaTree(PreviewPoint point1, ElementNode selectedNode)
        {
            _topLeft = point1;
            _bottomRight = new PreviewPoint(_topLeft.X, _topLeft.Y);

            _stringCount = 16;
            _topWidth = 20;
            _topHeight = _topWidth/2;
            _baseHeight = 40;
            _lightsPerString = 50;
            _degrees = 360;

            _strings = new List<PreviewBaseShape>();

            int childLightCount;
            if (IsPixelTreeSelected(selectedNode, out childLightCount)) {
                StringType = StringTypes.Pixel;
                _lightsPerString = childLightCount;
                foreach (ElementNode child in selectedNode.Children) {
                    PreviewLine line = new PreviewLine(new PreviewPoint(10, 10), new PreviewPoint(10, 10), _lightsPerString, child);
                    _strings.Add(line);
                }
                _stringCount = _strings.Count;
            }
            else if (IsStandardTreeSelected(selectedNode)) {
                StringType = StringTypes.Standard;
                foreach (ElementNode child in selectedNode.Children) {
                    PreviewLine line = new PreviewLine(new PreviewPoint(10, 10), new PreviewPoint(10, 10), _lightsPerString, child);
                    _strings.Add(line);
                }
                _stringCount = _strings.Count;
            }
            else {
                // Just add the pixels, we don't care where they go... they get positioned in Layout()
                for (int stringNum = 0; stringNum < _stringCount; stringNum++) {
                    PreviewLine line = new PreviewLine(new PreviewPoint(10, 10), new PreviewPoint(10, 10), _lightsPerString, null);
                    _strings.Add(line);
                }
            }

            // Lay out the pixels
            Layout();

            //DoResize += new ResizeEvent(OnResize);
        }
Ejemplo n.º 21
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();
        }
Ejemplo n.º 22
0
        public override void Layout()
        {
            int width  = _bottomRight.X - _topLeft.X;
            int height = _bottomRight.Y - _topLeft.Y;

            List <Point> _topEllipsePoints;
            List <Point> _baseEllipsePoints;

            // First we'll get the top and bottom ellipses
            //double _topLeftOffset = _topLeft.X + (width / 2) - (_topWidth / 2);
            //_topEllipsePoints = PreviewTools.GetEllipsePoints(_topLeftOffset, _topLeft.Y, _topWidth, _topHeight, _stringCount, _degrees);
            //double bottomTopOffset = _bottomRight.Y - _baseHeight;
            //_baseEllipsePoints = PreviewTools.GetEllipsePoints(_topLeft.X, bottomTopOffset, width, _baseHeight, _stringCount, _degrees);
            double _topLeftOffset  = _topLeft.X + (width / 2) - (_topWidth / 2);
            double bottomTopOffset = _bottomRight.Y - _baseHeight;

            //if (_degrees < 360)
            //{
            //    _topEllipsePoints = PreviewTools.GetEllipsePoints(_topLeftOffset, _topLeft.Y, _topWidth, _topHeight, _stringCount+1, 360, 0);
            //    _baseEllipsePoints = PreviewTools.GetEllipsePoints(_topLeft.X, bottomTopOffset, width, _baseHeight, _stringCount+1, 360, 0);
            //}
            //else
            //{
            _topEllipsePoints  = PreviewTools.GetEllipsePoints(_topLeftOffset, _topLeft.Y, _topWidth, _topHeight, _stringCount, _degrees, 0);
            _baseEllipsePoints = PreviewTools.GetEllipsePoints(_topLeft.X, bottomTopOffset, width, _baseHeight, _stringCount, _degrees, 0);
            //}

            _stringsInDegrees = (double)_stringCount * ((double)_degrees / 360);

            for (int stringNum = 0; stringNum < (int)_stringCount; stringNum++)
            {
                if (stringNum < (int)_stringsInDegrees)
                {
                    Point topPixel  = _topEllipsePoints[stringNum];
                    Point basePixel = _baseEllipsePoints[stringNum];

                    PreviewLine line = _strings[stringNum] as PreviewLine;
                    line.SetPoint0(basePixel.X, basePixel.Y);
                    line.SetPoint1(topPixel.X, topPixel.Y);
                    line.Layout();
                }
            }
        }
Ejemplo n.º 23
0
        /// <inheritdoc />
        internal sealed override void Reconfigure(ElementNode node)
        {
            _stringCount     = 16;
            _lightsPerString = 50;
            _pixels.Clear();
            _strings = new List <PreviewBaseShape>();

            int childLightCount;

            if (IsPixelTreeSelected(node, out childLightCount))
            {
                StringType       = StringTypes.Pixel;
                _lightsPerString = childLightCount;
                foreach (ElementNode child in node.Children)
                {
                    PreviewLine line = new PreviewLine(new PreviewPoint(10, 10), new PreviewPoint(10, 10), _lightsPerString, child, ZoomLevel);
                    _strings.Add(line);
                }
                _stringCount = _strings.Count;
            }
            else if (IsStandardTreeSelected(node))
            {
                StringType = StringTypes.Standard;
                foreach (ElementNode child in node.Children)
                {
                    PreviewLine line = new PreviewLine(new PreviewPoint(10, 10), new PreviewPoint(10, 10), _lightsPerString, child, ZoomLevel);
                    _strings.Add(line);
                }
                _stringCount = _strings.Count;
            }
            else
            {
                // Just add the pixels, we don't care where they go... they get positioned in Layout()
                for (int stringNum = 0; stringNum < _stringCount; stringNum++)
                {
                    PreviewLine line = new PreviewLine(new PreviewPoint(10, 10), new PreviewPoint(10, 10), _lightsPerString, null, ZoomLevel);
                    _strings.Add(line);
                }
            }

            // Lay out the pixels
            Layout();
        }
Ejemplo n.º 24
0
 public override void Layout()
 {
     if (_bottomRight != null && _topLeft != null)
     {
         if (StringOrientation == StringOrientations.Vertical)
         {
             int    width          = _bottomRight.X - _topLeft.X;
             int    height         = _bottomRight.Y - _topLeft.Y;
             double stringXSpacing = (double)width / (double)(StringCount - 1);
             double x = _topLeft.X;
             int    y = _topLeft.Y;
             for (int stringNum = 0; stringNum < StringCount; stringNum++)
             {
                 PreviewLine line = _strings[stringNum] as PreviewLine;
                 var         x1   = (int)Math.Round(x, MidpointRounding.AwayFromZero);
                 line.SetPoint0(x1, y + height);
                 line.SetPoint1(x1, y);
                 line.Layout();
                 x += stringXSpacing;
             }
         }
         else
         {
             int    width          = _bottomRight.X - _bottomLeft.X;
             int    height         = _bottomLeft.Y - _topLeft.Y;
             double stringYSpacing = height / (double)(StringCount - 1);
             int    x = _bottomLeft.X;
             double y = _bottomLeft.Y;
             for (int stringNum = 0; stringNum < StringCount; stringNum++)
             {
                 PreviewLine line = _strings[stringNum] as PreviewLine;
                 var         y1   = (int)Math.Round(y, MidpointRounding.AwayFromZero);
                 line.SetPoint0(x, y1);
                 line.SetPoint1((x + width), y1);
                 line.Layout();
                 y -= stringYSpacing;
             }
         }
         SetPixelZoom();
     }
 }
Ejemplo n.º 25
0
        public PreviewTriangle(PreviewPoint point1, ElementNode selectedNode, double zoomLevel)
        {
            ZoomLevel         = zoomLevel;
            _bottomRightPoint = PointToZoomPoint(point1);
            _point1           = new PreviewPoint(_bottomRightPoint);
            _point2           = new PreviewPoint(_bottomRightPoint);
            _point3           = new PreviewPoint(_bottomRightPoint);

            _strings = new List <PreviewBaseShape>();

            if (selectedNode != null)
            {
                List <ElementNode> children = PreviewTools.GetLeafNodes(selectedNode);
                if (children.Count >= 6)
                //
                {
                    int increment  = children.Count / 3;
                    int pixelsLeft = children.Count;

                    StringType = StringTypes.Pixel;

                    // Just add lines, they will be layed out in Layout()
                    for (int i = 0; i < 3; 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 < 3; 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();
        }
Ejemplo n.º 26
0
        public PreviewRectangle(PreviewPoint point1, ElementNode selectedNode)
        {
            _topLeft     = point1;
            _topRight    = new PreviewPoint(point1);
            _bottomLeft  = new PreviewPoint(point1);
            _bottomRight = new PreviewPoint(point1);

            _strings = new List <PreviewBaseShape>();

            if (selectedNode != null)
            {
                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);
                        }
                        else
                        {
                            line = new PreviewLine(new PreviewPoint(10, 10), new PreviewPoint(20, 20), pixelsLeft, null);
                        }
                        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);
                    line.PixelColor = Color.White;
                    _strings.Add(line);
                }
            }

            Layout();

            //DoResize += new ResizeEvent(OnResize);
        }
Ejemplo n.º 27
0
        public override void Layout()
        {
            //int width = _bottomRight.X - _topLeft.X;
            //int height = _bottomRight.Y - _topLeft.Y;

            //List<Point> _topEllipsePoints;
            //List<Point> _baseEllipsePoints;

            //double _topLeftOffset = _topLeft.X + (width/2) - (_topWidth/2);
            //double bottomTopOffset = _bottomRight.Y - _baseHeight;

            //_topEllipsePoints = PreviewTools.GetEllipsePoints(_topLeftOffset, _topLeft.Y, _topWidth, _topHeight, _stringCount,
            //                                                  _degrees, 0);
            //_baseEllipsePoints = PreviewTools.GetEllipsePoints(_topLeft.X, bottomTopOffset, width, _baseHeight, _stringCount,
            //                                                   _degrees, 0);

            //_stringsInDegrees = (double) _stringCount*((double) _degrees/360);

            //for (int stringNum = 0; stringNum < (int) _stringCount; stringNum++) {
            //    if (stringNum < (int) _stringsInDegrees) {
            //        if (stringNum < _topEllipsePoints.Count()) {
            //            Point topPixel = _topEllipsePoints[stringNum];
            //            Point basePixel = _baseEllipsePoints[stringNum];

            //            PreviewLine line = _strings[stringNum] as PreviewLine;
            //            line.SetPoint0(basePixel.X, basePixel.Y);
            //            line.SetPoint1(topPixel.X, topPixel.Y);
            //            line.Layout();
            //        }
            //    }
            //}

            // DB: Added 8/4/2013
            int width  = _bottomRight.X - _topLeft.X;
            int height = _bottomRight.Y - _topLeft.Y;

            List <Point> _topEllipsePoints;
            List <Point> _baseEllipsePoints;

            double _topLeftOffset  = _topLeft.X + (width / 2) - (_topWidth / 2);
            double bottomTopOffset = _bottomRight.Y - _baseHeight;

            double totalStringsInEllipse = Math.Ceiling((360d / Convert.ToDouble(_degrees)) * Convert.ToDouble(StringCount));

            _topEllipsePoints = PreviewTools.GetEllipsePoints(_topLeftOffset,
                                                              _topLeft.Y,
                                                              _topWidth,
                                                              _topHeight,
                                                              totalStringsInEllipse,
                                                              _degrees,
                                                              0);
            _baseEllipsePoints = PreviewTools.GetEllipsePoints(_topLeft.X,
                                                               bottomTopOffset,
                                                               width,
                                                               _baseHeight,
                                                               totalStringsInEllipse,
                                                               _degrees,
                                                               0);

            for (int stringNum = 0; stringNum < (int)_stringCount; stringNum++)
            {
                if (stringNum < StringCount && stringNum < _topEllipsePoints.Count())
                {
                    Point topPixel  = _topEllipsePoints[_stringCount - 1 - stringNum];
                    Point basePixel = _baseEllipsePoints[_stringCount - 1 - stringNum];
                    //Console.WriteLine("topPixel " + topPixel.ToString() + ", basePixel " + basePixel.ToString());

                    PreviewLine line = _strings[stringNum] as PreviewLine;
                    line.SetPoint0(basePixel.X, basePixel.Y);
                    line.SetPoint1(topPixel.X, topPixel.Y);
                    line.Layout();
                }
            }
        }
Ejemplo n.º 28
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();
        }
Ejemplo n.º 29
0
        private void CreateString()
        {
            if (Creating)
            {
                // There is no ElementNode selected in the tree
                if (inputElements == null)
                {
                    StringCount++;
                }
                // We've got an ElementNode selected in the tree, now figure out what to do with it.
                else
                {
                    int inputStringCount = 0;
                    int inputPixelCount  = 0;
                    PreviewTools.CountPixelsAndStrings(inputElements, out inputPixelCount, out inputStringCount);
                    int stringNum = _strings.Count();

                    // is this a single node with no children?
                    if (inputPixelCount == 0 && inputStringCount == 0)
                    {
                        PreviewLine line = new PreviewLine(new PreviewPoint(10, 10), new PreviewPoint(10, 10), 10, inputElements, ZoomLevel);
                        line.Parent = this;
                        _strings.Add(line);
                        _stringCount = _strings.Count();
                    }
                    // If we're here, we've got a group selected
                    else
                    {
                        // Do we have multiple child strings in this group and no individual pixels selected?
                        if (stringNum <= inputStringCount - 1 && inputPixelCount == 0)
                        {
                            StringType = StringTypes.Pixel;

                            ElementNode child = null;
                            if (inputStringCount > 0)
                            {
                                child = inputElements.Children.ToList()[stringNum];
                            }
                            else
                            {
                                child = inputElements;
                            }
                            int         pixelCount = child.Count();
                            PreviewLine line       = new PreviewLine(new PreviewPoint(10, 10), new PreviewPoint(10, 10), child.Count(), child, ZoomLevel);
                            line.Parent = this;
                            _strings.Add(line);
                            _stringCount = _strings.Count();
                        }
                        // If we're here, we have multiple pixels in a single string and no strings in our parent node
                        else if (inputPixelCount > 2 && inputStringCount == 0 && stringNum == 0)
                        {
                            StringType = StringTypes.Pixel;
                            PreviewLine line = new PreviewLine(new PreviewPoint(10, 10), new PreviewPoint(10, 10), inputElements.Count(), inputElements, ZoomLevel);
                            line.Parent = this;
                            _strings.Add(line);
                            _stringCount = _strings.Count();
                        }
                        // If we get here, there is nothing valid selected so add a string and move on
                        else
                        {
                            PreviewLine line = new PreviewLine(new PreviewPoint(10, 10), new PreviewPoint(10, 10), 10, null, ZoomLevel);
                            line.StringType = StringType;
                            line.Parent     = this;
                            _strings.Add(line);
                            _stringCount = _strings.Count();
                        }
                    }
                }
            }
        }
Ejemplo n.º 30
0
        private void SetupLine(bool horizontal)
        {
            preview.Data = new VixenPreviewData();
            preview.LoadBackground();
            preview.BackgroundAlpha = 0;
            displayItem = new DisplayItem();
            PreviewPoint p1, p2;
            if (horizontal) {
                p1 = new PreviewPoint(10, preview.Height/2);
                p2 = new PreviewPoint(preview.Width - 10, preview.Height/2);
            }
            else {
                p1 = new PreviewPoint(preview.Width/2, preview.Height - 10);
                p2 = new PreviewPoint(preview.Width/2, 10);
            }
            PreviewLine line = new PreviewLine(p1, p2, PixelsPerString(), null, 1);

            line.PixelCount = PixelsPerString();
            line.PixelSize = Data.PixelSize;
            line.PixelColor = Color.White;
            line.Layout();
            displayItem.Shape = line;

            preview.AddDisplayItem(displayItem);
        }
Ejemplo n.º 31
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();
        }
Ejemplo n.º 32
0
        private void CreateString()
        {
            if (Creating)
            {
                // There is no ElementNode selected in the tree
                if (inputElements == null)
                {
                    StringCount++;
                }
                // We've got an ElementNode selected in the tree, now figure out what to do with it.
                else
                {
                    int inputStringCount = 0;
                    int inputPixelCount = 0;
                    PreviewTools.CountPixelsAndStrings(inputElements, out inputPixelCount, out inputStringCount);
                    int stringNum = _strings.Count();

                    // is this a single node with no children?
                    if (inputPixelCount == 0 && inputStringCount == 0)
                    {
                        PreviewLine line = new PreviewLine(new PreviewPoint(10, 10), new PreviewPoint(10, 10), 10, inputElements, ZoomLevel);
                        line.Parent = this;
                        _strings.Add(line);
                        _stringCount = _strings.Count();
                    }
                    // If we're here, we've got a group selected
                    else
                    {
                        // Do we have multiple child strings in this group and no individual pixels selected?
                        if (stringNum <= inputStringCount - 1 && inputPixelCount == 0)
                        {
                            StringType = StringTypes.Pixel;

                            ElementNode child = null;
                            if (inputStringCount > 0)
                            {
                                child = inputElements.Children.ToList()[stringNum];
                            }
                            else
                            {
                                child = inputElements;
                            }
                            int pixelCount = child.Count();
                            PreviewLine line = new PreviewLine(new PreviewPoint(10, 10), new PreviewPoint(10, 10), child.Count(), child, ZoomLevel);
                            line.Parent = this;
                            _strings.Add(line);
                            _stringCount = _strings.Count();
                        }
                        // If we're here, we have multiple pixels in a single string and no strings in our parent node
                        else if (inputPixelCount > 2 && inputStringCount == 0 && stringNum == 0)
                        {
                            StringType = StringTypes.Pixel;
                            PreviewLine line = new PreviewLine(new PreviewPoint(10, 10), new PreviewPoint(10, 10), inputElements.Count(), inputElements, ZoomLevel);
                            line.Parent = this;
                            _strings.Add(line);
                            _stringCount = _strings.Count();
                        }
                        // If we get here, there is nothing valid selected so add a string and move on
                        else
                        {
                            PreviewLine line = new PreviewLine(new PreviewPoint(10, 10), new PreviewPoint(10, 10), 10, null, ZoomLevel);
                            line.StringType = StringType;
                            line.Parent = this;
                            _strings.Add(line);
                            _stringCount = _strings.Count();
                        }
                    }
                }
            }
        }
Ejemplo n.º 33
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();
        }