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); }
private void CreateArrowShapeWithLogicalLinePort() { // create a filled graph connector with one logical line port NArrowShape shape = new NArrowShape(ArrowType.DoubleArrow, new NPointF(15, 380), new NPointF(55, 420), 10, 45, 30); shape.Bounds = base.GetGridCell(6, 1); shape.Name = "Filled shape with Stroke Port"; // create the ports shape.CreateShapeElements(ShapeElementsMask.Ports); NLogicalLinePort port = new NLogicalLinePort(shape.UniqueId, 30); shape.Ports.RemoveAllChildren(); shape.Ports.AddChild(port); shape.Ports.DefaultInwardPortUniqueId = port.UniqueId; // connect it with the center shape document.ActiveLayer.AddChild(shape); ConnectShapes(centerShape, shape); // descibte it NTextShape text = new NTextShape("Shape with Logical Line Port", base.GetGridCell(6, 2, 0, 1)); document.ActiveLayer.AddChild(text); }
private void arrowConnectorTypeCombo_SelectedIndexChanged(object sender, System.EventArgs e) { if (EventsHandlingPaused) { return; } NArrowShape connector = (view.Selection.AnchorNode as NArrowShape); if (connector == null) { return; } connector.ArrowType = (ArrowType)arrowConnectorTypeCombo.SelectedIndex; document.SmartRefreshAllViews(); }
protected NGroup CreateScale1DGroup() { NGroup group = new NGroup(); // arrow NArrowShape arrow = new NArrowShape(ArrowType.SingleArrow, new NPointF(0, 0), new NPointF(75, 75), 10, 45, 30); arrow.ResizeInAggregate = ResizeInAggregate.Scale1D; arrow.Text = "Scale 1D"; group.Shapes.AddChild(arrow); // line NLineShape line = new NLineShape(new NPointF(150, 0), new NPointF(150 + 100, 100)); line.StyleSheetName = NDR.NameConnectorsStyleSheet; line.ResizeInAggregate = ResizeInAggregate.Scale1D; line.Text = "Scale 1D"; group.Shapes.AddChild(line); // polyline NPolylineShape polyline = new NPolylineShape(base.GetRandomPoints(new NRectangleF(0, 150, 100, 100), 3)); polyline.StyleSheetName = NDR.NameConnectorsStyleSheet; polyline.ResizeInAggregate = ResizeInAggregate.Scale1D; polyline.Text = "Scale 1D"; group.Shapes.AddChild(polyline); // rect NRectangleShape rect = new NRectangleShape(150, 150, 75, 75); rect.Rotate(CoordinateSystem.Scene, 45, rect.PinPoint); rect.ResizeInAggregate = ResizeInAggregate.Scale1D; rect.Text = "Scale 1D"; group.Shapes.AddChild(rect); // update the group model bounds group.UpdateModelBounds(); // add the group to the active layer document.ActiveLayer.AddChild(group); return(group); }
public void CreateSingleArrow() { // create single arrow NRectangleF cell = this.DocumentHelper.GetGridCell(2, 0); 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.SingleArrow, startPoint, endPoint, 20, 45, 60); // set styles arrow.Style.FillStyle = new NHatchFillStyle(HatchStyle.SmallGrid, Color.Yellow, Color.Coral); arrow.Style.StrokeStyle = new NStrokeStyle(1, Color.Black, LinePattern.Dot); // add to the active layer Document.ActiveLayer.AddChild(arrow); // add description cell = this.DocumentHelper.GetGridCell(3, 0); NTextShape text = new NTextShape("Single arrow with hatch fill style and dot stroke style", cell); Document.ActiveLayer.AddChild(text); }
private void InitDocument() { document.Style.TextStyle = new NTextStyle(new Font("Arial", 9), Color.Black); // modify the connectors style sheet NStyleSheet styleSheet = (document.StyleSheets.GetChildByName(NDR.NameConnectorsStyleSheet, -1) as NStyleSheet); NTextStyle textStyle = new NTextStyle(); textStyle.BackplaneStyle.Visible = true; textStyle.BackplaneStyle.StandardFrameStyle.InnerBorderWidth = new NLength(0); styleSheet.Style.TextStyle = textStyle; styleSheet.Style.StrokeStyle = new NStrokeStyle(1, Color.Black); styleSheet.Style.StartArrowheadStyle.StrokeStyle = new NStrokeStyle(1, Color.Black); styleSheet.Style.EndArrowheadStyle.StrokeStyle = new NStrokeStyle(1, Color.Black); // create a stylesheet for the 2D Shapes styleSheet = new NStyleSheet("SHAPE2D"); styleSheet.Style.FillStyle = new NColorFillStyle(Color.PapayaWhip); document.StyleSheets.AddChild(styleSheet); // create a stylesheet for the arrows, which inherits from the connectors stylesheet styleSheet = new NStyleSheet("ARROW", NDR.NameConnectorsStyleSheet); textStyle = new NTextStyle(); textStyle.FontStyle.InitFromFont(new Font("Arial", 8)); styleSheet.Style.TextStyle = textStyle; document.StyleSheets.AddChild(styleSheet); // create shapes NShape shape1 = base.CreateBasicShape(BasicShapes.Rectangle, new NRectangleF(150, 50, 50, 50), "1", "SHAPE2D"); NShape shape2 = base.CreateBasicShape(BasicShapes.Rectangle, new NRectangleF(150, 150, 50, 50), "2", "SHAPE2D"); NShape shape3 = base.CreateBasicShape(BasicShapes.Rectangle, new NRectangleF(325, 150, 50, 50), "3", "SHAPE2D"); NShape shape4 = base.CreateBasicShape(BasicShapes.Rectangle, new NRectangleF(50, 250, 50, 50), "4", "SHAPE2D"); NShape shape5 = base.CreateBasicShape(BasicShapes.Rectangle, new NRectangleF(250, 250, 50, 50), "5", "SHAPE2D"); NShape shape6 = base.CreateBasicShape(BasicShapes.Rectangle, new NRectangleF(400, 250, 50, 50), "6", "SHAPE2D"); NShape shape7 = base.CreateBasicShape(BasicShapes.Rectangle, new NRectangleF(250, 350, 50, 50), "7", "SHAPE2D"); NShape shape8 = base.CreateBasicShape(BasicShapes.Rectangle, new NRectangleF(400, 350, 50, 50), "8", "SHAPE2D"); // create connectors NLineShape line = new NLineShape(); line.StyleSheetName = NDR.NameConnectorsStyleSheet; line.Text = "Line"; document.ActiveLayer.AddChild(line); line.StartPlug.Connect(shape1.Ports.GetChildByName("Bottom", 0) as NPort); line.EndPlug.Connect(shape2.Ports.GetChildByName("Top", 0) as NPort); NStep2Connector hv = new NStep2Connector(false); hv.StyleSheetName = NDR.NameConnectorsStyleSheet; hv.Text = "HV"; document.ActiveLayer.AddChild(hv); hv.StartPlug.Connect(shape1.Ports.GetChildByName("Right", 0) as NPort); hv.EndPlug.Connect(shape3.Ports.GetChildByName("Top", 0) as NPort); NStep2Connector vh = new NStep2Connector(true); vh.StyleSheetName = NDR.NameConnectorsStyleSheet; vh.Text = "VH"; document.ActiveLayer.AddChild(vh); vh.StartPlug.Connect(shape4.Ports.GetChildByName("Bottom", 0) as NPort); vh.EndPlug.Connect(shape7.Ports.GetChildByName("Left", 0) as NPort); NStep3Connector vhv = new NStep3Connector(true, 50, 0, true); vhv.StyleSheetName = NDR.NameConnectorsStyleSheet; vhv.Text = "VHV"; document.ActiveLayer.AddChild(vhv); vhv.StartPlug.Connect(shape2.Ports.GetChildByName("Bottom", 0) as NPort); vhv.EndPlug.Connect(shape4.Ports.GetChildByName("Top", 0) as NPort); NStep3Connector hvh = new NStep3Connector(false, 50, 0, true); hvh.StyleSheetName = NDR.NameConnectorsStyleSheet; hvh.Text = "HVH"; document.ActiveLayer.AddChild(hvh); hvh.StartPlug.Connect(shape2.Ports.GetChildByName("Right", 0) as NPort); hvh.EndPlug.Connect(shape5.Ports.GetChildByName("Left", 0) as NPort); NArrowShape doubleArrow = new NArrowShape(ArrowType.DoubleArrow, new NPointF(0, 0), new NPointF(1, 1), 10, 45, 30); doubleArrow.StyleSheetName = "ARROW"; doubleArrow.Text = "Double Arrow"; document.ActiveLayer.AddChild(doubleArrow); doubleArrow.StartPlug.Connect(shape5.Ports.GetChildByName("Right", 0) as NPort); doubleArrow.EndPlug.Connect(shape6.Ports.GetChildByName("Left", 0) as NPort); NArrowShape singleArrow = new NArrowShape(ArrowType.SingleArrow, new NPointF(0, 0), new NPointF(1, 1), 10, 45, 30); singleArrow.StyleSheetName = "ARROW"; singleArrow.Text = "Single Arrow"; document.ActiveLayer.AddChild(singleArrow); singleArrow.StartPlug.Connect(shape7.Ports.GetChildByName("Right", 0) as NPort); singleArrow.EndPlug.Connect(shape8.Ports.GetChildByName("Left", 0) as NPort); NBezierCurveShape bezier = new NBezierCurveShape(); bezier.StyleSheetName = NDR.NameConnectorsStyleSheet; bezier.Text = "Bezier"; bezier.StartPlug.Connect(shape6.Ports.GetChildByName("Right", 0) as NPort); bezier.EndPlug.Connect(shape6.Ports.GetChildByName("Top", 0) as NPort); bezier.Reflex(); }
/// <summary> /// Creates a connector between the ports of the specified shapes /// </summary> /// <param name="fromShape"></param> /// <param name="fromPortName"></param> /// <param name="toShape"></param> /// <param name="toPortName"></param> /// <param name="connectorType"></param> /// <param name="text"></param> /// <returns></returns> public NShape CreateConnector(NShape fromShape, string fromPortName, NShape toShape, string toPortName, ConnectorType connectorType, string text) { // check input if (fromShape == null) { throw new ArgumentNullException("fromShape"); } if (toShape == null) { throw new ArgumentNullException("toShape"); } NPort fromPort = (fromShape.Ports.GetChildByName(fromPortName, 0) as NPort); if (fromPort == null) { throw new ArgumentException("Was not able to find fromPortName in the ports collection of the fromShape", "fromPortName"); } NPort toPort = (toShape.Ports.GetChildByName(toPortName, 0) as NPort); if (toPort == null) { throw new ArgumentException("Was not able to find toPortName in the ports collection of the toShape", "toPortName"); } // create the connector NShape connector = null; switch (connectorType) { case ConnectorType.Line: connector = new NLineShape(); break; case ConnectorType.Bezier: connector = new NBezierCurveShape(); break; case ConnectorType.SingleArrow: connector = new NArrowShape(ArrowType.SingleArrow); break; case ConnectorType.DoubleArrow: connector = new NArrowShape(ArrowType.DoubleArrow); break; case ConnectorType.SideToTopBottom: connector = new NStep2Connector(false); break; case ConnectorType.TopBottomToSide: connector = new NStep2Connector(true); break; case ConnectorType.SideToSide: connector = new NStep3Connector(false, 50, 0, true); break; case ConnectorType.TopToBottom: connector = new NStep3Connector(true, 50, 0, true); break; case ConnectorType.DynamicHV: connector = new NRoutableConnector(RoutableConnectorType.DynamicHV); break; case ConnectorType.DynamicPolyline: connector = new NRoutableConnector(RoutableConnectorType.DynamicPolyline); break; case ConnectorType.DynamicCurve: connector = new NRoutableConnector(RoutableConnectorType.DynamicCurve); break; default: Debug.Assert(false, "New graph connector type?"); break; } // the connector must be added to the document prior to connecting it document.ActiveLayer.AddChild(connector); connector.StartPlug.Connect(fromPort); connector.EndPlug.Connect(toPort); connector.Style.TextStyle = (connector.ComposeTextStyle().Clone() as NTextStyle); connector.Style.TextStyle.Offset = new Nevron.GraphicsCore.NPointL(0, -7); connector.Text = text; return(connector); }
/// <summary> /// Creates a new connector, which connects the specified shapes /// </summary> /// <param name="fromShape"></param> /// <param name="fromPortName"></param> /// <param name="toShape"></param> /// <param name="toPortName"></param> /// <param name="connectorType"></param> /// <param name="text"></param> /// <returns>new 1D shapes</returns> protected NShape CreateConnector(NShape fromShape, string fromPortName, NShape toShape, string toPortName, ConnectorType connectorType, string text) { // check arguments if (fromShape == null) { throw new ArgumentNullException("fromShape"); } if (toShape == null) { throw new ArgumentNullException("toShape"); } NPort fromPort = (fromShape.Ports.GetChildByName(fromPortName, 0) as NPort); if (fromPort == null) { throw new ArgumentException("Was not able to find fromPortName in the ports collection of the fromShape", "fromPortName"); } NPort toPort = (toShape.Ports.GetChildByName(toPortName, 0) as NPort); if (toPort == null) { throw new ArgumentException("Was not able to find toPortName in the ports collection of the toShape", "toPortName"); } // create the connector NShape connector = null; switch (connectorType) { case ConnectorType.Line: connector = new NLineShape(); break; case ConnectorType.Bezier: connector = new NBezierCurveShape(); break; case ConnectorType.SingleArrow: connector = new NArrowShape(ArrowType.SingleArrow); break; case ConnectorType.DoubleArrow: connector = new NArrowShape(ArrowType.DoubleArrow); break; case ConnectorType.SideToTopBottom: connector = new NStep2Connector(false); break; case ConnectorType.TopBottomToSide: connector = new NStep2Connector(true); break; case ConnectorType.SideToSide: connector = new NStep3Connector(false, 50, 0, true); break; case ConnectorType.TopToBottom: connector = new NStep3Connector(true, 50, 0, true); break; case ConnectorType.DynamicHV: connector = new NRoutableConnector(RoutableConnectorType.DynamicHV); break; case ConnectorType.DynamicPolyline: connector = new NRoutableConnector(RoutableConnectorType.DynamicPolyline); break; case ConnectorType.DynamicCurve: connector = new NRoutableConnector(RoutableConnectorType.DynamicCurve); break; default: Debug.Assert(false, "New graph connector type?"); break; } // the connector must be added to the document prior to connecting it DrawingView.Document.ActiveLayer.AddChild(connector); // change the default label text connector.Text = text; // connectors by default inherit styles from the connectors stylesheet connector.StyleSheetName = NDR.NameConnectorsStyleSheet; // connect the connector to the specified ports connector.StartPlug.Connect(fromPort); connector.EndPlug.Connect(toPort); // modify the connector text style connector.Style.TextStyle = (connector.ComposeTextStyle().Clone() as NTextStyle); connector.Style.TextStyle.Offset = new NPointL(0, -7); return(connector); }