Demonstrates how to create a soccer tournament scoreboard using the following NOV Diagram features:

| Language: C# |
using Nevron.Nov;
using Nevron.Nov.DataStructures;
using Nevron.Nov.Diagram;
using Nevron.Nov.Diagram.Layout;
using Nevron.Nov.Diagram.Themes;
using Nevron.Nov.Dom;
using Nevron.Nov.Graphics;
using Nevron.Nov.Layout;
using Nevron.Nov.Text;
using Nevron.Nov.UI;
using Nevron.Nov.Windows.Forms;
using System.Windows.Forms;
namespace NovWinFormsProject
{
public partial class Form1 : Form
{
#region Constructors
public Form1()
{
InitializeComponent();
// Set form title
Text = "NOV WinForms - NSoccerTournamentExample";
// 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;
// hide grid and ports
m_DrawingView.Content.ScreenVisibility.ShowGrid = false;
m_DrawingView.Content.ScreenVisibility.ShowPorts = false;
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 soccer tournament scoreboard using the following NOV Diagram features:
- Theme-based colors for the title - change the page theme from the ""Design"" tab to see how the style of the title will change, too.
- Table blocks - used for the match shapes.
- Layered Graph Layout - used to arrange the shapes.
";
}
///
/// Gets the relevant documentation links for the example
///
///
public (string Name, string Url)[] GetDocumentationUrls()
{
return new[]
{
("Shapes", "https://www.nevron.com/docs/openvision/diagram-shapes.html"),
("Text Block", "https://www.nevron.com/docs/openvision/diagram-text-block.html"),
("Routable Connectors", "https://www.nevron.com/docs/openvision/diagram-routable-connectors.html"),
};
}
private void InitDiagram(NDrawingDocument drawingDocument)
{
NPage page = drawingDocument.Content.ActivePage;
// Create a title shape
NShape titleShape = CreateTitleShape("FIFA World Cup 2022");
page.Items.Add(titleShape);
// Create the match shapes
NShape[] roundOf16Shapes = CreateMatchShapes(page, RoundOf16);
NShape[] quarterFinalsShapes = CreateMatchShapes(page, QuarterFinals);
NShape[] semiFinalsShapes = CreateMatchShapes(page, SemiFinals);
NShape finalShape = CreateMatchShape(Final);
page.Items.Add(finalShape);
// Connect the shapes
for (int i = 0; i < quarterFinalsShapes.Length; i++)
{
ConnectShapes(roundOf16Shapes[i * 2], roundOf16Shapes[i * 2 + 1], quarterFinalsShapes[i]);
}
ConnectShapes(quarterFinalsShapes[0], quarterFinalsShapes[1], semiFinalsShapes[0]);
ConnectShapes(quarterFinalsShapes[2], quarterFinalsShapes[3], semiFinalsShapes[1]);
ConnectShapes(semiFinalsShapes[0], semiFinalsShapes[1], finalShape);
// Arrange the shapes using a Layered Graph Layout
NLayeredGraphLayout layout = new NLayeredGraphLayout();
layout.Direction = ENHVDirection.LeftToRight;
layout.UseSingleBus = true;
layout.PlugSpacing.Mode = ENPlugSpacingMode.None;
layout.RegionLayout.VerticalSpacing = 25; // Controls the spacing between the title and the diagram
NList shapes = page.GetShapes(false, NDiagramFilters.ShapeType2D);
layout.Arrange(shapes.CastAll