Demonstrates how to create a flowchart that describes a Software Installation process.

| Language: C# |
using Nevron.Nov;
using Nevron.Nov.Diagram;
using Nevron.Nov.Diagram.Shapes;
using Nevron.Nov.Dom;
using Nevron.Nov.Graphics;
using Nevron.Nov.IO;
using Nevron.Nov.Layout;
using Nevron.Nov.UI;
using Nevron.Nov.Windows.Forms;
using System;
using System.Windows.Forms;
namespace NovWinFormsProject
{
public partial class Form1 : Form
{
#region Constructors
public Form1()
{
InitializeComponent();
// Set form title
Text = "NOV WinForms - NInstallProgramExample";
// Create the NOV example and its controls
NWidget exampleContent = CreateExampleContent();
NWidget exampleControls = CreateExampleControls();
if (exampleControls != null)
{
exampleControls.PreferredWidth = 300;
}
// Place the example and its controls in a pair box
NPairBox pairBox = new NPairBox(exampleContent, exampleControls);
pairBox.FillMode = ENStackFillMode.First;
pairBox.FitMode = ENStackFitMode.First;
pairBox.Margins = new NMargins(NDesign.HorizontalSpacing, NDesign.VerticalSpacing);
// Host the example in the form
NNovWidgetHost host = new NNovWidgetHost(pairBox);
host.Dock = DockStyle.Fill;
Controls.Add(host);
}
#endregion
#region Example
public NWidget CreateExampleContent()
{
// Create a simple drawing
NDrawingViewWithRibbon drawingViewWithRibbon = new NDrawingViewWithRibbon();
m_DrawingView = drawingViewWithRibbon.View;
m_DrawingView.Document.HistoryService.Pause();
try
{
InitDiagram(m_DrawingView.Document);
}
finally
{
m_DrawingView.Document.HistoryService.Resume();
}
return drawingViewWithRibbon;
}
public NWidget CreateExampleControls()
{
return null;
}
public string GetExampleDescription()
{
return @"Demonstrates how to create a flowchart that describes a Software Installation process.
";
}
///
/// Gets the relevant documentation links for the example
///
///
public (string Name, string Url)[] GetDocumentationUrls()
{
return new[]
{
("Predefined Libraries", "https://www.nevron.com/docs/openvision/diagram-predefined-libraries.html"),
("Routable Connectors", "https://www.nevron.com/docs/openvision/diagram-routable-connectors.html"),
("Layered Graph Layout", "https://www.nevron.com/docs/openvision/diagram-layered-graph-layout.html"),
};
}
private void InitDiagram(NDrawingDocument drawingDocument)
{
NStyleSheet sheet = new NStyleSheet();
drawingDocument.StyleSheets.Add(sheet);
// create a rule that applies to the geometries of all shapes with user class Connectors
{
NRule rule = sheet.CreateRule(delegate (NSelectorBuilder sb)
{
sb.Type(NGeometry.NGeometrySchema); sb.ChildOf(); sb.UserClass(NDR.StyleSheetNameConnectors);
});
rule.AddValueDeclaration(NGeometry.EndArrowheadProperty, new NArrowhead(ENArrowheadShape.TriangleNoFill), true);
}
// create a rule that applies to the TextBlocks of all shapes with user class Connectors
{
NRule rule = sheet.CreateRule(delegate (NSelectorBuilder sb)
{
sb.Type(NTextBlock.NTextBlockSchema); sb.ChildOf(); sb.UserClass(NDR.StyleSheetNameConnectors);
});
rule.AddValueDeclaration(NTextBlock.BackgroundFillProperty, new NColorFill(NColor.White));
}
// create a rule that applies to shapes with user class "STARTEND"
{
NRule rule = sheet.CreateRule(delegate (NSelectorBuilder sb)
{
sb.Type(NGeometry.NGeometrySchema); sb.ChildOf(); sb.UserClass("STARTEND");
});
rule.AddValueDeclaration(NGeometry.FillProperty, new NStockGradientFill(ENGradientStyle.Horizontal, ENGradientVariant.Variant1, new NColor(247, 150, 56), new NColor(251, 203, 156)));
}
// create a rule that applies to shapes with user class "QUESTION"
{
NRule rule = sheet.CreateRule(delegate (NSelectorBuilder sb)
{
sb.Type(NGeometry.NGeometrySchema); sb.ChildOf(); sb.UserClass("QUESTION");
});
rule.AddValueDeclaration(NGeometry.FillProperty, new NStockGradientFill(ENGradientStyle.Horizontal, ENGradientVariant.Variant1, new NColor(129, 133, 133), new NColor(192, 194, 194)));
}
// create a rule that applies to shapes with user class "ACTION"
{
NRule rule = sheet.CreateRule(delegate (NSelectorBuilder sb)
{
sb.Type(NGeometry.NGeometrySchema); sb.ChildOf(); sb.UserClass("ACTION");
});
rule.AddValueDeclaration(NGeometry.FillProperty, new NStockGradientFill(ENGradientStyle.Horizontal, ENGradientVariant.Variant1, new NColor(68, 90, 108), new NColor(162, 173, 182)));
}
// get drawing and active page
NDrawing drawing = drawingDocument.Content;
NPage activePage = drawing.ActivePage;
// hide ports and grid
drawing.ScreenVisibility.ShowGrid = false;
drawing.ScreenVisibility.ShowPorts = false;
int vSpacing = 35;
int hSpacing = 45;
int topMargin = 10;
int leftMargin = 10;
int shapeWidth = 90;
int shapeHeight = 55;
int col1 = leftMargin;
int col2 = col1 + shapeWidth + hSpacing;
int col3 = col2 + shapeWidth + hSpacing;
int col4 = col3 + shapeWidth + hSpacing;
int row1 = topMargin;
int row2 = row1 + shapeHeight + vSpacing;
int row3 = row2 + shapeHeight + vSpacing;
int row4 = row3 + shapeHeight + vSpacing;
int row5 = row4 + shapeHeight + vSpacing;
int row6 = row5 + shapeHeight + vSpacing;
NFlowchartShapeFactory flowchartShapes = new NFlowchartShapeFactory();
NBasicShapeFactory basicShapes = new NBasicShapeFactory();
NConnectorShapeFactory connectorShapes = new NConnectorShapeFactory();
NRectangle bounds = new NRectangle(col2, row1, shapeWidth, shapeHeight);
NShape start = CreateFlowchartShape(flowchartShapes, ENFlowchartShape.Termination, bounds, "START", "STARTEND");
// row 2
bounds = new NRectangle(col2, row2, shapeWidth, shapeHeight);
NShape haveSerialNumber = CreateFlowchartShape(flowchartShapes, ENFlowchartShape.Decision, bounds, "Have a serial number?", "QUESTION");
bounds = new NRectangle(col3, row2, shapeWidth, shapeHeight);
NShape getSerialNumber = CreateFlowchartShape(flowchartShapes, ENFlowchartShape.Process, bounds, "Get serial number", "ACTION");
// row 3
bounds = new NRectangle(col1, row3, shapeWidth, shapeHeight);
NShape enterSerialNumber = CreateFlowchartShape(flowchartShapes, ENFlowchartShape.Process, bounds, "Enter serial number", "ACTION");
bounds = new NRectangle(col2, row3, shapeWidth, shapeHeight);
NShape haveDiskSpace = CreateFlowchartShape(flowchartShapes, ENFlowchartShape.Decision, bounds, "Have disk space?", "QUESTION");
bounds = new NRectangle(col3, row3, shapeWidth, shapeHeight);
NShape freeUpSpace = CreateFlowchartShape(flowchartShapes, ENFlowchartShape.Process, bounds, "Free up space", "ACTION");
// row 4
bounds = new NRectangle(col1, row4, shapeWidth, shapeHeight);
NShape runInstallRect = CreateFlowchartShape(flowchartShapes, ENFlowchartShape.Process, bounds, "Run install file", "ACTION");
bounds = new NRectangle(col2, row4, shapeWidth, shapeHeight);
NShape registerNow = CreateFlowchartShape(flowchartShapes, ENFlowchartShape.Decision, bounds, "Register now?", "QUESTION");
bounds = new NRectangle(col3, row4, shapeWidth, shapeHeight);
NShape fillForm = CreateFlowchartShape(flowchartShapes, ENFlowchartShape.Process, bounds, "Fill out form", "ACTION");
bounds = new NRectangle(col4, row4, shapeWidth, shapeHeight);
NShape submitForm = CreateFlowchartShape(flowchartShapes, ENFlowchartShape.Process, bounds, "Submit form", "ACTION");
// row 5
bounds = new NRectangle(col1, row5, shapeWidth, shapeHeight);
NShape finishInstall = CreateFlowchartShape(flowchartShapes, ENFlowchartShape.Process, bounds, "Finish installation", "ACTION");
bounds = new NRectangle(col2, row5, shapeWidth, shapeHeight);
NShape restartNeeded = CreateFlowchartShape(flowchartShapes, ENFlowchartShape.Decision, bounds, "Restart needed?", "QUESTION");
bounds = new NRectangle(col3, row5, shapeWidth, shapeHeight);
NShape restart = CreateFlowchartShape(flowchartShapes, ENFlowchartShape.Process, bounds, "Restart", "ACTION");
// row 6
bounds = new NRectangle(col2, row6, shapeWidth, shapeHeight);
NShape run = CreateFlowchartShape(flowchartShapes, ENFlowchartShape.Process, bounds, "RUN", "STARTEND");
// create connectors
CreateConnector(start, "Bottom", haveSerialNumber, "Top", ENConnectorShape.Line, "");
CreateConnector(getSerialNumber, "Top", haveSerialNumber, "Top", ENConnectorShape.RoutableConnector, "");
CreateConnector(haveSerialNumber, "Right", getSerialNumber, "Left", ENConnectorShape.Line, "No");
CreateConnector(haveSerialNumber, "Bottom", enterSerialNumber, "Top", ENConnectorShape.BottomToTop1, "Yes");
CreateConnector(enterSerialNumber, "Right", haveDiskSpace, "Left", ENConnectorShape.Line, "");
CreateConnector(freeUpSpace, "Top", haveDiskSpace, "Top", ENConnectorShape.RoutableConnector, "");
CreateConnector(haveDiskSpace, "Right", freeUpSpace, "Left", ENConnectorShape.Line, "No");
CreateConnector(haveDiskSpace, "Bottom", runInstallRect, "Top", ENConnectorShape.BottomToTop1, "Yes");
CreateConnector(registerNow, "Right", fillForm, "Left", ENConnectorShape.Line, "Yes");
CreateConnector(registerNow, "Bottom", finishInstall, "Top", ENConnectorShape.BottomToTop1, "No");
CreateConnector(fillForm, "Right", submitForm, "Left", ENConnectorShape.Line, "");
CreateConnector(submitForm, "Bottom", finishInstall, "Top", ENConnectorShape.BottomToTop1, "");
CreateConnector(finishInstall, "Right", restartNeeded, "Left", ENConnectorShape.Line, "");
CreateConnector(restart, "Bottom", run, "Top", ENConnectorShape.BottomToTop1, "");
CreateConnector(restartNeeded, "Right", restart, "Left", ENConnectorShape.Line, "Yes");
CreateConnector(restartNeeded, "Bottom", run, "Top", ENConnectorShape.Line, "No");
}
#endregion
#region Implementation
///
/// Creates a predefined basic shape
///
/// basic shape
/// bounds
/// default label text
/// name of the stylesheet from which to inherit styles
/// new basic shape
private NShape CreateBasicShape(ENBasicShape basicShape, NRectangle bounds, string text, string userClass)
{
// create shape
NShape shape = m_BasicShapes.CreateShape(basicShape);
// set bounds, text and user class
shape.SetBounds(bounds);
shape.Text = text;
shape.UserClass = userClass;
// add to active page
m_DrawingView.ActivePage.Items.Add(shape);
return shape;
}
///
/// Creates a predefined flowchart shape.
///
/// flowchart shape
/// bounds
/// default label text
/// name of the stylesheet from which to inherit styles
/// new basic shape
private NShape CreateFlowchartShape(NFlowchartShapeFactory flowchartShapeFactory, ENFlowchartShape flowChartShape, NRectangle bounds, string text, string userClass)
{
// create shape
NShape shape = flowchartShapeFactory.CreateShape(flowChartShape);
// set bounds, text and user class
shape.SetBounds(bounds);
shape.Text = text;
shape.UserClass = userClass;
// add to active page
m_DrawingView.ActivePage.Items.Add(shape);
return shape;
}
///
/// Creates a new connector, which connects the specified shapes
///
///
///
///
///
///
///
/// new 1D shapes
private NShape CreateConnector(NShape fromShape, string fromPortName, NShape toShape, string toPortName, ENConnectorShape connectorType, string text)
{
// check arguments
if (fromShape == null)
throw new ArgumentNullException("fromShape");
if (toShape == null)
throw new ArgumentNullException("toShape");
// create the connector
NShape connector = m_ConnectorShapes.CreateShape(connectorType);
// set text and user class
connector.Text = text;
connector.UserClass = NDR.StyleSheetNameConnectors;
// connect begin
NPort fromPort = fromShape.Ports.GetPortByName(fromPortName);
if (fromPort != null)
{
connector.GlueBeginToPort(fromPort);
}
else
{
connector.GlueBeginToShape(fromShape);
}
// connect end
NPort toPort = toShape.Ports.GetPortByName(toPortName);
if (toPort != null)
{
connector.GlueEndToPort(toPort);
}
else
{
connector.GlueEndToShape(toShape);
}
// add to active page
m_DrawingView.ActivePage.Items.Add(connector);
return connector;
}
#endregion
#region Event Handlers
#endregion
#region Fields
private NDrawingView m_DrawingView;
private NPoint m_GridOrigin = new NPoint(30, 30);
private NSize m_GridCellSize = new NSize(180, 70);
private NSize m_GridSpacing = new NSize(50, 40);
private NBasicShapeFactory m_BasicShapes = new NBasicShapeFactory();
private NConnectorShapeFactory m_ConnectorShapes = new NConnectorShapeFactory();
#endregion
#region Static Methods
#endregion
#region Constants
#endregion
#region Nested Types
#endregion
}
} | Language: VB.NET |
Imports Nevron.Nov
Imports Nevron.Nov.Diagram
Imports Nevron.Nov.Diagram.Shapes
Imports Nevron.Nov.Dom
Imports Nevron.Nov.Graphics
Imports Nevron.Nov.Layout
Imports Nevron.Nov.UI
Imports Nevron.Nov.Windows.Forms
Imports System
Public Class Form1
#Region "Constructors"
Public Sub New()
' This call is required by the designer.
InitializeComponent()
' Add any initialization after the InitializeComponent() call.
' Set form title
Text = "NOV WinForms - NInstallProgramExample"
' Create the NOV example and its controls
Dim exampleContent As NWidget = CreateExampleContent()
Dim exampleControls As NWidget = CreateExampleControls()
If Not exampleControls Is Nothing Then
exampleControls.PreferredWidth = 300
End If
' Place the example and its controls in a pair box
Dim pairBox As NPairBox = New NPairBox(exampleContent, exampleControls)
pairBox.FillMode = ENStackFillMode.First
pairBox.FitMode = ENStackFitMode.First
pairBox.Margins = New NMargins(NDesign.HorizontalSpacing, NDesign.VerticalSpacing)
' Host the example in the form
Dim host As NNovWidgetHost(Of NWidget) = New NNovWidgetHost(Of NWidget)(pairBox)
host.Dock = DockStyle.Fill
Controls.Add(host)
End Sub
#End Region
#Region "Example"
Public Function CreateExampleContent() As NWidget
' Create a simple drawing
Dim drawingViewWithRibbon As NDrawingViewWithRibbon = New NDrawingViewWithRibbon()
m_DrawingView = drawingViewWithRibbon.View
m_DrawingView.Document.HistoryService.Pause()
Try
InitDiagram(m_DrawingView.Document)
Finally
m_DrawingView.Document.HistoryService.Resume()
End Try
Return drawingViewWithRibbon
End Function
Public Function CreateExampleControls() As NWidget
Return Nothing
End Function
Public Function GetExampleDescription() As String
Return "Demonstrates how to create a flowchart that describes a Software Installation process.
"
End Function
'''
''' Gets the relevant documentation links for the example
'''
'''
Public Function GetDocumentationUrls() As (String, String)()
Return {("Predefined Libraries", "https://www.nevron.com/docs/openvision/diagram-predefined-libraries.html"), ("Routable Connectors", "https://www.nevron.com/docs/openvision/diagram-routable-connectors.html"), ("Layered Graph Layout", "https://www.nevron.com/docs/openvision/diagram-layered-graph-layout.html")}
End Function
Private Sub InitDiagram(drawingDocument As NDrawingDocument)
Dim sheet As NStyleSheet = New NStyleSheet()
drawingDocument.StyleSheets.Add(sheet)
' create a rule that applies to the geometries of all shapes with user class Connectors
If True Then
Dim rule As NRule = sheet.CreateRule(Sub(sb As NSelectorBuilder)
sb.Type(NGeometry.NGeometrySchema)
sb.ChildOf()
sb.UserClass(NDR.StyleSheetNameConnectors)
End Sub)
rule.AddValueDeclaration(Of NArrowhead)(NGeometry.EndArrowheadProperty, New NArrowhead(ENArrowheadShape.TriangleNoFill), True)
End If
' create a rule that applies to the TextBlocks of all shapes with user class Connectors
If True Then
Dim rule As NRule = sheet.CreateRule(Sub(sb As NSelectorBuilder)
sb.Type(NTextBlock.NTextBlockSchema)
sb.ChildOf()
sb.UserClass(NDR.StyleSheetNameConnectors)
End Sub)
rule.AddValueDeclaration(Of NFill)(NShapeBlock.BackgroundFillProperty, New NColorFill(NColor.White))
End If
' create a rule that applies to shapes with user class "STARTEND"
If True Then
Dim rule As NRule = sheet.CreateRule(Sub(sb As NSelectorBuilder)
sb.Type(NGeometry.NGeometrySchema)
sb.ChildOf()
sb.UserClass("STARTEND")
End Sub)
rule.AddValueDeclaration(Of NFill)(NGeometry.FillProperty, New NStockGradientFill(ENGradientStyle.Horizontal, ENGradientVariant.Variant1, New NColor(247, 150, 56), New NColor(251, 203, 156)))
End If
' create a rule that applies to shapes with user class "QUESTION"
If True Then
Dim rule As NRule = sheet.CreateRule(Sub(sb As NSelectorBuilder)
sb.Type(NGeometry.NGeometrySchema)
sb.ChildOf()
sb.UserClass("QUESTION")
End Sub)
rule.AddValueDeclaration(Of NFill)(NGeometry.FillProperty, New NStockGradientFill(ENGradientStyle.Horizontal, ENGradientVariant.Variant1, New NColor(129, 133, 133), New NColor(192, 194, 194)))
End If
' create a rule that applies to shapes with user class "ACTION"
If True Then
Dim rule As NRule = sheet.CreateRule(Sub(sb As NSelectorBuilder)
sb.Type(NGeometry.NGeometrySchema)
sb.ChildOf()
sb.UserClass("ACTION")
End Sub)
rule.AddValueDeclaration(Of NFill)(NGeometry.FillProperty, New NStockGradientFill(ENGradientStyle.Horizontal, ENGradientVariant.Variant1, New NColor(68, 90, 108), New NColor(162, 173, 182)))
End If
' get drawing and active page
Dim drawing = drawingDocument.Content
Dim activePage = drawing.ActivePage
' hide ports and grid
drawing.ScreenVisibility.ShowGrid = False
drawing.ScreenVisibility.ShowPorts = False
Dim vSpacing = 35
Dim hSpacing = 45
Dim topMargin = 10
Dim leftMargin = 10
Dim shapeWidth = 90
Dim shapeHeight = 55
Dim col1 = leftMargin
Dim col2 = col1 + shapeWidth + hSpacing
Dim col3 = col2 + shapeWidth + hSpacing
Dim col4 = col3 + shapeWidth + hSpacing
Dim row1 = topMargin
Dim row2 = row1 + shapeHeight + vSpacing
Dim row3 = row2 + shapeHeight + vSpacing
Dim row4 = row3 + shapeHeight + vSpacing
Dim row5 = row4 + shapeHeight + vSpacing
Dim row6 = row5 + shapeHeight + vSpacing
Dim flowchartShapes As NFlowchartShapeFactory = New NFlowchartShapeFactory()
Dim basicShapes As NBasicShapeFactory = New NBasicShapeFactory()
Dim connectorShapes As NConnectorShapeFactory = New NConnectorShapeFactory()
Dim bounds As NRectangle = New NRectangle(col2, row1, shapeWidth, shapeHeight)
Dim start = CreateFlowchartShape(flowchartShapes, ENFlowchartShape.Termination, bounds, "START", "STARTEND")
' row 2
bounds = New NRectangle(col2, row2, shapeWidth, shapeHeight)
Dim haveSerialNumber = CreateFlowchartShape(flowchartShapes, ENFlowchartShape.Decision, bounds, "Have a serial number?", "QUESTION")
bounds = New NRectangle(col3, row2, shapeWidth, shapeHeight)
Dim getSerialNumber = CreateFlowchartShape(flowchartShapes, ENFlowchartShape.Process, bounds, "Get serial number", "ACTION")
' row 3
bounds = New NRectangle(col1, row3, shapeWidth, shapeHeight)
Dim enterSerialNumber = CreateFlowchartShape(flowchartShapes, ENFlowchartShape.Process, bounds, "Enter serial number", "ACTION")
bounds = New NRectangle(col2, row3, shapeWidth, shapeHeight)
Dim haveDiskSpace = CreateFlowchartShape(flowchartShapes, ENFlowchartShape.Decision, bounds, "Have disk space?", "QUESTION")
bounds = New NRectangle(col3, row3, shapeWidth, shapeHeight)
Dim freeUpSpace = CreateFlowchartShape(flowchartShapes, ENFlowchartShape.Process, bounds, "Free up space", "ACTION")
' row 4
bounds = New NRectangle(col1, row4, shapeWidth, shapeHeight)
Dim runInstallRect = CreateFlowchartShape(flowchartShapes, ENFlowchartShape.Process, bounds, "Run install file", "ACTION")
bounds = New NRectangle(col2, row4, shapeWidth, shapeHeight)
Dim registerNow = CreateFlowchartShape(flowchartShapes, ENFlowchartShape.Decision, bounds, "Register now?", "QUESTION")
bounds = New NRectangle(col3, row4, shapeWidth, shapeHeight)
Dim fillForm = CreateFlowchartShape(flowchartShapes, ENFlowchartShape.Process, bounds, "Fill out form", "ACTION")
bounds = New NRectangle(col4, row4, shapeWidth, shapeHeight)
Dim submitForm = CreateFlowchartShape(flowchartShapes, ENFlowchartShape.Process, bounds, "Submit form", "ACTION")
' row 5
bounds = New NRectangle(col1, row5, shapeWidth, shapeHeight)
Dim finishInstall = CreateFlowchartShape(flowchartShapes, ENFlowchartShape.Process, bounds, "Finish installation", "ACTION")
bounds = New NRectangle(col2, row5, shapeWidth, shapeHeight)
Dim restartNeeded = CreateFlowchartShape(flowchartShapes, ENFlowchartShape.Decision, bounds, "Restart needed?", "QUESTION")
bounds = New NRectangle(col3, row5, shapeWidth, shapeHeight)
Dim restart = CreateFlowchartShape(flowchartShapes, ENFlowchartShape.Process, bounds, "Restart", "ACTION")
' row 6
bounds = New NRectangle(col2, row6, shapeWidth, shapeHeight)
Dim run = CreateFlowchartShape(flowchartShapes, ENFlowchartShape.Process, bounds, "RUN", "STARTEND")
' create connectors
CreateConnector(start, "Bottom", haveSerialNumber, "Top", ENConnectorShape.Line, "")
CreateConnector(getSerialNumber, "Top", haveSerialNumber, "Top", ENConnectorShape.RoutableConnector, "")
CreateConnector(haveSerialNumber, "Right", getSerialNumber, "Left", ENConnectorShape.Line, "No")
CreateConnector(haveSerialNumber, "Bottom", enterSerialNumber, "Top", ENConnectorShape.BottomToTop1, "Yes")
CreateConnector(enterSerialNumber, "Right", haveDiskSpace, "Left", ENConnectorShape.Line, "")
CreateConnector(freeUpSpace, "Top", haveDiskSpace, "Top", ENConnectorShape.RoutableConnector, "")
CreateConnector(haveDiskSpace, "Right", freeUpSpace, "Left", ENConnectorShape.Line, "No")
CreateConnector(haveDiskSpace, "Bottom", runInstallRect, "Top", ENConnectorShape.BottomToTop1, "Yes")
CreateConnector(registerNow, "Right", fillForm, "Left", ENConnectorShape.Line, "Yes")
CreateConnector(registerNow, "Bottom", finishInstall, "Top", ENConnectorShape.BottomToTop1, "No")
CreateConnector(fillForm, "Right", submitForm, "Left", ENConnectorShape.Line, "")
CreateConnector(submitForm, "Bottom", finishInstall, "Top", ENConnectorShape.BottomToTop1, "")
CreateConnector(finishInstall, "Right", restartNeeded, "Left", ENConnectorShape.Line, "")
CreateConnector(restart, "Bottom", run, "Top", ENConnectorShape.BottomToTop1, "")
CreateConnector(restartNeeded, "Right", restart, "Left", ENConnectorShape.Line, "Yes")
CreateConnector(restartNeeded, "Bottom", run, "Top", ENConnectorShape.Line, "No")
End Sub
#End Region
#Region "Implementation"
'''
''' Creates a predefined basic shape
'''
''' basic shape
''' bounds
''' default label text
''' name of the stylesheet from which to inherit styles
''' new basic shape
Private Function CreateBasicShape(basicShape As ENBasicShape, bounds As NRectangle, text As String, userClass As String) As NShape
' create shape
Dim shape = m_BasicShapes.CreateShape(basicShape)
' set bounds, text and user class
shape.SetBounds(bounds)
shape.Text = text
shape.UserClass = userClass
' add to active page
m_DrawingView.ActivePage.Items.Add(shape)
Return shape
End Function
'''
''' Creates a predefined flowchart shape.
'''
''' flowchart shape
''' bounds
''' default label text
''' name of the stylesheet from which to inherit styles
''' new basic shape
Private Function CreateFlowchartShape(flowchartShapeFactory As NFlowchartShapeFactory, flowChartShape As ENFlowchartShape, bounds As NRectangle, text As String, userClass As String) As NShape
' create shape
Dim shape = flowchartShapeFactory.CreateShape(flowChartShape)
' set bounds, text and user class
shape.SetBounds(bounds)
shape.Text = text
shape.UserClass = userClass
' add to active page
m_DrawingView.ActivePage.Items.Add(shape)
Return shape
End Function
'''
''' Creates a new connector, which connects the specified shapes
'''
'''
'''
'''
'''
'''
'''
''' new 1D shapes
Private Function CreateConnector(fromShape As NShape, fromPortName As String, toShape As NShape, toPortName As String, connectorType As ENConnectorShape, text As String) As NShape
' check arguments
If fromShape Is Nothing Then Throw New ArgumentNullException("fromShape")
If toShape Is Nothing Then Throw New ArgumentNullException("toShape")
' create the connector
Dim connector = m_ConnectorShapes.CreateShape(connectorType)
' set text and user class
connector.Text = text
connector.UserClass = NDR.StyleSheetNameConnectors
' connect begin
Dim fromPort = fromShape.Ports.GetPortByName(fromPortName)
If fromPort IsNot Nothing Then
connector.GlueBeginToPort(fromPort)
Else
connector.GlueBeginToShape(fromShape)
End If
' connect end
Dim toPort = toShape.Ports.GetPortByName(toPortName)
If toPort IsNot Nothing Then
connector.GlueEndToPort(toPort)
Else
connector.GlueEndToShape(toShape)
End If
' add to active page
m_DrawingView.ActivePage.Items.Add(connector)
Return connector
End Function
#End Region
#Region "Event Handlers"
#End Region
#Region "Fields"
Private m_DrawingView As NDrawingView
Private m_GridOrigin As NPoint = New NPoint(30, 30)
Private m_GridCellSize As NSize = New NSize(180, 70)
Private m_GridSpacing As NSize = New NSize(50, 40)
Private m_BasicShapes As NBasicShapeFactory = New NBasicShapeFactory()
Private m_ConnectorShapes As NConnectorShapeFactory = New NConnectorShapeFactory()
#End Region
#Region "Static Methods"
#End Region
#Region "Constants"
#End Region
#Region "Nested Types"
#End Region
End Class