protected override PdnGraphicsPath CreateShapePath(PointF[] points) { // make sure we don't screw them up if (points.Length < 2) { return null; } // make sure the shape has an area of at least 1 // we can determine this by making sure that all the Points in points are not all the same bool allTheSame = true; foreach (PointF pt in points) { if (pt != points[0]) { allTheSame = false; break; } } if (allTheSame) { return null; } PdnGraphicsPath path = new PdnGraphicsPath(); path.AddLines(points); path.AddLine(points[points.Length - 1], points[0]); path.CloseAllFigures(); return path; }
protected override PdnGraphicsPath CreateShapePath(PointF[] points) { // make sure we don't screw them up if (points.Length < 2) { return(null); } // make sure the shape has an area of at least 1 // we can determine this by making sure that all the Points in points are not all the same bool allTheSame = true; foreach (PointF pt in points) { if (pt != points[0]) { allTheSame = false; break; } } if (allTheSame) { return(null); } PdnGraphicsPath path = new PdnGraphicsPath(); path.AddLines(points); path.AddLine(points[points.Length - 1], points[0]); path.CloseAllFigures(); return(path); }
protected override PdnGraphicsPath CreateShapePath(PointF[] points) { PointF a = points[0]; PointF b = points[points.Length - 1]; RectangleF rect; float radius = 10; if ((ModifierKeys & Keys.Shift) != 0) { rect = Utility.PointsToConstrainedRectangle(a, b); } else { rect = Utility.PointsToRectangle(a, b); } PdnGraphicsPath path = this.GetRoundedRect(rect, radius); path.Flatten(); if (path.PathPoints[0] != path.PathPoints[path.PathPoints.Length - 1]) { path.AddLine(path.PathPoints[0], path.PathPoints[path.PathPoints.Length - 1]); path.CloseFigure(); } string numberFormat; string unitsAbbreviation; { unitsAbbreviation = string.Empty; numberFormat = "F0"; } string unitsString = PdnResources.GetString("MeasurementUnit." + "Pixels" + ".Plural"); string statusText = string.Format( this.statusTextFormat, rect.Width, unitsAbbreviation, rect.Height, unitsAbbreviation, "0", unitsString); this.SetStatus(this.roundedRectangleToolIcon, statusText); return(path); }
protected override PdnGraphicsPath CreateShapePath(PointF[] points) { PointF a = points[0]; PointF b = points[points.Length - 1]; RectangleF rect; float radius = 10; if ((ModifierKeys & Keys.Shift) != 0) { rect = Utility.PointsToConstrainedRectangle(a, b); } else { rect = Utility.PointsToRectangle(a, b); } PdnGraphicsPath path = this.GetRoundedRect(rect, radius); path.Flatten(); if (path.PathPoints[0] != path.PathPoints[path.PathPoints.Length - 1]) { path.AddLine(path.PathPoints[0], path.PathPoints[path.PathPoints.Length - 1]); path.CloseFigure(); } MeasurementUnit units = AppWorkspace.Units; double widthPhysical = Math.Abs(Document.PixelToPhysicalX(rect.Width, units)); double heightPhysical = Math.Abs(Document.PixelToPhysicalY(rect.Height, units)); double areaPhysical = widthPhysical * heightPhysical; string numberFormat; string unitsAbbreviation; if (units != MeasurementUnit.Pixel) { string unitsAbbreviationName = "MeasurementUnit." + units.ToString() + ".Abbreviation"; unitsAbbreviation = PdnResources.GetString(unitsAbbreviationName); numberFormat = "F2"; } else { unitsAbbreviation = string.Empty; numberFormat = "F0"; } string unitsString = PdnResources.GetString("MeasurementUnit." + units.ToString() + ".Plural"); string statusText = string.Format( this.statusTextFormat, widthPhysical.ToString(numberFormat), unitsAbbreviation, heightPhysical.ToString(numberFormat), unitsAbbreviation, areaPhysical.ToString(numberFormat), unitsString); this.SetStatus(this.roundedRectangleToolIcon, statusText); return(path); }