public void CreateClosedCurve() { // create curve NRectangleF cell = this.DocumentHelper.GetGridCell(0, 3); int xdeviation = (int)cell.Width / 4; int ydeviation = (int)cell.Height / 4; NPointF[] points = new NPointF[] { new NPointF(cell.X + Random.Next(xdeviation), cell.Y + Random.Next(ydeviation)), new NPointF(cell.Right - Random.Next(xdeviation), cell.Y + Random.Next(ydeviation)), new NPointF(cell.Right - Random.Next(xdeviation), cell.Bottom - Random.Next(ydeviation)), new NPointF(cell.X + Random.Next(xdeviation), cell.Bottom - Random.Next(ydeviation)), new NPointF(cell.X + Random.Next((int)cell.Width), cell.Y + Random.Next((int)cell.Height)) }; NClosedCurveShape curve = new NClosedCurveShape(points, 1); // set fill and stroke styles curve.Style.FillStyle = new NHatchFillStyle(HatchStyle.SmallGrid, Color.LightSalmon, Color.Chocolate); curve.Style.StrokeStyle = new NStrokeStyle(1, Color.Black, LinePattern.DashDotDot); // add to active layer Document.ActiveLayer.AddChild(curve); // add description cell = this.DocumentHelper.GetGridCell(1, 3); NTextShape text = new NTextShape("Closed curve with hatch fill style and dash-dot-dot stroke style", cell); Document.ActiveLayer.AddChild(text); }
protected NGroup CreateChildGroup() { Color color1 = Color.FromArgb(25, 0, 0xbb, 0xbb); Color color2 = Color.FromArgb(150, 0, 204, 0); NGroup group = new NGroup(); // create the group frame NRectangleF bounds = base.GetGridCell(0, 0, 1, 1); NRectangleShape frame = new NRectangleShape(bounds); frame.Protection = new NAbilities(AbilitiesMask.Select); frame.Style.FillStyle = new NColorFillStyle(color1); group.Shapes.AddChild(frame); // create the group shapes group.Shapes.AddChild(new NRectangleShape(base.GetGridCell(0, 0))); group.Shapes.AddChild(new NEllipseShape(base.GetGridCell(0, 1))); group.Shapes.AddChild(new NTextShape("Child group", base.GetGridCell(1, 0, 0, 1))); // update the group model bounds group.UpdateModelBounds(); // apply styles to the group group.Style.FillStyle = new NColorFillStyle(color2); group.Style.StrokeStyle = new NStrokeStyle(1, color2); group.Style.TextStyle = new NTextStyle(new Font("Arial", 10), color2); return(group); }
public void CreateDoubleArrow() { // create double arrow NRectangleF cell = this.DocumentHelper.GetGridCell(2, 1); NPointF startPoint = new NPointF(cell.X, cell.Y + cell.Height / 2); NPointF endPoint = new NPointF(cell.Right, cell.Y + cell.Height / 2); NArrowShape arrow = new NArrowShape(ArrowType.DoubleArrow, startPoint, endPoint, 20, 45, 60); // set styles try { Bitmap bmp = new Bitmap(this.MapPathSecure(this.TemplateSourceDirectory + "\\..\\Images\\ConceptCar2.png")); arrow.Style.FillStyle = new NImageFillStyle(bmp, 125); } catch (Exception ex) { Debug.WriteLine("Failed to load concept car resource. Exception was: " + ex.Message); } arrow.Style.StrokeStyle = new NStrokeStyle(1, Color.Black, LinePattern.Solid); // add to the active layer Document.ActiveLayer.AddChild(arrow); // add description cell = this.DocumentHelper.GetGridCell(3, 1); NTextShape text = new NTextShape("Single arrow with semi transparent image fill style and solid stroke style", cell); Document.ActiveLayer.AddChild(text); }
/// <summary> /// Updates the specified status bar info /// </summary> /// <remarks> /// Overriden to populate the secondary info with the zoom rect bounds if it is valid /// and the secondary info is not yet populated. /// </remarks> /// <param name="info">status bar info</param> public override void UpdateStatusBarInfo(NStatusBarInfo info) { base.UpdateStatusBarInfo(info); // update secondary info with zoom rect if (info.Secondary == "" && m_ZoomRect != null) { StringBuilder sb = new StringBuilder(100); sb.Append("Zoom factor: "); sb.Append(ComputeZoomFactor()); sb.Append(". "); NMeasurementUnit mu = Document.MeasurementUnit; string format = mu.DefaultValueFormat; NRectangleF bounds = m_ZoomRect.Bounds; sb.Append("Zoom rect: {"); sb.Append(bounds.X.ToString(format)); sb.Append(", "); sb.Append(bounds.Y.ToString(format)); sb.Append(", "); sb.Append(bounds.Width.ToString(format)); sb.Append(", "); sb.Append(bounds.Height.ToString(format)); sb.Append("}"); info.Secondary = sb.ToString(); } }
private void CreateDoubleOpenedArrowShape() { NRectangleF modelBounds = new NRectangleF(0, -1, 2, 2); float fXCenter = modelBounds.X + modelBounds.Width / 2; float fYCenter = modelBounds.Y + modelBounds.Height / 2; PointF[] lines = new PointF[3]; GraphicsPath path = new GraphicsPath(); // arrow1 lines[0] = new PointF(fXCenter, modelBounds.Y); lines[1] = new PointF(modelBounds.X, fYCenter); lines[2] = new PointF(fXCenter, modelBounds.Bottom); path.AddLines(lines); // arrow2 path.StartFigure(); lines[0] = new PointF(modelBounds.Right, modelBounds.Y); lines[1] = new PointF(fXCenter, fYCenter); lines[2] = new PointF(modelBounds.Right, modelBounds.Bottom); path.AddLines(lines); /// create a custom open figure and name it NCustomPath strokePath = new NCustomPath(path, PathType.OpenFigure); strokePath.Name = "Double Opened Arrow"; // add it to the arrowhead shape stencil document.ArrowheadShapeStencil.AddChild(strokePath); }
private void CreateCenterShape() { // create the center shape to which all other shapes connect NRectangleF cell = base.GetGridCell(3, 0); cell.Inflate(-5, -5); NEllipseShape shape = new NEllipseShape(cell); shape.Name = "Center shape"; shape.Style.FillStyle = new NColorFillStyle(Color.FromArgb(50, 0, 0xbb, 0)); shape.Style.StrokeStyle = new NStrokeStyle(1, Color.FromArgb(0, 0xbb, 0)); shape.CreateShapeElements(ShapeElementsMask.Ports); NDynamicPort port = new NDynamicPort(shape.UniqueId, ContentAlignment.MiddleCenter, DynamicPortGlueMode.GlueToContour); shape.Ports.AddChild(port); shape.Ports.DefaultInwardPortUniqueId = port.UniqueId; // add it to the active layer and store for reuse document.ActiveLayer.AddChild(shape); centerShape = shape; }
private void CreateNGramPath(GraphicsPath path, NRectangleF rect, int edgeCount, float startAngle, float innerRadius) { float halfWidth = rect.Width / 2.0f; float halfHeight = rect.Height / 2.0f; float centerX = rect.X + halfWidth; float centerY = rect.Y + halfHeight; float incAngle = NMath.PI2 / edgeCount; float innerOffsetAngle = NMath.PI / edgeCount; PointF[] outer = new PointF[edgeCount]; PointF[] inner = new PointF[edgeCount]; for (int i = 0; i < edgeCount; i++) { float angle = startAngle + i * incAngle; outer[i].X = (float)Math.Round(centerX + Math.Cos(angle) * halfWidth, 1); outer[i].Y = (float)Math.Round(centerY + Math.Sin(angle) * halfHeight, 1); angle += innerOffsetAngle; inner[i].X = (float)Math.Round(centerX + Math.Cos(angle) * innerRadius, 1); inner[i].Y = (float)Math.Round(centerY + Math.Sin(angle) * innerRadius, 1); } for (int i = 0; i < (edgeCount - 1); i++) { path.AddLine(outer[i], inner[i]); path.AddLine(inner[i], outer[i + 1]); } path.AddLine(outer[edgeCount - 1], inner[edgeCount - 1]); path.CloseAllFigures(); }
private void CreateMoveMeShape() { // create the center shape to which all other shapes connect NRectangleF cell = base.GetGridCell(3, 0); cell.Inflate(-5, -5); NRectangleShape shape = new NRectangleShape(cell); shape.Name = "Move Me"; shape.Text = "Move Me Close to Another Shape"; shape.Style.FillStyle = new NColorFillStyle(Color.FromArgb(247, 150, 56)); shape.Style.StrokeStyle = new NStrokeStyle(1, Color.FromArgb(68, 90, 108)); // create an outward port shape.CreateShapeElements(ShapeElementsMask.Ports); NRotatedBoundsPort port = new NRotatedBoundsPort(shape.UniqueId, ContentAlignment.TopCenter); port.Type = PortType.Outward; shape.Ports.AddChild(port); shape.Ports.DefaultOutwardPortUniqueId = port.UniqueId; // add it to the active layer and store for reuse document.ActiveLayer.AddChild(shape); centerShape = shape; }
/// <summary> /// /// </summary> /// <param name="row"></param> /// <param name="col"></param> /// <param name="rowSpan"></param> /// <param name="colSpan"></param> /// <returns></returns> public NRectangleF GetGridCell(int row, int col, int rowSpan, int colSpan) { NRectangleF cell1 = GetGridCell(row, col, defaultGridOrigin, defaultGridCellSize, defaultGridSpacing); NRectangleF cell2 = GetGridCell(row + rowSpan, col + colSpan, defaultGridOrigin, defaultGridCellSize, defaultGridSpacing); return(NRectangleF.Union(cell1, cell2)); }
private NGroup CreateElement(string text) { NGroup group = new NGroup(); document.ActiveLayer.AddChild(group); // Create the text shape NTextShape textShape = new NTextShape(text, 0, 0, 1, 1); group.Shapes.AddChild(textShape); textShape.SizeToText(new NMarginsF(10, 2, 10, 2)); // Create the line shape under the text NRectangleF rect = textShape.Bounds; NLineShape lineShape = new NLineShape(rect.X, rect.Bottom, rect.Right, rect.Bottom); group.Shapes.AddChild(lineShape); // Create the ports CreatePorts(group, lineShape); // Set the protections SetProtections(group); group.UpdateModelBounds(); return(group); }
public void CreatePolygon() { // create polygon NRectangleF cell = this.DocumentHelper.GetGridCell(0, 2); int xdeviation = (int)cell.Width / 4; int ydeviation = (int)cell.Height / 4; NPointF[] points = new NPointF[] { new NPointF(cell.X + Random.Next(xdeviation), cell.Y + Random.Next(ydeviation)), new NPointF(cell.Right - Random.Next(xdeviation), cell.Y + Random.Next(ydeviation)), new NPointF(cell.Right - Random.Next(xdeviation), cell.Bottom - Random.Next(ydeviation)), new NPointF(cell.X + Random.Next(xdeviation), cell.Bottom - Random.Next(ydeviation)), new NPointF(cell.X + Random.Next((int)cell.Width), cell.Y + Random.Next((int)cell.Height)) }; NPolygonShape polygon = new NPolygonShape(points); // set fill and stroke styles polygon.Style.FillStyle = new NGradientFillStyle(GradientStyle.FromCenter, GradientVariant.Variant1, Color.Green, Color.Yellow); polygon.Style.StrokeStyle = new NStrokeStyle(1, Color.Black, LinePattern.DashDot); // add to active layer Document.ActiveLayer.AddChild(polygon); // add description cell = this.DocumentHelper.GetGridCell(1, 2); NTextShape text = new NTextShape("Polygon with gradient fill style and dash-dot stroke style", cell); Document.ActiveLayer.AddChild(text); }
private void CreateCompositePointShape() { NRectangleF modelBounds = new NRectangleF(-1, -1, 2, 2); float centerX = 0; // create composite geometry model NCompositeGeometry composite = new NCompositeGeometry(); composite.Name = "Composite Point"; // add ellipse composite.AddChild(new NEllipsePath(new NRectangleF(modelBounds.X, modelBounds.Y, modelBounds.Width / 2, modelBounds.Height))); // add cross GraphicsPath path = new GraphicsPath(); path.AddLine(centerX, modelBounds.Y, modelBounds.Right, modelBounds.Bottom); path.StartFigure(); path.AddLine(modelBounds.Right, modelBounds.Y, centerX, modelBounds.Bottom); composite.AddChild(new NCustomPath(path, PathType.OpenFigure)); // update the model bounds of the composite composite.UpdateModelBounds(); // add it to the point shape stencil document.PointShapeStencil.AddChild(composite); }
private void InitDocument() { Color color1 = Color.FromArgb(25, 0, 0xaa, 0xaa); Color color2 = Color.FromArgb(150, 0, 0, 204); NGroup group = new NGroup(); // create the group frame NRectangleF bounds = base.GetGridCell(0, 0, 2, 3); NRectangleShape frame = new NRectangleShape(bounds); frame.Protection = new NAbilities(AbilitiesMask.Select); frame.Style.FillStyle = new NColorFillStyle(color1); group.Shapes.AddChild(frame); // add some shape to the group group.Shapes.AddChild(new NRectangleShape(base.GetGridCell(0, 2))); group.Shapes.AddChild(new NEllipseShape(base.GetGridCell(0, 3))); group.Shapes.AddChild(new NTextShape("Parent group", GetGridCell(2, 0, 0, 3))); // add the child group in the group group.Shapes.AddChild(CreateChildGroup()); // update the group model bounds group.UpdateModelBounds(); // apply styles to the group group.Style.FillStyle = new NColorFillStyle(color2); group.Style.StrokeStyle = new NStrokeStyle(color2); group.Style.TextStyle = new NTextStyle(new Font("Arial", 10), color2); // add the parent group to the active layer document.ActiveLayer.AddChild(group); }
private void CreateCompositeArrowheadShape() { NRectangleF modelBounds = new NRectangleF(0, -1, 2, 2); // create composite geometry and name it NCompositeGeometry geometry = new NCompositeGeometry(); geometry.Name = "Composite Arrowhead"; // add rect geometry.AddChild(new NRectanglePath(new NRectangleF(modelBounds.X, modelBounds.Y, modelBounds.Width / 2, modelBounds.Height))); // add slash 1 float x = modelBounds.X + (modelBounds.Width * 3) / 4; geometry.AddChild(new NLinePath(new NPointF(x, modelBounds.Y), new NPointF(x, modelBounds.Bottom))); // add slash 2 geometry.AddChild(new NLinePath(new NPointF(modelBounds.Right, modelBounds.Y), new NPointF(modelBounds.Right, modelBounds.Bottom))); geometry.UpdateModelBounds(); // add it to the arrowhead shape stencil document.ArrowheadShapeStencil.AddChild(geometry); }
/// <summary> /// Gets a random point constrained in the specified bounds /// </summary> /// <param name="bounds"></param> /// <returns></returns> protected NPointF GetRandomPoint(NRectangleF bounds) { Random rand = new Random(); return(new NPointF( bounds.X + ((float)rand.NextDouble() * bounds.Width), bounds.Y + ((float)rand.NextDouble() * bounds.Height))); }
protected float ComputeZoomFactor() { NRectangleF zoomRect = m_ZoomRect.Bounds; float xScale = View.ScaleX * View.ViewportSize.Width / zoomRect.Width; float yScale = View.ScaleY * View.ViewportSize.Height / zoomRect.Height; return(Math.Min(xScale, yScale)); }
void INCustomSeriesCallback.Paint2D(NChartRenderingContext2D context, NGraphics graphics) { NVector3DF vecView = new NVector3DF(); NVector3DF vecModel = new NVector3DF(); NScaleRuler rulerX = m_Chart.Axis(m_Series.HorizontalAxes[0]).Scale.Ruler; NScaleRuler rulerY = m_Chart.Axis(m_Series.VerticalAxes[0]).Scale.Ruler; // current number of accumulated Bezier points int bpCount = 0; // accumulated Bezier points PointF[] bezierPoints = new PointF[4]; for (int i = 0; i < Points.Length; i++) { // Transform values to chart model coorinates vecModel.X = rulerX.LogicalToScale(Points[i].X); vecModel.Y = rulerY.LogicalToScale(Points[i].Y); // Transform model coordinates to view coordinates m_Chart.TransformModelToClient(vecModel, ref vecView); // Draw the current point bool isControlPoint = (i % 3) != 0; if (isControlPoint) { NRectangleF rect = new NRectangleF(vecView.X - 3, vecView.Y - 3, 6, 6); graphics.PaintEllipse(ControlPointFill, null, rect); } else { NRectangleF rect = new NRectangleF(vecView.X - 5, vecView.Y - 5, 10, 10); graphics.PaintEllipse(PointFill, null, rect); } // Accumulate Bezier point bezierPoints[bpCount] = new PointF(vecView.X, vecView.Y); bpCount++; if (bpCount == 4) { // Draw tangents graphics.DrawLine(TangentStroke, new NPointF(bezierPoints[0]), new NPointF(bezierPoints[1])); graphics.DrawLine(TangentStroke, new NPointF(bezierPoints[2]), new NPointF(bezierPoints[3])); // Draw Bezier line GraphicsPath path = new GraphicsPath(); path.AddBezier(bezierPoints[0], bezierPoints[1], bezierPoints[2], bezierPoints[3]); graphics.PaintPath(null, BezierStroke, path); path.Dispose(); // Update accumultaed points bezierPoints[0] = bezierPoints[3]; bpCount = 1; } } }
/// <summary> /// Gets a random set of points constrained in the specified bounds /// </summary> /// <param name="bounds"></param> /// <param name="pointsCount"></param> /// <returns></returns> protected NPointF[] GetRandomPoints(NRectangleF bounds, int pointsCount) { NPointF[] points = new NPointF[pointsCount]; for (int i = 0; i < points.Length; i++) { points[i] = GetRandomPoint(bounds); } return(points); }
private void CreateLine(int row, int col, AbilitiesMask protection) { // create a line NRectangleF rect = base.GetGridCell(row, col); NLineShape line = new NLineShape(rect.X, rect.Y, rect.Right, rect.Bottom); line.Protection = new NAbilities(protection); line.Text = "Protected from: " + protection.ToString(); document.ActiveLayer.AddChild(line); }
private void CreateRectangleArrowShape() { /// create a simple rect and name it NRectangleF modelBounds = new NRectangleF(0, -1, 2, 2); NRectanglePath rect = new NRectanglePath(modelBounds); rect.Name = "Rectangle"; // add it to the arrowhead shape stencil document.ArrowheadShapeStencil.AddChild(rect); }
/// <summary> /// Creates a predefined flow charting shape /// </summary> /// <param name="flowChartShape">flow charting shape</param> /// <param name="bounds">bounds</param> /// <param name="text">default label text</param> /// <param name="styleSheetName">name of the stylesheet from which to inherit styles</param> /// <returns>new basic shape</returns> private NShape CreateFlowChartingShape(FlowChartingShapes flowChartShape, NRectangleF bounds, string text, string styleSheetName) { NFlowChartingShapesFactory factory = new NFlowChartingShapesFactory(DrawingView.Document); NShape shape = factory.CreateShape((int)flowChartShape); shape.Bounds = bounds; shape.Text = text; shape.StyleSheetName = styleSheetName; DrawingView.Document.ActiveLayer.AddChild(shape); return(shape); }
/// <summary> /// Creates a new basic shape and adds it to the document's active layer. /// </summary> /// <param name="basicShape"></param> /// <param name="bounds"></param> /// <param name="text"></param> /// <param name="styleSheetName"></param> /// <returns></returns> public NShape CreateBasicShape(BasicShapes basicShape, NRectangleF bounds, string text, string styleSheetName) { NBasicShapesFactory factory = new NBasicShapesFactory(document); NShape shape = factory.CreateShape((int)basicShape); shape.Bounds = bounds; shape.Text = text; shape.StyleSheetName = styleSheetName; document.ActiveLayer.AddChild(shape); return(shape); }
/// <summary> /// /// </summary> /// <param name="flowChartingShape"></param> /// <param name="bounds"></param> /// <param name="text"></param> /// <param name="fillStyle"></param> /// <returns></returns> public NShape CreateFlowChartingShape(FlowChartingShapes flowChartingShape, NRectangleF bounds, string text, NFillStyle fillStyle) { NFlowChartingShapesFactory factory = new NFlowChartingShapesFactory(document); NShape shape = factory.CreateShape((int)flowChartingShape); shape.Bounds = bounds; shape.Text = text; shape.Style.FillStyle = (NFillStyle)fillStyle.Clone(); document.ActiveLayer.AddChild(shape); return(shape); }
private void CreateCurveShape(int row, int col) { NRectangleF cell = GetGridCell(row, col); Color color = GetPredefinedColor(5); int xdeviation = (int)cell.Width / 4; int ydeviation = (int)cell.Height / 4; NPointF[] points = new NPointF[] { new NPointF(cell.X + Random.Next(xdeviation), cell.Y + Random.Next(ydeviation)), new NPointF(cell.Right - Random.Next(xdeviation), cell.Y + Random.Next(ydeviation)), new NPointF(cell.Right - Random.Next(xdeviation), cell.Bottom - Random.Next(ydeviation)), new NPointF(cell.X + Random.Next(xdeviation), cell.Bottom - Random.Next(ydeviation)), new NPointF(cell.X + Random.Next((int)cell.Width), cell.Y + Random.Next((int)cell.Height)) }; // create curve NCurveShape curve = new NCurveShape(points, 1); // set stroke style curve.Style.StrokeStyle = new NStrokeStyle(2, color, LinePattern.DashDotDot); // set arrowheads style NArrowheadStyle arrowheadStyle = new NArrowheadStyle( ArrowheadShape.QuillArrow, "", new NSizeL(12, 12), new NColorFillStyle(color), new NStrokeStyle(1, Color.Black)); curve.Style.StartArrowheadStyle = arrowheadStyle; arrowheadStyle = new NArrowheadStyle( ArrowheadShape.SunkenArrow, "", new NSizeL(12, 12), new NColorFillStyle(color), new NStrokeStyle(1, Color.Black)); curve.Style.EndArrowheadStyle = arrowheadStyle; // add to the active layer document.ActiveLayer.AddChild(curve); // add description cell = GetGridCell(row + 1, col); NTextShape text = new NTextShape("Curve with dash-dot-dot style and QuillArrow and SunkenArrow arrowheads", cell); document.ActiveLayer.AddChild(text); }
/// <summary> /// Zooms the view to the dragged zoom rect /// </summary> protected virtual void ZoomToRect() { NRectangleF zoomRect = m_ZoomRect.Bounds; if (zoomRect.Width != 0 || zoomRect.Height != 0) { float scaleFactor = ComputeZoomFactor(); if (View.IsValidScaleFactor(scaleFactor)) { NPointF viewportCenter = new NPointF(zoomRect.X + zoomRect.Width / 2, zoomRect.Y + zoomRect.Height / 2); View.Zoom(scaleFactor, viewportCenter, true); } } }
/// <summary> /// Creates a predefined basic shape /// </summary> /// <param name="basicShape">basic shape</param> /// <param name="bounds">bounds</param> /// <param name="text">default label text</param> /// <param name="styleSheetName">name of the stylesheet from which to inherit styles</param> /// <returns>new basic shape</returns> protected NShape CreateBasicShape(BasicShapes basicShape, NRectangleF bounds, string text, string styleSheetName) { NBasicShapesFactory factory = new NBasicShapesFactory(document); factory.DefaultSize = bounds.Size; NShape shape = factory.CreateShape((int)basicShape); shape.Location = bounds.Location; shape.Text = text; shape.StyleSheetName = styleSheetName; document.ActiveLayer.AddChild(shape); return(shape); }
private void CreateStarPointShape() { // create the graphics path representing the point shape NRectangleF modelBounds = new NRectangleF(-1, -1, 2, 2); GraphicsPath path = new GraphicsPath(); CreateNGramPath(path, modelBounds, 5, -NMath.PIHalf, 0.5f); // wrap it in a model and name it NCustomPath customPath = new NCustomPath(path, PathType.ClosedFigure); customPath.Name = "Star"; // add it to the stencil document.PointShapeStencil.AddChild(customPath); }
/// <summary> /// /// </summary> /// <param name="basicShape"></param> /// <param name="bounds"></param> /// <param name="text"></param> /// <param name="fillStyle"></param> /// <param name="addToActiveLayer"></param> /// <returns></returns> public NShape CreateBasicShape(BasicShapes basicShape, NRectangleF bounds, string text, NFillStyle fillStyle, bool addToActiveLayer) { NBasicShapesFactory factory = new NBasicShapesFactory(document); NShape shape = factory.CreateShape((int)basicShape); shape.Bounds = bounds; shape.Text = text; shape.Style.FillStyle = (NFillStyle)fillStyle.Clone(); if (addToActiveLayer) { document.ActiveLayer.AddChild(shape); } return(shape); }
protected NCompositeShape CreateLegendItem(NRectangleF bounds, string str, NFillStyle fillStyle) { NCompositeShape item = new NCompositeShape(); NRectanglePath rect = new NRectanglePath(0, 0, 2, 2); NStyle.SetFillStyle(rect, (fillStyle.Clone() as NFillStyle)); item.Primitives.AddChild(rect); NTextPrimitive text = new NTextPrimitive(str, new NRectangleF(2, 0, 4, 2)); item.Primitives.AddChild(text); item.UpdateModelBounds(); item.Bounds = bounds; return(item); }
private void addLineButton_Click(object sender, System.EventArgs e) { NRectangleF bounds = view.Viewport; NPointF[] points = base.GetRandomPoints(bounds, 2); NLineShape path = new NLineShape(points[0], points[1]); document.ActiveLayer.AddChild(path); path.Style = path.ComposeStyle().Clone() as NStyle; path.Style.StrokeStyle.Color = Color.DarkCyan; path.Style.StartArrowheadStyle.StrokeStyle.Color = Color.DarkCyan; path.Style.EndArrowheadStyle.StrokeStyle.Color = Color.DarkCyan; view.Selection.SingleSelect(path); view.SmartRefresh(); }