private void CreateShapePorts(NShape shape) { shape.CreateShapeElements(ShapeElementsMask.Ports); // create a dynamic port anchored to the center of the shape NDynamicPort port = new NDynamicPort(new NContentAlignment(ContentAlignment.MiddleCenter), DynamicPortGlueMode.GlueToContour); port.Name = "port"; shape.Ports.AddChild(port); }
private void OnEdgeImported(NDataSourceImporter dataSourceImporter, NShape shape, INDataRecord dataRecord) { // Set the text of the edge shape.Text = dataRecord.GetColumnValue("Desc").ToString(); // Get the symbol name if any object symbol = dataRecord.GetColumnValue("Symbol"); if (symbol == null || Convert.IsDBNull(symbol)) { return; } // Add a logical line port NLogicalLinePort linePort = new NLogicalLinePort(20); shape.CreateShapeElements(ShapeElementsMask.Ports); shape.Ports.AddChild(linePort); // Attach a custom shape based on the symbol name NShape customShape = null; switch (symbol.ToString()) { case "Stop": customShape = m_BusinessProcessShapesFactory.CreateShape(BusinessProcessShapes.StopAccepted); break; case "Question": customShape = m_BusinessProcessShapesFactory.CreateShape(BusinessProcessShapes.Question); break; } ((NDrawingDocument)shape.Document).ActiveLayer.AddChild(customShape); // Protect the symbol from user interactions NAbilities protection = customShape.Protection; protection.All = true; customShape.Protection = protection; // Add an outward port to the shape NRotatedBoundsPort outwardPort = new NRotatedBoundsPort(new NContentAlignment(ContentAlignment.MiddleCenter)); outwardPort.Type = PortType.Outward; customShape.CreateShapeElements(ShapeElementsMask.Ports); customShape.Ports.AddChild(outwardPort); outwardPort.Connect(linePort); }
private void InitDocument() { NDrawingDocument document = NDrawingView1.Document; // remove the standard frame document.BackgroundStyle.FrameStyle.Visible = false; // set up visual formatting document.Style.FillStyle = new NGradientFillStyle(GradientStyle.Horizontal, GradientVariant.Variant3, Color.FromArgb(192, 194, 194), Color.FromArgb(129, 133, 133)); document.Style.StrokeStyle = new NStrokeStyle(1, Color.FromArgb(68, 90, 108)); // create a stylesheet for the edges NStyleSheet sheet = new NStyleSheet("edges"); sheet.Style.StartArrowheadStyle = new NArrowheadStyle(ArrowheadShape.None, "", NSizeL.Empty, document.Style.FillStyle, document.Style.StrokeStyle); sheet.Style.EndArrowheadStyle = new NArrowheadStyle(ArrowheadShape.None, "", NSizeL.Empty, document.Style.FillStyle, document.Style.StrokeStyle); document.StyleSheets.AddChild(sheet); // generate a simple tree NGenericTreeTemplate tree = new NGenericTreeTemplate(); tree.VerticesSize = new NSizeF(80, 80); tree.EdgesStyleSheetName = "edges"; tree.Create(document); // create a show/hide decorator for all shapes that have children NNodeList shapes = document.ActiveLayer.Descendants(NFilters.Shape2D, -1); int i, count = shapes.Count; for (i = 0; i < count; i++) { NShape shape = (NShape)shapes[i]; if (shape.GetOutgoingShapes().Count == 0) { continue; } shape.CreateShapeElements(ShapeElementsMask.Decorators); NShowHideSubtreeDecorator decorator = new NShowHideSubtreeDecorator(); decorator.Name = "ShowHideSubtree"; shape.Decorators.AddChild(new NShowHideSubtreeDecorator()); } // size the document to the content document.SizeToContent(); }
private void CreateDecorators(NShape shape, string decoratorText) { // Create the decorators shape.CreateShapeElements(ShapeElementsMask.Decorators); // Create a frame decorator // We want the user to be able to select the shape when the frame is hit NFrameDecorator frameDecorator = new NFrameDecorator(); frameDecorator.ShapeHitTestable = true; frameDecorator.Header.Margins = new Nevron.Diagram.NMargins(20, 0, 0, 0); frameDecorator.Header.Text = decoratorText; shape.Decorators.AddChild(frameDecorator); // Create an expand/collapse decorator NExpandCollapseDecorator decorator = new NExpandCollapseDecorator(); shape.Decorators.AddChild(decorator); }
private UDNGroup CreateInstance(string name, List <Port> ports, string id) { int instanceWidth = 50; int instanceHeight = 50; int InputMaxSize = 10; int InputCnt = 0; int OutputMaxSize = 10; int OutputCnt = 0; int offsetWidth = 9; int offsetHeight = 30; int widthPadding = 10; int heightPadding = 10; int textWidth = 30; int textHeight = 15; double textOffset = 1.5; int curInPtCnt = 0; int curOutPtCnt = 0; UDNGroup group = new UDNGroup(); group.Name = name; group.UDFullName = name; group.UDPorts = ports; // find max input/output port size for (int i = 0; i < ports.Count; i++) { if (ports[i].Type == PortType.IN) { InputCnt += 1; if (InputMaxSize < ports[i].Name.Length) { InputMaxSize = ports[i].Name.Length; } } else { OutputCnt += 1; if (OutputMaxSize < ports[i].Name.Length) { OutputMaxSize = ports[i].Name.Length; } } } instanceWidth = (InputMaxSize * offsetWidth) + (OutputMaxSize * offsetWidth) + widthPadding; instanceHeight = (InputCnt > OutputCnt ? InputCnt : OutputCnt) * offsetHeight + heightPadding; textWidth = instanceWidth; // Add Instance NRectangleShape node = new NRectangleShape(0, 0, (int)instanceWidth, (int)instanceHeight); NAbilities protection = node.Protection; protection.InplaceEdit = true; node.Protection = protection; node.Name = name; group.Shapes.AddChild(node); NTextShape nodeName = new NTextShape(name, 0, -15, textWidth, textHeight); nodeName.Style.TextStyle = new NTextStyle(); nodeName.Style.TextStyle.FontStyle = new NFontStyle(new Font("Arial", 9)); protection = nodeName.Protection; protection.InplaceEdit = true; nodeName.Protection = protection; group.Shapes.AddChild(nodeName); // Add Port for (int i = 0; i < ports.Count; i++) { NShape port = createPort(ports[i].Name, ports[i].Type); protection = port.Protection; protection.InplaceEdit = true; port.Protection = protection; group.Shapes.AddChild(port); if (ports[i].Type == PortType.IN) { curInPtCnt += 1; port.Location = new NPointF(-port.Bounds.Width / 2, (node.Bounds.Height / (InputCnt + 1)) * curInPtCnt); NTextShape portName = new NTextShape(ports[i].Name, port.Bounds.Width / 2, (node.Bounds.Height / (InputCnt + 1)) * curInPtCnt, ports[i].Name.Length * 9, (int)(port.Bounds.Height * textOffset)); portName.Style.TextStyle = new NTextStyle(); portName.Style.TextStyle.FontStyle = new NFontStyle(new Font("Arial", 9)); portName.Style.TextStyle.StringFormatStyle.HorzAlign = Nevron.HorzAlign.Left; protection = portName.Protection; protection.InplaceEdit = true; portName.Protection = protection; group.Shapes.AddChild(portName); } else { curOutPtCnt += 1; port.Location = new NPointF((-port.Bounds.Width / 2) + node.Bounds.Width, (node.Bounds.Height / (OutputCnt + 1)) * curOutPtCnt); NTextShape portName = new NTextShape(ports[i].Name, node.Bounds.Width - (port.Bounds.Width / 2) - (ports[i].Name.Length * 9), (node.Bounds.Height / (OutputCnt + 1)) * curOutPtCnt, ports[i].Name.Length * 9, (int)(port.Bounds.Height * textOffset)); portName.Style.TextStyle = new NTextStyle(); portName.Style.TextStyle.FontStyle = new NFontStyle(new Font("Arial", 9)); portName.Style.TextStyle.StringFormatStyle.HorzAlign = Nevron.HorzAlign.Right; protection = portName.Protection; protection.InplaceEdit = true; portName.Protection = protection; group.Shapes.AddChild(portName); } port.CreateShapeElements(ShapeElementsMask.Ports); NDynamicPort portInner; if (ports[i].Type == PortType.IN) { portInner = new NDynamicPort(new NContentAlignment(-50, 0), DynamicPortGlueMode.GlueToContour); portInner.Name = ports[i].Name; } else { portInner = new NDynamicPort(new NContentAlignment(50, 0), DynamicPortGlueMode.GlueToContour); portInner.Name = ports[i].Name; } port.Ports.AddChild(portInner); } group.UpdateModelBounds(); return(group); }
private void CreateScene(NDrawingDocument document) { document.BackgroundStyle.FrameStyle.Visible = false; NFillStyle cpaFillStyle = new NGradientFillStyle(GradientStyle.Horizontal, GradientVariant.Variant1, Color.FromArgb(102, 204, 255), Color.FromArgb(0, 128, 128)); NFillStyle clientFillStyle = new NGradientFillStyle(GradientStyle.Horizontal, GradientVariant.Variant1, Color.FromArgb(255, 102, 0), Color.FromArgb(255, 204, 0)); NFillStyle stripeFillStyle = new NGradientFillStyle(GradientStyle.Horizontal, GradientVariant.Variant1, Color.White, Color.FromArgb(221, 221, 221)); NTextStyle abcTextStyle = new NTextStyle(new Font("Arial", 12), Color.FromArgb(150, 150, 150)); float abcWidth = 150; NDrawingDocumentHelper helper = new NDrawingDocumentHelper(document); // configure the document helper.DefaultGridCellSize = new NSizeF(100, 70); helper.DefaultGridSpacing = new NSizeF(30, 30); helper.DefaultGridOrigin = new NPointF(60, 30); document.Bounds = new NRectangleF(0, 0, 1000, (6 * helper.DefaultGridCellSize.Height) + (7 * helper.DefaultGridSpacing.Height)); document.ShadowsZOrder = ShadowsZOrder.BehindLayer; // create the stripes NRectangleShape rect = new NRectangleShape(0, 0, document.Width, document.Height / 3); rect.Style.FillStyle = (NFillStyle)stripeFillStyle.Clone(); rect.Style.StrokeStyle = new NStrokeStyle(0, Color.White); document.ActiveLayer.AddChild(rect); rect = new NRectangleShape(0, document.Height / 3, document.Width, document.Height / 3); rect.Style.FillStyle = (NFillStyle)stripeFillStyle.Clone(); rect.Style.StrokeStyle = new NStrokeStyle(0, Color.White); document.ActiveLayer.AddChild(rect); rect = new NRectangleShape(0, 2 * document.Height / 3, document.Width, document.Height / 3); rect.Style.FillStyle = (NFillStyle)stripeFillStyle.Clone(); rect.Style.StrokeStyle = new NStrokeStyle(0, Color.White); document.ActiveLayer.AddChild(rect); // create A,B,C texts NTextShape text = new NTextShape("A", document.Width - abcWidth, 0, abcWidth, document.Height / 3); text.Mode = BoxTextMode.Stretch; text.Style.TextStyle = (abcTextStyle.Clone() as NTextStyle); document.ActiveLayer.AddChild(text); text = new NTextShape("B", document.Width - abcWidth, document.Height / 3, abcWidth, document.Height / 3); text.Mode = BoxTextMode.Stretch; text.Style.TextStyle = (abcTextStyle.Clone() as NTextStyle); document.ActiveLayer.AddChild(text); text = new NTextShape("C", document.Width - abcWidth, 2 * document.Height / 3, abcWidth, document.Height / 3); text.Mode = BoxTextMode.Stretch; text.Style.TextStyle = (abcTextStyle.Clone() as NTextStyle); document.ActiveLayer.AddChild(text); // add stripe texts text = new NTextShape("Sing up client", document.Width - abcWidth, document.Height / 3 - 50, abcWidth, 50); document.ActiveLayer.AddChild(text); text = new NTextShape("Monthly Accounting Services", document.Width - abcWidth, 2 * document.Height / 3 - 50, abcWidth, 50); document.ActiveLayer.AddChild(text); text = new NTextShape("Additional Services", document.Width - abcWidth, 3 * document.Height / 3 - 50, abcWidth, 50); document.ActiveLayer.AddChild(text); // create a layer for the forground shapes NLayer layer = new NLayer(); document.Layers.AddChild(layer); document.ActiveLayerUniqueId = layer.UniqueId; layer.Style.ShadowStyle = new NShadowStyle(ShadowType.GaussianBlur, Color.Gray, new Nevron.GraphicsCore.NPointL(5, 5), 1, new NLength(10)); // shapes in row 1 NShape newClient = helper.CreateBasicShape(BasicShapes.Diamond, helper.GetGridCell(0, 0), "New Client", cpaFillStyle); NShape register = helper.CreateBasicShape(BasicShapes.Rectangle, helper.GetGridCell(0, 1), "Register", cpaFillStyle); NShape clientAccountInfo = helper.CreateFlowChartingShape(FlowChartingShapes.Data, helper.GetGridCell(0, 2), "Client account info", cpaFillStyle); NShape explainDataEntryProcedures = helper.CreateBasicShape(BasicShapes.Rectangle, helper.GetGridCell(0, 3), "Explain data entry procedures", cpaFillStyle); // shapes in row 2 NShape dataEntry = helper.CreateFlowChartingShape(FlowChartingShapes.ManualInput, helper.GetGridCell(2, 0), "Data Entry", clientFillStyle); NShape emailCompleted = helper.CreateFlowChartingShape(FlowChartingShapes.Document, helper.GetGridCell(2, 1), "E-mail Completed", clientFillStyle); NShape review = helper.CreateBasicShape(BasicShapes.Rectangle, helper.GetGridCell(2, 2), "Review", cpaFillStyle); NShape needsRevising = helper.CreateBasicShape(BasicShapes.Diamond, helper.GetGridCell(2, 3), "Needs revising", cpaFillStyle); NShape emailRevisions = helper.CreateBasicShape(BasicShapes.Rectangle, helper.GetGridCell(2, 4), "E-mail revisions", cpaFillStyle); NShape evaluateRevisions = helper.CreateBasicShape(BasicShapes.Rectangle, helper.GetGridCell(2, 5), "Evaluate revisions", clientFillStyle); // shapes in row 3 NShape emailApprovedRevisions = helper.CreateFlowChartingShape(FlowChartingShapes.Document, helper.GetGridCell(3, 2), "E-mail Approved Revisions", clientFillStyle); NShape evaluateRevisions2 = helper.CreateBasicShape(BasicShapes.Rectangle, helper.GetGridCell(3, 4), "Evaluate Revisions", clientFillStyle); NShape answerClientEmail = helper.CreateBasicShape(BasicShapes.Rectangle, helper.GetGridCell(3, 5), "Answer Client E-mail", cpaFillStyle); // shapes in row 4 NShape paywoll = helper.CreateFlowChartingShape(FlowChartingShapes.Document, helper.GetGridCell(5, 2), "Payroll", clientFillStyle); NShape taxes = helper.CreateBasicShape(BasicShapes.Rectangle, helper.GetGridCell(5, 3), "Taxes", clientFillStyle); NShape controller = helper.CreateBasicShape(BasicShapes.Rectangle, helper.GetGridCell(5, 4), "Controller", cpaFillStyle); // create the optional ports of the shape evaluateRevisions.CreateShapeElements(ShapeElementsMask.Ports); // some shapes need to have extra ports NRotatedBoundsPort port = new NRotatedBoundsPort(evaluateRevisions.UniqueId, new NContentAlignment(-25, 50)); port.Name = "BottomLeft"; evaluateRevisions.Ports.AddChild(port); port = new NRotatedBoundsPort(evaluateRevisions.UniqueId, new NContentAlignment(+25, 50)); port.Name = "BottomRight"; evaluateRevisions.Ports.AddChild(port); // create the optional ports of the shape answerClientEmail.CreateShapeElements(ShapeElementsMask.Ports); port = new NRotatedBoundsPort(answerClientEmail.UniqueId, new NContentAlignment(-25, -50)); port.Name = "TopLeft"; answerClientEmail.Ports.AddChild(port); port = new NRotatedBoundsPort(answerClientEmail.UniqueId, new NContentAlignment(+25, -50)); port.Name = "TopRight"; answerClientEmail.Ports.AddChild(port); // connect shapes in levels helper.CreateConnector(newClient, "Center", register, "Center", ConnectorType.Line, "YES"); helper.CreateConnector(register, "Center", clientAccountInfo, "Center", ConnectorType.Line, ""); helper.CreateConnector(clientAccountInfo, "Center", explainDataEntryProcedures, "Center", ConnectorType.Line, ""); helper.CreateConnector(dataEntry, "Center", emailCompleted, "Center", ConnectorType.Line, ""); helper.CreateConnector(emailCompleted, "Center", review, "Center", ConnectorType.Line, ""); helper.CreateConnector(review, "Center", needsRevising, "Center", ConnectorType.Line, ""); helper.CreateConnector(needsRevising, "Center", emailRevisions, "Center", ConnectorType.Line, "YES"); helper.CreateConnector(emailRevisions, "Center", evaluateRevisions, "Center", ConnectorType.Line, ""); helper.CreateConnector(evaluateRevisions2, "Center", emailApprovedRevisions, "Center", ConnectorType.Line, ""); // connect accross levels NStep3Connector connector = (helper.CreateConnector(newClient, "Center", dataEntry, "Center", ConnectorType.SideToSide, "NO") as NStep3Connector); connector.UseMiddleControlPointPercent = false; connector.MiddleControlPointOffset = -50; helper.CreateConnector(explainDataEntryProcedures, "Center", dataEntry, "Center", ConnectorType.TopToBottom, ""); helper.CreateConnector(emailApprovedRevisions, "Center", review, "Center", ConnectorType.Line, ""); helper.CreateConnector(emailRevisions, "Center", evaluateRevisions2, "Center", ConnectorType.Line, ""); helper.CreateConnector(evaluateRevisions, "BottomLeft", answerClientEmail, "TopLeft", ConnectorType.Line, ""); helper.CreateConnector(answerClientEmail, "TopRight", evaluateRevisions, "BottomRight", ConnectorType.Line, ""); connector = (helper.CreateConnector(needsRevising, "Center", paywoll, "Center", ConnectorType.TopToBottom, "") as NStep3Connector); connector.MiddleControlPointPercent = 66; connector = (helper.CreateConnector(needsRevising, "Center", taxes, "Center", ConnectorType.TopToBottom, "") as NStep3Connector); connector.MiddleControlPointPercent = 66; connector = (helper.CreateConnector(needsRevising, "Center", controller, "Center", ConnectorType.TopToBottom, "") as NStep3Connector); connector.MiddleControlPointPercent = 66; // create the legend NGroup legend = new NGroup(); NRectangleShape ledendBackground = new NRectangleShape(0, 0, 1, 3); ledendBackground.Style.FillStyle = new NColorFillStyle(Color.White); legend.Shapes.AddChild(ledendBackground); NTextShape legendTitle = new NTextShape("Legend", 0, 0, 1, 1); legend.Shapes.AddChild(legendTitle); NRectangleF bounds = new NRectangleF(0, 1, 1, 1); bounds.Inflate(-0.2f, -0.2f); NShape shape = helper.CreateBasicShape(BasicShapes.Rectangle, bounds, "CPA", (NFillStyle)cpaFillStyle.Clone(), false); legend.Shapes.AddChild(shape); bounds = new NRectangleF(0, 2, 1, 1); bounds.Inflate(-0.2f, -0.2f); shape = helper.CreateBasicShape(BasicShapes.Rectangle, bounds, "Client", (NFillStyle)clientFillStyle.Clone(), false); legend.Shapes.AddChild(shape); legend.UpdateModelBounds(); legend.Bounds = helper.GetGridCell(4, 0, 1, 1); document.ActiveLayer.AddChild(legend); }