public System.Drawing.PointF ToDrawing() { PDFUnit x = this.X.ToPoints(); PDFUnit y = this.Y.ToPoints(); return(new System.Drawing.PointF((float)x.Value, (float)y.Value)); }
/// <summary> /// Increases the thickness of the edges by the specified amount (Top & Bottom += h, Left & Right += w) /// </summary> /// <param name="w">The value to increase the horizontal sizes by</param> /// <param name="h">The value to increase the vertical sizes by</param> public void Inflate(PDFUnit w, PDFUnit h) { this.Top += h; this.Bottom += h; this.Left += w; this.Right += w; }
public static PDFRect Inflate(PDFRect rect, PDFUnit x, PDFUnit y) { PDFRect rect2 = rect.Clone(); rect2 = rect2.Inflate(x, y); return(rect2); }
public PDFRect(PDFUnit x, PDFUnit y, PDFUnit width, PDFUnit height) { this._x = x; this._y = y; this._w = width; this._h = height; }
public PDFRect(PDFPoint location, PDFSize size) { this._x = location.X; this._y = location.Y; this._w = size.Width; this._h = size.Height; }
public PDFSize ToPoints() { PDFUnit w = this.Width.ToPoints(); PDFUnit h = this.Height.ToPoints(); return(new PDFSize(w, h)); }
public System.Drawing.SizeF ToDrawing() { PDFUnit w = this.Width.ToPoints(); PDFUnit h = this.Height.ToPoints(); return(new System.Drawing.SizeF((float)w.Value, (float)h.Value)); }
private PDFSize CalculateAppropriateImageSize(PDFImageData imgdata, PDFRect bounds) { //Find the dimension that makes sure the bounds are fully covered double scale = (bounds.Width.PointsValue / imgdata.DisplayWidth.PointsValue); double resultHeight = imgdata.DisplayHeight.PointsValue * scale; if (resultHeight < bounds.Height) { scale = bounds.Height.PointsValue / imgdata.DisplayHeight.PointsValue; } PDFUnit imgw = imgdata.DisplayWidth.PointsValue * scale; PDFUnit imgh = imgdata.DisplayHeight.PointsValue * scale; if (imgw > bounds.Width) { this.XPostion = -((imgw.PointsValue - bounds.Width.PointsValue) / 2.0); } if (imgh > bounds.Height) { this.YPostion = -((imgh.PointsValue - bounds.Height.PointsValue) / 2.0); } this.XStep = imgw; this.YStep = imgh; return(new PDFSize(imgw, imgh)); }
/// <summary> /// Increases the thickness of the edges by the specified amount (Top & Bottom & Left & Right += all) /// </summary> /// <param name="all">The thickness to increase all edges by</param> public void Inflate(PDFUnit all) { this.Top += all; this.Bottom += all; this.Left += all; this.Right += all; }
/// <summary> /// Increases the thickness of the edges by the individually specified amounts /// </summary> /// <param name="top">The value to increase the top edge by</param> /// <param name="left">The value to increase the left edge by</param> /// <param name="bottom">The value to increase the bottom edge by</param> /// <param name="right">The value to increase the right edge by</param> public void Inflate(PDFUnit top, PDFUnit right, PDFUnit bottom, PDFUnit left) { this.Top += top; this.Bottom += bottom; this.Left += left; this.Right += right; }
/// <summary> /// Creates a new instance of a PDFThickness /// </summary> /// <param name="top">The top thickness</param> /// <param name="left">The left thickness</param> /// <param name="bottom">The bottom thickness</param> /// <param name="right">The right thickness</param> public PDFThickness(PDFUnit top, PDFUnit right, PDFUnit bottom, PDFUnit left) { this._left = left; this._top = top; this._right = right; this._bottom = bottom; }
public static PDFPoint Parse(string input) { if (string.IsNullOrEmpty(input)) { return(PDFPoint.Empty); } else { try { input = input.Trim(); PDFUnit x, y; if (input.IndexOf(Separator) > 0) { string[] all = input.Split(Separator); x = PDFUnit.Parse(all[0]); y = PDFUnit.Parse(all[1]); } else { x = PDFUnit.Parse(input); y = x; } PDFPoint pt = new PDFPoint(x, y); return(pt); } catch (Exception ex) { string msg = String.Format(Errors.CouldNotParseValue_3, input, "PDFPoint", "Unit,Unit"); throw new PDFException(msg, ex); } } }
private PDFSize CalculateAppropriateImageSize(PDFImageData imgdata) { if (this.XSize > 0 && this.YSize > 0) { //We have both explicit widths return(new PDFSize(this.XSize, this.YSize)); } PDFUnit imgw = imgdata.DisplayWidth; PDFUnit imgh = imgdata.DisplayHeight; //If we have one dimension, then calculate the other proportionally. if (this.XSize > 0) { imgh = this.XSize * (imgh.PointsValue / imgw.PointsValue); imgw = this.XSize; } else if (this.XSize > 0) { imgw = this.XSize * (imgw.PointsValue / imgh.PointsValue); imgh = this.XSize; } return(new PDFSize(imgw, imgh)); }
public PDFPoint ToPoints() { PDFUnit x = this.X.ToPoints(); PDFUnit y = this.Y.ToPoints(); return(new PDFPoint(x, y)); }
internal void ArcFor(PDFUnit rx, PDFUnit ry, double ang, PathArcSize size, PathArcSweep sweep, PDFPoint enddelta) { PDFPoint end = ConvertDeltaToActual(enddelta); PathArcData arc = new PathArcData() { RadiusX = rx, RadiusY = ry, XAxisRotation = ang, ArcSize = size, ArcSweep = sweep, EndPoint = end }; CurrentPath.Add(arc); IEnumerable <PathBezierCurveData> curves = PathDataHelper.GetBezierCurvesForArc(this.Cursor, arc); foreach (PathBezierCurveData bez in curves) { IncludeInBounds(bez.EndPoint); if (bez.HasStartHandle) { IncludeInBounds(bez.StartHandle); } if (bez.HasEndHandle) { IncludeInBounds(bez.EndHandle); } } Cursor = end; }
/// <summary> /// Increases the size of this rectagle by the specified width and height. Returning the resulting rectangle /// </summary> /// <param name="width"></param> /// <param name="height"></param> /// <returns></returns> public PDFRect Inflate(PDFUnit width, PDFUnit height) { PDFRect r = this.Clone(); r.Width += width; r.Height += height; return(r); }
public PDFRect Offset(PDFUnit x, PDFUnit y) { PDFRect rect2 = this.Clone(); rect2.X += x; rect2.Y += y; return(rect2); }
public static PDFRect Union(PDFRect a, PDFRect b) { PDFUnit x = PDFUnit.Min(a.X, b.X); PDFUnit x2 = PDFUnit.Max(a.X + a.Width, b.X + b.Width); PDFUnit y = PDFUnit.Min(a.Y, b.Y); PDFUnit y2 = PDFUnit.Max(a.Y + a.Height, b.Y + b.Height); return(new PDFRect(x, y, x2 - x, y2 - y)); }
private PDFPoint GetReflectedLastHandle() { PDFUnit handlex = new PDFUnit((Cursor.X.PointsValue - LastHandle.X.PointsValue)); PDFUnit handley = new PDFUnit((Cursor.Y.PointsValue - LastHandle.Y.PointsValue)); PDFPoint handle = new PDFPoint(handlex, handley); handle = ConvertDeltaToActual(handle); return(handle); }
public static PDFColumnWidths Parse(string value) { if (string.IsNullOrEmpty(value)) { return(PDFColumnWidths.Empty); } string[] all = value.Split(_splitChars, StringSplitOptions.RemoveEmptyEntries); if (all.Length == 1) { //check to see if it is an explicit width for all columns (e.g. 200pt) var expl = all[0]; if (char.IsLetter(expl, expl.Length - 1)) { PDFUnit val; if (PDFUnit.TryParse(expl, out val)) { return(new PDFColumnWidths(val)); } else { throw new ArgumentException("The value '" + value + "' could not be converted to column widths. Either use an explicit width (e.g. 200pt) or a set of percentage widths (e.g. 30% 40% 30%, or 0.3 0.4 0.3) ", "value"); } } } double[] parsed = new double[all.Length]; double sum = 0; for (var i = 0; i < all.Length; i++) { double one; if (all[i] == "*") { one = UndefinedWidth; } else if (all[i].EndsWith("%")) { one = double.Parse(all[i].Substring(0, all[i].Length - 1)); one = one / 100.0; } else { one = double.Parse(all[i]); } sum += one; if (sum > 1.0) { throw new ArgumentOutOfRangeException("value", "The widths of the columns is a percentage number that must not exceed 1."); } parsed[i] = one; } return(new PDFColumnWidths(parsed)); }
/// <summary> /// Parses a string value in the format [T L B R] or [All] into a PDFThickness instance /// </summary> /// <param name="value">The string to parse</param> /// <returns>A new PDFSize instance</returns> /// <exception cref="ArgumentNullException" /> /// <exception cref="ArgumentException" /> public static PDFThickness Parse(string value) { if (String.IsNullOrEmpty(value)) { throw new ArgumentNullException("value", String.Format(Errors.CouldNotParseValue_3, value, "PDFThickness", "[T L B R], [TB RL] OR [All]")); } if (value.StartsWith(ThicknessStartChar.ToString()) || value.EndsWith(ThicknessEndChar.ToString())) { value = value.Substring(1, value.Length - 2); } else if (ThicknessStartAndEndRequired) { throw new ArgumentNullException("value", String.Format(Errors.CouldNotParseValue_3, value, "PDFThickness", "[T R B L], [TB RL] OR [All]")); } PDFUnit t, l, b, r; string[] thick = value.Split(ThicknessSeparatorChar); if (thick.Length == 1) { if (PDFUnit.TryParse(thick[0], out t) == false) { throw new ArgumentException("value", String.Format(Errors.CouldNotParseValue_3, value, "PDFThickness", "[T R B L], [TB RL] OR [All]")); } else { l = b = r = t; } } else if (thick.Length == 2) { if (PDFUnit.TryParse(thick[0], out t) == false || PDFUnit.TryParse(thick[1], out r) == false) { throw new ArgumentException("value", String.Format(Errors.CouldNotParseValue_3, value, "PDFThickness", "[T R B L], [TB RL] OR [All]")); } b = t; l = r; } else if (thick.Length != 4) { throw new ArgumentException("value", String.Format(Errors.CouldNotParseValue_3, value, "PDFThickness", "[T R B L], [TB RL] OR [All]")); } else { if (PDFUnit.TryParse(thick[0], out t) == false || PDFUnit.TryParse(thick[1], out r) == false || PDFUnit.TryParse(thick[2], out b) == false || PDFUnit.TryParse(thick[3], out l) == false) { throw new ArgumentException("value", String.Format(Errors.CouldNotParseValue_3, value, "PDFThickness", "[T R B L], [TB RL] OR [All]")); } } return(new PDFThickness(t, r, b, l)); }
public void VerticalLineTo(PDFUnit y) { PathLineData line = new PathLineData(); PDFPoint end = new PDFPoint(this.Cursor.X, y); line.LineTo = end; CurrentPath.Add(line); IncludeInBounds(end); Cursor = end; }
public void HorizontalLineFor(PDFUnit dx) { PathLineData line = new PathLineData(); PDFPoint end = ConvertDeltaToActual(dx, 0); line.LineTo = end; CurrentPath.Add(line); IncludeInBounds(end); Cursor = end; }
public void HorizontalLineTo(PDFUnit x) { PathLineData line = new PathLineData(); PDFPoint end = new PDFPoint(x, this.Cursor.Y); line.LineTo = end; CurrentPath.Add(line); IncludeInBounds(end); Cursor = end; }
public void SetClipRect(PDFPoint pt, PDFSize sz, Sides sides, PDFUnit cornerradius) { if (cornerradius > PDFUnit.Zero) { this.DoOutputRoundRectangleWithSidesFill(pt.X, pt.Y, sz.Width, sz.Height, cornerradius, sides); } else { this.RenderRectangle(pt.X, pt.Y, sz.Width, sz.Height); } this.Writer.WriteOpCodeS(PDFOpCode.GraphSetClip); this.Writer.WriteOpCodeS(PDFOpCode.GraphNoOp); }
public static PDFPen Create(PDFBrush brush, PDFUnit width) { if (brush.FillStyle == FillType.Solid) { PDFSolidBrush solid = (PDFSolidBrush)brush; PDFPen pen = Create(solid.Color, width); pen.Opacity = solid.Opacity; return(pen); } else { return(new PDFNoPen()); } }
public PDFPointArray(params PDFUnit[] xys) : this() { if (xys.Length % 2 != 0) { throw new ArgumentOutOfRangeException("xys"); } for (int i = 0; i < xys.Length; i += 2) { PDFUnit x = xys[i]; PDFUnit y = xys[i + 1]; this.Add(new PDFPoint(x, y)); } }
public static PDFUnit[] GetEqualColumnWidths(PDFUnit available, PDFUnit alley, int colCount) { double total = available.PointsValue; total -= (alley.PointsValue * (colCount - 1)); double each = total / colCount; PDFUnit[] all = new PDFUnit[colCount]; for (var i = 0; i < colCount; i++) { all[i] = new PDFUnit(each, PageUnits.Points); } return(all); }
private void OutputQuadrantShapes(PDFUnit x, PDFUnit y, PDFUnit width, PDFUnit height, Quadrants sides) { PDFReal left = x.RealValue; PDFReal right = (x + width).RealValue; PDFReal top = y.RealValue; PDFReal bottom = (y + height).RealValue; PDFReal hcentre = (left + (width.RealValue / (PDFReal)2.0)); PDFReal vcentre = (top + (height.RealValue / (PDFReal)2.0)); PDFReal xhandle = ((width.RealValue / (PDFReal)2.0) * (PDFReal)CircularityFactor); PDFReal yhandle = ((height.RealValue / (PDFReal)2.0) * (PDFReal)CircularityFactor); if ((sides & Quadrants.TopLeft) > 0) { this.RenderMoveTo(left, vcentre); //top left quadrant this.RenderBezierCurveTo(hcentre, top, left, vcentre - yhandle, hcentre - xhandle, top); this.RenderContinuationLine(hcentre, vcentre); this.RenderContinuationLine(left, vcentre); } if ((sides & Quadrants.TopRight) > 0) { this.RenderMoveTo(hcentre, top); //top right quadrant this.RenderBezierCurveTo(right, vcentre, hcentre + xhandle, top, right, vcentre - yhandle); this.RenderContinuationLine(hcentre, vcentre); this.RenderContinuationLine(hcentre, top); } if ((sides & Quadrants.BottomRight) > 0) { this.RenderMoveTo(right, vcentre); //bottom right quadrant this.RenderBezierCurveTo(hcentre, bottom, right, vcentre + yhandle, hcentre + xhandle, bottom); this.RenderContinuationLine(hcentre, vcentre); this.RenderContinuationLine(right, vcentre); } if ((sides & Quadrants.BottomLeft) > 0) { this.RenderMoveTo(hcentre, bottom); //bottom left quadrant this.RenderBezierCurveTo(left, vcentre, hcentre - xhandle, bottom, left, vcentre + yhandle); this.RenderContinuationLine(hcentre, vcentre); this.RenderContinuationLine(hcentre, bottom); } }
public void DrawRectangle(PDFPen pen, PDFUnit x, PDFUnit y, PDFUnit width, PDFUnit height) { if (pen == null) { throw new ArgumentNullException("pen"); } this.SaveGraphicsState(); PDFRect rect = new PDFRect(x, y, width, height); pen.SetUpGraphics(this, rect); this.RenderRectangle(x, y, width, height); this.RenderStrokePathOp(); pen.ReleaseGraphics(this, rect); this.RestoreGraphicsState(); }