public async Task ParseCleanRule() { var rulePath = Path.Combine(MockDataDirectory, "NRule_Clean.json"); var ruleRaw = File.ReadAllText(rulePath); var rule = await NRule.ParseAsync(ruleRaw); Assert.IsNotNull(rule); Assert.IsNotNull(rule.Conditions); Assert.IsNotNull(rule.Actions); }
public static async Task <INRuleset> ParseAsync(JObject rulesetObject) { try { var rawRules = JArray.Parse(rulesetObject["Rules"].ToString()); var rules = rawRules.Select(rule => NRule.Parse(rule.ToString())); var union = rulesetObject["Union"].ToString(); return(new NRuleset(rules, (Union)Enum.Parse(typeof(Union), union))); } catch (JsonReaderException ex) { throw new NRulesetParseException(ex); } }
private void AddStyles(NDrawingDocument document) { // Create a style sheet NStyleSheet styleSheet = new NStyleSheet(); document.StyleSheets.Add(styleSheet); // Add some styling for the shapes NRule rule = new NRule(); NSelectorBuilder sb = rule.GetSelectorBuilder(); sb.Start(); sb.Type(NGeometry.NGeometrySchema); sb.ChildOf(); sb.Type(NShape.NShapeSchema); sb.End(); rule.Declarations.Add(new NValueDeclaration <NStroke>(NGeometry.StrokeProperty, new NStroke(new NColor(80, 80, 80)))); styleSheet.Add(rule); }
/// <summary> /// Creates the rule for one to many connectors. /// </summary> /// <returns></returns> private NRule CreateConnectorOneToManyRule() { NRule rule = new NRule(); NSelectorBuilder sb = rule.GetSelectorBuilder(); sb.Start(); sb.Type(NGeometry.NGeometrySchema); sb.ChildOf(); sb.UserClass(ConnectorOneToManyClassName); sb.End(); rule.Declarations.Add(new NValueDeclaration <NStroke>(NGeometry.StrokeProperty, new NStroke(1, NColor.Black, ENDashStyle.Dash))); rule.Declarations.Add(new NValueDeclaration <NArrowhead>(NGeometry.BeginArrowheadProperty, new NArrowhead(ENArrowheadShape.VerticalLine, 8, 8, null, new NStroke(1, NColor.Black)))); rule.Declarations.Add(new NValueDeclaration <NArrowhead>(NGeometry.EndArrowheadProperty, new NArrowhead(ENArrowheadShape.InvertedLineArrowWithCircleNoFill, 8, 8, null, new NStroke(1, NColor.Black)))); return(rule); }
/// <summary> /// Creates a style sheet for the shopping cart table /// </summary> /// <returns></returns> NStyleSheet CreateShoppingCartStyleSheet() { NStyleSheet styleSheet = new NStyleSheet(); NRule rule = new NRule(); for (int i = 0; i < 3; i++) { NSelectorBuilder sb = rule.GetSelectorBuilder(); sb.Start(); sb.Type(NTableCell.NTableCellSchema); // in case of the first or last row selector -> must not be last cell if (i == 0 || i == 2) { sb.StartInvertedConditions(); sb.LastChild(); sb.EndInvertedConditions(); } // descendant of table row sb.DescendantOf(); sb.Type(NTableRow.NTableRowSchema); switch (i) { case 0: // descendant of first row sb.FirstChild(); break; case 1: // middle cells sb.StartInvertedConditions(); sb.FirstChild(); sb.LastChild(); sb.EndInvertedConditions(); break; case 2: // descendant of last row sb.LastChild(); break; } // descendant of table sb.DescendantOf(); sb.Type(NTable.NTableSchema); sb.ValueEquals(NTable.TagProperty, "ShoppingCart"); sb.End(); } rule.Declarations.Add(new NValueDeclaration <NMargins>(NTableCell.BorderThicknessProperty, new NMargins(1))); rule.Declarations.Add(new NValueDeclaration <NBorder>(NTableCell.BorderProperty, NBorder.CreateFilledBorder(NColor.Black))); styleSheet.Add(rule); return(styleSheet); }
protected override void InitDiagram() { base.InitDiagram(); NDrawing drawing = m_DrawingDocument.Content; NPage activePage = drawing.ActivePage; // hide grid and ports drawing.ScreenVisibility.ShowGrid = false; drawing.ScreenVisibility.ShowPorts = false; // create a stylesheet for styling the different bricks NStyleSheet styleSheet = new NStyleSheet(); m_DrawingDocument.StyleSheets.AddChild(styleSheet); // the first rule fills brichs with UserClass BRICK1 NRule ruleBrick1 = new NRule(); styleSheet.Add(ruleBrick1); NSelectorBuilder sb = ruleBrick1.GetSelectorBuilder(); sb.Start(); sb.Type(NGeometry.NGeometrySchema); sb.ChildOf(); sb.UserClass("BRICK1"); sb.End(); ruleBrick1.Declarations.Add(new NValueDeclaration <NFill>(NGeometry.FillProperty, new NHatchFill(ENHatchStyle.HorizontalBrick, NColor.DarkOrange, NColor.Gold))); // the second rule fills brichs with UserClass BRICK2 NRule ruleBrick2 = new NRule(); styleSheet.Add(ruleBrick2); sb = ruleBrick2.GetSelectorBuilder(); sb.Start(); sb.Type(NGeometry.NGeometrySchema); sb.ChildOf(); sb.UserClass("BRICK2"); sb.End(); ruleBrick2.Declarations.Add(new NValueDeclaration <NFill>(NGeometry.FillProperty, new NHatchFill(ENHatchStyle.HorizontalBrick, NColor.DarkRed, NColor.Gold))); // create all shapes // create the maze frame CreateBrick(new NRectangle(50, 0, 700, 50), "BRICK1"); CreateBrick(new NRectangle(750, 0, 50, 800), "BRICK1"); CreateBrick(new NRectangle(50, 750, 700, 50), "BRICK1"); CreateBrick(new NRectangle(0, 0, 50, 800), "BRICK1"); // create the maze obstacles CreateBrick(new NRectangle(100, 200, 200, 50), "BRICK2"); CreateBrick(new NRectangle(300, 50, 50, 200), "BRICK2"); CreateBrick(new NRectangle(450, 50, 50, 200), "BRICK2"); CreateBrick(new NRectangle(500, 200, 200, 50), "BRICK2"); CreateBrick(new NRectangle(50, 300, 250, 50), "BRICK2"); CreateBrick(new NRectangle(500, 300, 250, 50), "BRICK2"); CreateBrick(new NRectangle(350, 350, 100, 100), "BRICK2"); CreateBrick(new NRectangle(50, 450, 250, 50), "BRICK2"); CreateBrick(new NRectangle(500, 450, 250, 50), "BRICK2"); CreateBrick(new NRectangle(100, 550, 200, 50), "BRICK2"); CreateBrick(new NRectangle(300, 550, 50, 200), "BRICK2"); CreateBrick(new NRectangle(450, 550, 50, 200), "BRICK2"); CreateBrick(new NRectangle(500, 550, 200, 50), "BRICK2"); // create the first set of start/end shapes NShape start = CreateEllipse(new NRectangle(100, 100, 50, 50), "START"); NShape end = CreateEllipse(new NRectangle(650, 650, 50, 50), "END"); // connect them with a dynamic HV routable connector, // which is rerouted whenever the obstacles have changed NRoutableConnector routableConnector = new NRoutableConnector(); routableConnector.RerouteMode = ENRoutableConnectorRerouteMode.Always; routableConnector.Geometry.Stroke = new NStroke(3, NColor.Black); activePage.Items.Add(routableConnector); // connect the start and end shapes routableConnector.GlueBeginToShape(start); routableConnector.GlueEndToShape(end); // reroute the connector routableConnector.Reroute(); // size document to fit the maze activePage.SizeToContent(); }
protected override void InitDiagram() { base.InitDiagram(); NStyleSheet sheet = new NStyleSheet(); m_DrawingDocument.StyleSheets.Add(sheet); // create a rule that applies to the geometries of all shapes with user class Connectors const string connectorsClass = "Connector"; { NRule rule = sheet.CreateRule(delegate(NSelectorBuilder sb) { sb.Type(NGeometry.NGeometrySchema); sb.ChildOf(); sb.UserClass(connectorsClass); }); rule.AddValueDeclaration <NArrowhead>(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(connectorsClass); }); rule.AddValueDeclaration <NFill>(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 <NFill>(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 <NFill>(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 <NFill>(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 = m_DrawingDocument.Content; NPage activePage = drawing.ActivePage; // hide ports and grid drawing.ScreenVisibility.ShowGrid = false; drawing.ScreenVisibility.ShowPorts = false; NBasicShapeFactory basicShapesFactory = new NBasicShapeFactory(); NFlowchartingShapeFactory flowChartingShapesFactory = new NFlowchartingShapeFactory(); NConnectorShapeFactory connectorShapesFactory = new NConnectorShapeFactory(); NRectangle bounds; 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; bounds = new NRectangle(col2, row1, shapeWidth, shapeHeight); NShape start = CreateFlowChartingShape(ENFlowchartingShape.Termination, bounds, "START", "STARTEND"); // row 2 bounds = new NRectangle(col2, row2, shapeWidth, shapeHeight); NShape haveSerialNumber = CreateFlowChartingShape(ENFlowchartingShape.Decision, bounds, "Have a serial number?", "QUESTION"); bounds = new NRectangle(col3, row2, shapeWidth, shapeHeight); NShape getSerialNumber = CreateFlowChartingShape(ENFlowchartingShape.Process, bounds, "Get serial number", "ACTION"); // row 3 bounds = new NRectangle(col1, row3, shapeWidth, shapeHeight); NShape enterSerialNumber = CreateFlowChartingShape(ENFlowchartingShape.Process, bounds, "Enter serial number", "ACTION"); bounds = new NRectangle(col2, row3, shapeWidth, shapeHeight); NShape haveDiskSpace = CreateFlowChartingShape(ENFlowchartingShape.Decision, bounds, "Have disk space?", "QUESTION"); bounds = new NRectangle(col3, row3, shapeWidth, shapeHeight); NShape freeUpSpace = CreateFlowChartingShape(ENFlowchartingShape.Process, bounds, "Free up space", "ACTION"); // row 4 bounds = new NRectangle(col1, row4, shapeWidth, shapeHeight); NShape runInstallRect = CreateFlowChartingShape(ENFlowchartingShape.Process, bounds, "Run install file", "ACTION"); bounds = new NRectangle(col2, row4, shapeWidth, shapeHeight); NShape registerNow = CreateFlowChartingShape(ENFlowchartingShape.Decision, bounds, "Register now?", "QUESTION"); bounds = new NRectangle(col3, row4, shapeWidth, shapeHeight); NShape fillForm = CreateFlowChartingShape(ENFlowchartingShape.Process, bounds, "Fill out form", "ACTION"); bounds = new NRectangle(col4, row4, shapeWidth, shapeHeight); NShape submitForm = CreateFlowChartingShape(ENFlowchartingShape.Process, bounds, "Submit form", "ACTION"); // row 5 bounds = new NRectangle(col1, row5, shapeWidth, shapeHeight); NShape finishInstall = CreateFlowChartingShape(ENFlowchartingShape.Process, bounds, "Finish installation", "ACTION"); bounds = new NRectangle(col2, row5, shapeWidth, shapeHeight); NShape restartNeeded = CreateFlowChartingShape(ENFlowchartingShape.Decision, bounds, "Restart needed?", "QUESTION"); bounds = new NRectangle(col3, row5, shapeWidth, shapeHeight); NShape restart = CreateFlowChartingShape(ENFlowchartingShape.Process, bounds, "Restart", "ACTION"); // row 6 bounds = new NRectangle(col2, row6, shapeWidth, shapeHeight); NShape run = CreateFlowChartingShape(ENFlowchartingShape.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"); }
protected override void InitDiagram() { base.InitDiagram(); // Get drawing and active page NDrawing drawing = m_DrawingDocument.Content; NPage activePage = drawing.ActivePage; // Hide ports and grid drawing.ScreenVisibility.ShowGrid = false; // Create styles NRule rule = CreateConnectorOneToManyRule(); NStyleSheet styleSheet = new NStyleSheet(); styleSheet.Add(rule); m_DrawingDocument.StyleSheets.Add(styleSheet); // Create some UML shapes NShape shapeDevice = CreateUmlShape("Device", new NMemberInfo[] { new NMemberInfo(ENMemberVisibility.Public, "DeviceID", "integer(10)"), new NMemberInfo(ENMemberVisibility.Protected, "DeviceCategory", "integer(10)"), new NMemberInfo(ENMemberVisibility.Private, "name", "varchar(50)"), new NMemberInfo(ENMemberVisibility.Private, "description", "blob"), new NMemberInfo(ENMemberVisibility.Private, "detail", "blob") }); activePage.Items.Add(shapeDevice); NShape shapeDeviceCategory = CreateUmlShape("DeviceCategory", new NMemberInfo[] { new NMemberInfo(ENMemberVisibility.Public, "CategoryID", "integer(10)"), new NMemberInfo(ENMemberVisibility.Private, "description", "blob") }); activePage.Items.Add(shapeDeviceCategory); NShape shapeSupportRequest = CreateUmlShape("SupportRequest", new NMemberInfo[] { new NMemberInfo(ENMemberVisibility.Protected, "Device", "integer(10)"), new NMemberInfo(ENMemberVisibility.Public, "RequestID", "integer(10)"), new NMemberInfo(ENMemberVisibility.Protected, "User", "integer(10)"), new NMemberInfo(ENMemberVisibility.Private, "reportDate", "date"), new NMemberInfo(ENMemberVisibility.Private, "description", "blob") }); activePage.Items.Add(shapeSupportRequest); NShape shapeUser = CreateUmlShape("User", new NMemberInfo[] { new NMemberInfo(ENMemberVisibility.Public, "ID", "integer(10)"), new NMemberInfo(ENMemberVisibility.Public, "firstName", "varchar(50)"), new NMemberInfo(ENMemberVisibility.Protected, "lastName", "varchar(50)"), new NMemberInfo(ENMemberVisibility.Private, "phone", "varchar(12)"), new NMemberInfo(ENMemberVisibility.Private, "email", "varchar(50)"), new NMemberInfo(ENMemberVisibility.Private, "address", "blob"), new NMemberInfo(ENMemberVisibility.Private, "remarks", "blob") }); activePage.Items.Add(shapeUser); // Connect the shapes Connect(GetShapeByName("DeviceCategory"), "CategoryID", GetShapeByName("Device"), "DeviceCategory"); Connect(GetShapeByName("Device"), "DeviceID", GetShapeByName("SupportRequest"), "Device"); Connect(GetShapeByName("User"), "ID", GetShapeByName("SupportRequest"), "User"); // Subscribe to the drawing view's Registered event to layout the shapes // when the drawing view is registered in its owner document m_DrawingView.Registered += OnDrawingViewRegistered; }
private NStyleSheet CreateCustomStyleSheet(NUITheme theme) { NStyleSheet styleSheet = new NStyleSheet(); #region Category headers NRule rule = new NRule(); NSelectorBuilder sb = rule.GetSelectorBuilder(); sb.Start(); sb.Type(NExampleCategoryHeader.NExampleCategoryHeaderSchema); sb.End(); rule.Declarations.Add(new NValueDeclaration <NFont>(FontProperty, new NFont(NFontDescriptor.DefaultSansFamilyName, CategoryHeaderFontSize, ENFontStyle.Bold))); rule.Declarations.Add(new NValueDeclaration <NFill>(TextFillProperty, new NColorFill(NColor.White))); rule.Declarations.Add(new NValueDeclaration <NMargins>(PaddingProperty, CategoryHeaderPadding)); styleSheet.Add(rule); rule = new NRule(); sb = rule.GetSelectorBuilder(); sb.Start(); sb.Type(NLabel.NLabelSchema); sb.ValueEquals(NMouse.IsDirectlyOverPropertyEx, true); sb.ChildOf(); sb.Type(NExampleCategoryHeader.NExampleCategoryHeaderSchema); sb.End(); rule.Declarations.Add(new NValueDeclaration <NFill>(TextFillProperty, new NColorFill(NColor.Wheat))); styleSheet.Add(rule); #endregion #region Component Image Box // Component image box rule = new NRule(); sb = rule.GetSelectorBuilder(); sb.Start(); sb.Type(NComponentImageBox.NComponentImageBoxSchema); sb.End(); rule.Declarations.Add(new NValueDeclaration <NMargins>(BorderThicknessProperty, new NMargins(1))); rule.Declarations.Add(new NValueDeclaration <NFont>(FontProperty, new NFont(NFontDescriptor.DefaultSansFamilyName, 8.25, ENFontStyle.Bold))); rule.Declarations.Add(new NValueDeclaration <NCursor>(CursorProperty, new NCursor(ENPredefinedCursor.Hand))); styleSheet.Add(rule); // Component image box - mouse over rule = new NRule(); sb = rule.GetSelectorBuilder(); sb.Start(); sb.Type(NComponentImageBox.NComponentImageBoxSchema); sb.ValueEquals(NMouse.IsOverPropertyEx, true); sb.End(); rule.Declarations.Add(new NValueDeclaration <NBorder>(BorderProperty, NBorder.CreateFilledBorder(NColor.Gray))); styleSheet.Add(rule); #endregion #region Example tiles and contact labels // Example tiles and contact labels rule = new NRule(); sb = rule.GetSelectorBuilder(); sb.Start(); sb.Type(NExampleTile.NExampleTileSchema); sb.ChildOf(); sb.Type(NTableFlowPanel.NTableFlowPanelSchema); sb.End(); sb.Start(); sb.Type(NLabel.NLabelSchema); sb.UserClass("ContactLabel"); sb.End(); rule.Declarations.Add(new NValueDeclaration <NCursor>(CursorProperty, new NCursor(ENPredefinedCursor.Hand))); styleSheet.Add(rule); // Example tiles and contact labels - mouse over rule = new NRule(); sb = rule.GetSelectorBuilder(); sb.Start(); sb.Type(NExampleTile.NExampleTileSchema); sb.ValueEquals(NMouse.IsOverPropertyEx, true); sb.ChildOf(); sb.Type(NTableFlowPanel.NTableFlowPanelSchema); sb.End(); sb.Start(); sb.Type(NLabel.NLabelSchema); sb.UserClass("ContactLabel"); sb.ValueEquals(NMouse.IsOverPropertyEx, true); sb.End(); rule.Declarations.Add(new NValueDeclaration <NFill>(TextFillProperty, new NColorFill(MouseOverColor))); styleSheet.Add(rule); #endregion #region Example in the autocomplete list box rule = new NRule(); sb = rule.GetSelectorBuilder(); sb.Start(); sb.Type(NListBoxItem.NListBoxItemSchema); sb.ValueEquals(NMouse.IsOverPropertyEx, true); sb.ChildOf(); sb.ChildOf(); sb.Type(NListBox.NListBoxSchema); sb.ChildOf(); sb.Type(NPopupWindow.NPopupWindowSchema); sb.End(); rule.Declarations.Add(new NValueDeclaration <NFill>(BackgroundFillProperty, new NColorFill(theme.Colors.ButtonSelectedHighlight))); styleSheet.Add(rule); #endregion return(styleSheet); }
protected override void InitDiagram() { base.InitDiagram(); NStyleSheet sheet = new NStyleSheet(); m_DrawingDocument.StyleSheets.Add(sheet); // create a rule that applies to the TextBlocks of all shapes with user class Connectors string connectorClass = NDR.StyleSheetNameConnectors; { NRule rule2 = new NRule(); sheet.Add(rule2); NSelectorBuilder sb = rule2.GetSelectorBuilder(); sb.Start(); sb.Type(NTextBlock.NTextBlockSchema); sb.ChildOf(); sb.UserClass(connectorClass); sb.End(); rule2.Declarations.Add(new NValueDeclaration <NFill>(NTextBlock.BackgroundFillProperty, new NColorFill(NColor.White))); } // get drawing and active page NDrawing drawing = m_DrawingDocument.Content; NPage activePage = drawing.ActivePage; // hide ports and grid drawing.ScreenVisibility.ShowGrid = false; drawing.ScreenVisibility.ShowPorts = false; NBasicShapeFactory basicShapesFactory = new NBasicShapeFactory(); NFlowchartingShapeFactory flowChartingShapesFactory = new NFlowchartingShapeFactory(); NConnectorShapeFactory connectorShapesFactory = new NConnectorShapeFactory(); // create title NShape titleShape = basicShapesFactory.CreateTextShape("Bubble Sort"); titleShape.SetBounds(GetGridCell(0, 1, 2, 1)); titleShape.TextBlock.FontName = "Arial"; titleShape.TextBlock.FontSize = 40; titleShape.TextBlock.FontStyle = ENFontStyle.Bold; titleShape.TextBlock.Fill = new NColorFill(new NColor(68, 90, 108)); titleShape.TextBlock.Shadow = new NShadow(); activePage.Items.AddChild(titleShape); // begin shape NShape shapeBegin = flowChartingShapesFactory.CreateShape(ENFlowchartingShape.Termination); shapeBegin.SetBounds(GetGridCell(0, 0)); shapeBegin.Text = "BEGIN"; activePage.Items.Add(shapeBegin); // get array item shape NShape shapeGetItem = flowChartingShapesFactory.CreateShape(ENFlowchartingShape.Data); shapeGetItem.SetBounds(GetGridCell(1, 0)); shapeGetItem.Text = "Get array item [1...n]"; activePage.Items.Add(shapeGetItem); // i = 1 shape NShape shapeI1 = flowChartingShapesFactory.CreateShape(ENFlowchartingShape.Process); shapeI1.SetBounds(GetGridCell(2, 0)); shapeI1.Text = "i = 1"; activePage.Items.Add(shapeI1); // j = n shape NShape shapeJEN = flowChartingShapesFactory.CreateShape(ENFlowchartingShape.Process); shapeJEN.SetBounds(GetGridCell(3, 0)); shapeJEN.Text = "j = n"; activePage.Items.Add(shapeJEN); // less comparison shape NShape shapeLess = flowChartingShapesFactory.CreateShape(ENFlowchartingShape.Decision); shapeLess.SetBounds(GetGridCell(4, 0)); shapeLess.Text = "item[i] < item[j - 1]?"; activePage.Items.Add(shapeLess); // swap shape NShape shapeSwap = flowChartingShapesFactory.CreateShape(ENFlowchartingShape.Process); shapeSwap.SetBounds(GetGridCell(4, 1)); shapeSwap.Text = "Swap item[i] and item[j-1]"; activePage.Items.Add(shapeSwap); // j > i + 1? shape NShape shapeJQ = flowChartingShapesFactory.CreateShape(ENFlowchartingShape.Decision); shapeJQ.SetBounds(GetGridCell(5, 0)); shapeJQ.Text = "j = (i + 1)?"; activePage.Items.Add(shapeJQ); // dec j shape NShape shapeDecJ = flowChartingShapesFactory.CreateShape(ENFlowchartingShape.Process); shapeDecJ.SetBounds(GetGridCell(5, 1)); shapeDecJ.Text = "j = j - 1"; activePage.Items.Add(shapeDecJ); // i > n - 1? shape NShape shapeIQ = flowChartingShapesFactory.CreateShape(ENFlowchartingShape.Decision); shapeIQ.SetBounds(GetGridCell(6, 0)); shapeIQ.Text = "i = (n - 1)?"; activePage.Items.Add(shapeIQ); // inc i shape NShape shapeIncI = flowChartingShapesFactory.CreateShape(ENFlowchartingShape.Process); shapeIncI.SetBounds(GetGridCell(6, 1)); shapeIncI.Text = "i = i + 1"; activePage.Items.Add(shapeIncI); // end shape NShape shapeEnd = flowChartingShapesFactory.CreateShape(ENFlowchartingShape.Termination); shapeEnd.SetBounds(GetGridCell(7, 0)); shapeEnd.Text = "END"; activePage.Items.Add(shapeEnd); // connect begin with get array item NShape connector1 = connectorShapesFactory.CreateShape(ENConnectorShape.Line); connector1.UserClass = connectorClass; activePage.Items.AddChild(connector1); connector1.GlueBeginToShape(shapeBegin); connector1.GlueEndToShape(shapeGetItem); // connect get array item with i = 1 NShape connector2 = connectorShapesFactory.CreateShape(ENConnectorShape.Line); connector2.UserClass = connectorClass; activePage.Items.AddChild(connector2); connector2.GlueBeginToShape(shapeGetItem); connector2.GlueEndToShape(shapeI1); // connect i = 1 and j = n NShape connector3 = connectorShapesFactory.CreateShape(ENConnectorShape.Line); connector3.UserClass = connectorClass; activePage.Items.AddChild(connector3); connector3.GlueBeginToShape(shapeI1); connector3.GlueEndToShape(shapeJEN); // connect j = n and item[i] < item[j-1]? NShape connector4 = connectorShapesFactory.CreateShape(ENConnectorShape.Line); connector4.UserClass = connectorClass; activePage.Items.AddChild(connector4); connector4.GlueBeginToShape(shapeJEN); connector4.GlueEndToShape(shapeLess); // connect item[i] < item[j-1]? and j = (i + 1)? NShape connector5 = connectorShapesFactory.CreateShape(ENConnectorShape.Line); connector5.UserClass = connectorClass; connector5.Text = "No"; activePage.Items.AddChild(connector5); connector5.GlueBeginToShape(shapeLess); connector5.GlueEndToShape(shapeJQ); // connect j = (i + 1)? and i = (n - 1)? NShape connector6 = connectorShapesFactory.CreateShape(ENConnectorShape.Line); connector6.UserClass = connectorClass; activePage.Items.AddChild(connector6); connector6.GlueBeginToShape(shapeJQ); connector6.GlueEndToShape(shapeIQ); // connect i = (n - 1) and END NShape connector7 = connectorShapesFactory.CreateShape(ENConnectorShape.Line); connector7.UserClass = connectorClass; activePage.Items.AddChild(connector7); connector7.GlueBeginToShape(shapeIQ); connector7.GlueEndToShape(shapeEnd); // connect item[i] < item[j-1]? and Swap NShape connector8 = connectorShapesFactory.CreateShape(ENConnectorShape.Line); connector8.UserClass = connectorClass; connector8.Text = "Yes"; activePage.Items.AddChild(connector8); connector8.GlueBeginToShape(shapeLess); connector8.GlueEndToShape(shapeSwap); // connect j = (i + 1)? and j = (j - 1) NShape connector9 = connectorShapesFactory.CreateShape(ENConnectorShape.Line); connector9.UserClass = connectorClass; activePage.Items.AddChild(connector9); connector9.GlueBeginToShape(shapeJQ); connector9.GlueEndToShape(shapeDecJ); // connect i = (n - 1)? and i = (i + 1) NShape connector10 = connectorShapesFactory.CreateShape(ENConnectorShape.Line); connector10.UserClass = connectorClass; activePage.Items.AddChild(connector10); connector10.GlueBeginToShape(shapeIQ); connector10.GlueEndToShape(shapeIncI); // connect Swap to No connector NShape connector11 = connectorShapesFactory.CreateShape(ENConnectorShape.TopBottomToSide); connector11.UserClass = connectorClass; activePage.Items.AddChild(connector11); connector11.GlueBeginToShape(shapeSwap); connector11.GlueEndToShape(connector5); // connect i = i + 1 to connector3 NShape connector12 = connectorShapesFactory.CreateSideToSide(m_GridSpacing.Width * 2); connector12.UserClass = connectorClass; activePage.Items.AddChild(connector12); connector12.GlueBeginToPort(shapeIncI.GetPortByName("Right")); connector12.GlueEndToGeometryContour(connector3, 0.5f); // connect j = j - 1 to connector4 NShape connector13 = connectorShapesFactory.CreateSideToSide(m_GridSpacing.Width); connector13.UserClass = connectorClass; activePage.Items.AddChild(connector13); connector13.GlueBeginToPort(shapeDecJ.GetPortByName(("Right"))); connector13.GlueEndToGeometryContour(connector4, 0.5f); }