/// <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(); }
public PreviewArch(PreviewPoint point1, ElementNode selectedNode, double zoomLevel) { ZoomLevel = zoomLevel; TopLeft = PointToZoomPoint(point1).ToPoint(); BottomRight = new PreviewPoint(_topLeft.X, _topLeft.Y).ToPoint(); int lightCount = 25; if (selectedNode != null) { List <ElementNode> children = PreviewTools.GetLeafNodes(selectedNode); // is this a single node? if (children.Count >= 4) { StringType = StringTypes.Pixel; lightCount = children.Count; // Just add the pixels, they will get layed out next foreach (ElementNode child in children) { { PreviewPixel pixel = AddPixel(10, 10); pixel.Node = child; pixel.PixelColor = Color.White; } } } } if (_pixels.Count == 0) { // Just add the pixels, they will get layed out next for (int lightNum = 0; lightNum < lightCount; lightNum++) { PreviewPixel pixel = AddPixel(10, 10); pixel.PixelColor = Color.White; if (selectedNode != null && selectedNode.IsLeaf) { pixel.Node = selectedNode; } } } // Lay out the pixels Layout(); }
public PreviewStar(PreviewPoint point, ElementNode selectedNode, double zoomLevel) { ZoomLevel = zoomLevel; _topLeftPoint = PointToZoomPoint(point); _bottomRightPoint = PointToZoomPoint(point); _pixelCount = 40; _pointCount = 5; _insideSize = 40; if (selectedNode != null) { List <ElementNode> children = PreviewTools.GetLeafNodes(selectedNode); // is this a single node? if (children.Count >= 10) { StringType = StringTypes.Pixel; // Just add the pixels, they will get layed out next foreach (ElementNode child in children) { PreviewPixel pixel = AddPixel(10, 10); pixel.Node = child; pixel.PixelColor = Color.White; } _pixelCount = children.Count; } } if (_pixels.Count == 0) { // Just add the pixels, they will get layed out next for (int lightNum = 0; lightNum < _pixelCount; lightNum++) { PreviewPixel pixel = AddPixel(10, 10); pixel.PixelColor = Color.White; if (selectedNode != null && selectedNode.IsLeaf) { pixel.Node = selectedNode; } } } // Lay out the pixels Layout(); }
/// <inheritdoc /> internal sealed override void Reconfigure(ElementNode node) { _pixels.Clear(); if (node != null) { List<ElementNode> children = PreviewTools.GetLeafNodes(node); // is this a single node? if (children.Count == 0) { StringType = StringTypes.Standard; // Just add the pixels, they will get layed out next for (int lightNum = 0; lightNum < _lightCount; lightNum++) { PreviewPixel pixel = AddPixel(10, 10); pixel.PixelColor = Color.White; if (node.IsLeaf) pixel.Node = node; } } else { StringType = StringTypes.Pixel; // Just add the pixels, they will get layed out next foreach (ElementNode child in children) { PreviewPixel pixel = AddPixel(10, 10); pixel.Node = child; pixel.NodeId = child.Id; pixel.PixelColor = Color.White; } } } else { // Just add the pixels, they will get layed out next for (int lightNum = 0; lightNum < _lightCount; lightNum++) { //Console.WriteLine("Added: " + lightNum.ToString()); PreviewPixel pixel = AddPixel(10, 10); pixel.PixelColor = Color.White; } } // Lay out the pixels Layout(); }
public override void Layout() { if (_bottomRight != null && _topLeft != null) { int width = _bottomRight.X - _topLeft.X; int height = _bottomRight.Y - _topLeft.Y; List <Point> points; points = PreviewTools.GetEllipsePoints(0, 0, width, height, PixelCount, 360, 0); int pointNum = 0; foreach (PreviewPixel pixel in _pixels) { pixel.X = points[pointNum].X + _topLeft.X; pixel.Y = points[pointNum].Y + _topLeft.Y; pointNum++; } //Skew(); } }
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(); } } }
public override void Layout() { if (BottomRight != null && TopLeft != null) { int width = BottomRight.X - TopLeft.X; int height = BottomRight.Y - TopLeft.Y; List <Point> points; points = PreviewTools.GetArcPoints(width, height, PixelCount); int pointNum = 0; foreach (PreviewPixel pixel in _pixels) { pixel.X = points[pointNum].X + TopLeft.X; pixel.Y = points[pointNum].Y + TopLeft.Y; pointNum++; } SetPixelZoom(); } }
/// <inheritdoc /> internal sealed override void Reconfigure(ElementNode node) { _pixels.Clear(); var lightCount = 25; if (node != null) { List <ElementNode> children = PreviewTools.GetLeafNodes(node); // is this a single node? if (children.Count >= 4) { StringType = StringTypes.Pixel; lightCount = children.Count; // Just add the pixels, they will get laid out next foreach (ElementNode child in children) { { PreviewPixel pixel = AddPixel(10, 10); pixel.Node = child; pixel.PixelColor = Color.White; } } } } if (_pixels.Count == 0) { // Just add the pixels, they will get laid out next for (int lightNum = 0; lightNum < lightCount; lightNum++) { PreviewPixel pixel = AddPixel(10, 10); pixel.PixelColor = Color.White; if (node != null && node.IsLeaf) { pixel.Node = node; } } } // Lay out the pixels Layout(); }
public override void Layout() { int width = _bottomRight.X - _topLeft.X; int height = _bottomRight.Y - _topLeft.Y; List <Point> points; points = PreviewTools.GetArcPoints(width, height, PixelCount); //points = PreviewTools.GetEllipsePoints(0, 0, width/2, height/2, PixelCount*2, 180); int pointNum = 0; foreach (PreviewPixel pixel in _pixels) { //if (pointNum < points.Count) //{ pixel.X = points[pointNum].X + _topLeft.X; pixel.Y = points[pointNum].Y + _topLeft.Y; pointNum++; //} } }
/// <inheritdoc /> internal sealed override void Reconfigure(ElementNode node) { _archPixelCount = 8; _linePixelCount = 8; _pixels.Clear(); int lightCount = _archPixelCount + _linePixelCount; if (node != null) { List <ElementNode> children = PreviewTools.GetLeafNodes(node); // is this a single node? if (children.Count >= 8) { StringType = StringTypes.Pixel; _archPixelCount = children.Count / 2; _linePixelCount = children.Count - _archPixelCount; if (_archPixelCount + _linePixelCount > children.Count) { _archPixelCount -= 1; } else if (_archPixelCount + _linePixelCount < children.Count) { _linePixelCount -= 1; } lightCount = children.Count; // Just add the pixels, they will get layed out next foreach (ElementNode child in children) { PreviewPixel pixel = AddPixel(10, 10); pixel.Node = child; pixel.PixelColor = Color.White; } } } AddPixels(node, lightCount); // Lay out the pixels Layout(); }
public override void Layout() { double pixelSpacing = (double)(_bottomRightPoint.Y - _archLeftPoint.Y) / (double)_linePixelCount; for (int i = 0; i < _linePixelCount; i++) { PreviewPixel pixel = _pixels[i]; pixel.X = _topLeftPoint.X; pixel.Y = _bottomRightPoint.Y - (int)(i * pixelSpacing);; } int arcWidth = _bottomRightPoint.X - _topLeftPoint.X; int arcHeight = _archLeftPoint.Y - _topLeftPoint.Y; List <Point> points = PreviewTools.GetArcPoints(arcWidth, arcHeight, _archPixelCount); for (int i = 0; i < points.Count; i++) { PreviewPixel pixel = _pixels[i + _linePixelCount]; pixel.X = points[i].X + _topLeftPoint.X; pixel.Y = points[i].Y + _topLeftPoint.Y; } }
public override void Layout() { if (_topLeft != null && _bottomRight != null) { _topRight.X = _bottomRight.X; _topRight.Y = _topLeft.Y; _bottomLeft.X = _topLeft.X; _bottomLeft.Y = _bottomRight.Y; int width = Math.Abs(_bottomRight.X - _topLeft.X); int height = Math.Abs(_bottomRight.Y - _topLeft.Y); int centerX = Right - (width / 2); int centerY = Bottom - (height / 2); List <Point> outerEllipse = PreviewTools.GetEllipsePoints(_topLeft.X, _topLeft.Y, width, height, Strings.Count, 360, XYRotation); List <Point> innerEllipse = PreviewTools.GetEllipsePoints(centerX - (InnerCircleSize / 2), centerY - (InnerCircleSize / 2), InnerCircleSize, InnerCircleSize, Strings.Count, 360, XYRotation); int pointNum = 0; foreach (PreviewLine line in Strings) { line.Point1 = innerEllipse[pointNum]; line.Point2 = outerEllipse[pointNum]; pointNum++; } SetPixelZoom(); } }
private double SegmentLength(int segmentNum) { // Get the length of just this line double thisLineLength = 0; // Is this a horizontal line? if (_points[segmentNum].X == _points[segmentNum + 1].X) { thisLineLength = Math.Abs(_points[segmentNum].Y - _points[segmentNum + 1].Y); } // Is this a vertical line? else if (_points[segmentNum].Y == _points[segmentNum + 1].Y) { thisLineLength = Math.Abs(_points[segmentNum].X - _points[segmentNum + 1].X); } else { // Find the length of the Hypotenuse of the right triangle double a = Math.Abs(_points[segmentNum].X - _points[segmentNum + 1].X); double b = Math.Abs(_points[segmentNum].Y - _points[segmentNum + 1].Y); thisLineLength = PreviewTools.TriangleHypotenuse(a, b); } return(thisLineLength); }
public override void Layout() { if (_topLeftPoint != null && _bottomRightPoint != null) { if (Width > 10 && Height > 10) { RecalcPoints(); int outerWidth = _bottomRightPoint.X - _topLeftPoint.X; int outerHeight = _bottomRightPoint.Y - _topLeftPoint.Y; List <Point> outerEllipse = PreviewTools.GetEllipsePoints(_topLeftPoint.X, _topLeftPoint.Y, outerWidth, outerHeight, _pointCount, 360, XYRotation); int innerWidth = (int)(outerWidth * _insideSize * .01); if (innerWidth < 4) { innerWidth = 4; } int innerHeight = (int)(outerHeight * _insideSize * .01); if (innerHeight < 4) { innerHeight = 4; } int degreeOffset = 360 / _pointCount / 2; int widthOffset = ((outerWidth - innerWidth) / 2); int heightOffset = ((outerHeight - innerHeight) / 2); int innerLeft = _topLeftPoint.X + widthOffset; int innerTop = _topLeftPoint.Y + heightOffset; List <Point> innerEllipse = PreviewTools.GetEllipsePoints(innerLeft, innerTop, innerWidth, innerHeight, _pointCount, 360, degreeOffset + XYRotation); int pixelNum = 0; for (int ellipsePointNum = 0; ellipsePointNum < _pointCount; ellipsePointNum++) { Point point1 = outerEllipse[ellipsePointNum]; Point point2 = innerEllipse[ellipsePointNum]; Point point3; if (ellipsePointNum < _pointCount - 1) { point3 = outerEllipse[ellipsePointNum + 1]; } else { point3 = outerEllipse[0]; } int line1PixelCount = (int)(pixelsPerPoint / 2); int line2PixelCount = line1PixelCount - 1; if (line1PixelCount + line2PixelCount < pixelsPerPoint) { line1PixelCount++; } double xSpacing = (double)(point1.X - point2.X) / (double)(line1PixelCount - 1); double ySpacing = (double)(point1.Y - point2.Y) / (double)(line1PixelCount - 1); double x = point1.X; double y = point1.Y; for (int linePointNum = 0; linePointNum < line1PixelCount; linePointNum++) { if (pixelNum < _pixelCount) { _pixels[pixelNum].X = (int)Math.Round(x); _pixels[pixelNum].Y = (int)Math.Round(y); x -= xSpacing; y -= ySpacing; } else { Console.WriteLine("pixelNum Overrun 1: " + pixelNum); } pixelNum++; } xSpacing = (double)(point2.X - point3.X) / (double)(line1PixelCount - 1); ySpacing = (double)(point2.Y - point3.Y) / (double)(line1PixelCount - 1); x = point2.X - xSpacing; y = point2.Y - ySpacing; for (int linePointNum = 0; linePointNum < line2PixelCount; linePointNum++) { if (pixelNum < _pixelCount) { _pixels[pixelNum].X = (int)Math.Round(x); _pixels[pixelNum].Y = (int)Math.Round(y); x -= xSpacing; y -= ySpacing; } else { Console.WriteLine("pixelNum Overrun 2: " + pixelNum); } pixelNum++; } } SetPixelZoom(); } } }
private void PreviewSetElements_Load(object sender, EventArgs e) { PreviewTools.PopulateElementTree(treeElements); PopulateStringList(); UpdateListLinkedElements(); }
public override void Layout() { if (_points != null && _points.Count > 0) { double lineLength = LineLength; int currentPixelNum = 0; if (lineLength > 0) { // Tracks the spacing between each of the pixels without worrying about the points. double currentEmptySpace = 0; // Length of the entire segment for (int pointNum = 0; pointNum < _points.Count - 1; pointNum++) { double thisFullLineLength = SegmentLength(pointNum); // First pixel is a special case if (currentEmptySpace + thisFullLineLength > PixelSpacing || pointNum == 0) { double thisEmptyStartLength = PixelSpacing - currentEmptySpace;; if (pointNum == 0) { thisEmptyStartLength = 0; } // Active length of the segment without the start double thisActiveLineLength = thisFullLineLength - thisEmptyStartLength; // Get the pixels in this line. No hangers on the end. double pixelSpacesInThisLine = Math.Truncate(thisActiveLineLength / PixelSpacing); //if (pixelSpacesInThisLine < 0) pixelSpacesInThisLine = 0; double pixelsInThisLine = pixelSpacesInThisLine + 1; // Re-calcuate the active line length thisActiveLineLength = pixelSpacesInThisLine * PixelSpacing; currentEmptySpace = thisFullLineLength - thisEmptyStartLength - thisActiveLineLength; Point lineStartPoint = PreviewTools.CalculatePointOnLine( new PreviewTools.Vector2(_points[pointNum].ToPoint()), new PreviewTools.Vector2(_points[pointNum + 1].ToPoint()), Convert.ToInt32(thisEmptyStartLength)); Point lineEndPoint = PreviewTools.CalculatePointOnLine( new PreviewTools.Vector2(_points[pointNum].ToPoint()), new PreviewTools.Vector2(_points[pointNum + 1].ToPoint()), Convert.ToInt32(thisEmptyStartLength + thisActiveLineLength)); double xSpacing = (double)(lineStartPoint.X - lineEndPoint.X) / (double)(pixelSpacesInThisLine); double ySpacing = (double)(lineStartPoint.Y - lineEndPoint.Y) / (double)(pixelSpacesInThisLine); double x = lineStartPoint.X; double y = lineStartPoint.Y; for (int pixelNum = 0; pixelNum < pixelsInThisLine; pixelNum++) { if (currentPixelNum < Pixels.Count - 1) { Pixels[currentPixelNum].X = Convert.ToInt32(x); Pixels[currentPixelNum].Y = Convert.ToInt32(y); x -= xSpacing; y -= ySpacing; } currentPixelNum++; } double a1 = _points[pointNum + 1].X - x; double b1 = _points[pointNum + 1].Y - y; } else { currentEmptySpace += thisFullLineLength; } // Finally, put the last dot on the line Pixels[PixelCount - 1].X = _points[_points.Count - 1].X; Pixels[PixelCount - 1].Y = _points[_points.Count - 1].Y; } } SetPixelZoom(); } }
public PreviewCane(PreviewPoint point, ElementNode selectedNode) { _topLeftPoint = point; _bottomRightPoint = new PreviewPoint(point.X, point.Y); _archLeftPoint = new PreviewPoint(point.X, point.Y); _archPixelCount = 8; _linePixelCount = 8; int lightCount = _archPixelCount + _linePixelCount; if (selectedNode != null) { //List<ElementNode> children = selectedNode.Children.ToList(); List <ElementNode> children = PreviewTools.GetLeafNodes(selectedNode); // is this a single node? if (children.Count >= 8) { StringType = StringTypes.Pixel; _archPixelCount = children.Count / 2; _linePixelCount = children.Count / 2; if (_archPixelCount + _linePixelCount > children.Count) { _archPixelCount -= 1; } else if (_archPixelCount + _linePixelCount < children.Count) { _linePixelCount -= 1; } lightCount = children.Count; // Just add the pixels, they will get layed out next foreach (ElementNode child in children) { PreviewPixel pixel = AddPixel(10, 10); pixel.Node = child; //pixel.NodeId = child.Id; pixel.PixelColor = Color.White; } } } if (_pixels.Count == 0) { // Just add the pixels, they will get layed out next for (int lightNum = 0; lightNum < lightCount; lightNum++) { PreviewPixel pixel = AddPixel(10, 10); pixel.PixelColor = Color.White; if (selectedNode != null && selectedNode.IsLeaf) { pixel.Node = selectedNode; //pixel.NodeId = selectedNode.Id; } } } // Lay out the pixels Layout(); //DoResize += new ResizeEvent(OnResize); }
/// <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(); }
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(); } } } } }
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(); } } }
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(); }
public override void Layout() { if (_topLeftPoint != null && _bottomRightPoint != null) { if (Width > 10 && Height > 10) { RecalcPoints(); int outerWidth = _bottomRightPoint.X - _topLeftPoint.X; int outerHeight = _bottomRightPoint.Y - _topLeftPoint.Y; int degreeOffset = 360 / _pointCount / 2; List <Point> outerEllipse = PreviewTools.GetEllipsePoints(_topLeftPoint.X, _topLeftPoint.Y, outerWidth, outerHeight, _pointCount, 360, degreeOffset + XYRotation); int innerWidth = (int)(outerWidth * _insideSize * .01); if (innerWidth < 4) { innerWidth = 4; } int innerHeight = (int)(outerHeight * _insideSize * .01); if (innerHeight < 4) { innerHeight = 4; } int widthOffset = ((outerWidth - innerWidth) / 2); int heightOffset = ((outerHeight - innerHeight) / 2); int innerLeft = _topLeftPoint.X + widthOffset; int innerTop = _topLeftPoint.Y + heightOffset; int rot = XYRotation; //if (StringDirection == StringDirections.CounterClockwise) // rot = -rot; List <Point> innerEllipse = PreviewTools.GetEllipsePoints(innerLeft, innerTop, innerWidth, innerHeight, _pointCount, 360, rot); int pixelNum = 0; for (int i = 0; i < _pointCount; i++) { Point point1; Point point2; Point point3; var ellipsePointNum = 0; if (StringDirection == StringDirections.Clockwise) { ellipsePointNum = i; point1 = innerEllipse[ellipsePointNum]; point2 = outerEllipse[ellipsePointNum]; if (ellipsePointNum < _pointCount - 1) { point3 = innerEllipse[ellipsePointNum + 1]; } else { point3 = innerEllipse[0]; } } else { ellipsePointNum = (_pointCount) - i; point1 = innerEllipse[ellipsePointNum]; if (ellipsePointNum > 0) { point2 = outerEllipse[ellipsePointNum - 1]; point3 = innerEllipse[ellipsePointNum - 1]; } else { point2 = outerEllipse[_pointCount - 1]; point3 = innerEllipse[_pointCount - 1]; } } var line1PixelCount = pixelsPerPoint / 2d; var line2PixelCount = line1PixelCount; if (line1PixelCount + line2PixelCount < pixelsPerPoint) { line1PixelCount++; } double xSpacing = (point1.X - point2.X) / line1PixelCount; double ySpacing = (point1.Y - point2.Y) / line1PixelCount; double x = point1.X; double y = point1.Y; for (int linePointNum = 0; linePointNum < line1PixelCount; linePointNum++) { if (pixelNum < _pixelCount && pixelNum < _pixels.Count) { _pixels[pixelNum].X = (int)Math.Round(x); _pixels[pixelNum].Y = (int)Math.Round(y); x -= xSpacing; y -= ySpacing; } else { Logging.Error("pixelNum Overrun 1: " + pixelNum); } pixelNum++; } xSpacing = (point2.X - point3.X) / line2PixelCount; ySpacing = (point2.Y - point3.Y) / line2PixelCount; x = point2.X; y = point2.Y; for (int linePointNum = 0; linePointNum < line2PixelCount; linePointNum++) { if (pixelNum < _pixelCount && pixelNum < _pixels.Count) { _pixels[pixelNum].X = (int)Math.Round(x); _pixels[pixelNum].Y = (int)Math.Round(y); x -= xSpacing; y -= ySpacing; } else { Logging.Error("pixelNum Overrun 2: " + pixelNum); } pixelNum++; } } SetPixelZoom(); } } }
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(); }
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); }
private void buttonHelp_Click(object sender, EventArgs e) { PreviewTools.ShowHelp(Properties.Settings.Default.Help_LinkElements); }