public override void Layout() { if (_topLeft != null && _bottomRight != null) { int width = Math.Abs(_topRight.X - _topLeft.X); int height = Math.Abs(_bottomLeft.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(); } }
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, _degreeOffset); _baseEllipsePoints = PreviewTools.GetEllipsePoints(_topLeft.X, bottomTopOffset, width, _baseHeight, totalStringsInEllipse, _degrees, _degreeOffset); for (int stringNum = 0; stringNum < (int)_stringCount; stringNum++) { if (stringNum < StringCount && stringNum < _topEllipsePoints.Count()) { var topPixel = _topEllipsePoints[_stringCount - 1 - stringNum]; var basePixel = _baseEllipsePoints[_stringCount - 1 - stringNum]; var line = _strings[stringNum] as PreviewLine; if (line != null) { line.SetPoint0(basePixel.X, basePixel.Y); line.SetPoint1(topPixel.X, topPixel.Y); line.Layout(); } } } SetPixelZoom(); } }
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 (_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(); } } }
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 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(); } } }