Nevron Open Vision provides support for drawing of vector based shapes called symbols. The advantage of such vector based shapes over regular raster images is that they do not blur and look nice at any size. This example demonstrates how to create and use predefined symbols. Nevron Open Vision currently provides support for 52 predefined symbols. Use the radio buttons on the right to see the symbols at different sizes.

| Language: C# |
using Nevron.Nov;
using Nevron.Nov.Dom;
using Nevron.Nov.Graphics;
using Nevron.Nov.Layout;
using Nevron.Nov.UI;
using Nevron.Nov.Windows.Forms;
using System;
using System.Globalization;
using System.Windows.Forms;
namespace NovWinFormsProject
{
public partial class Form1 : Form
{
#region Constructors
public Form1()
{
InitializeComponent();
// Set form title
Text = "NOV WinForms - NPredefinedSymbolsExample";
// 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()
{
m_SymbolsTable = new NTableFlowPanel();
m_SymbolsTable.BackgroundFill = new NColorFill(NColor.White);
m_SymbolsTable.HorizontalSpacing = NDesign.HorizontalSpacing * 3;
m_SymbolsTable.VerticalSpacing = NDesign.VerticalSpacing * 3;
m_SymbolsTable.Direction = ENHVDirection.LeftToRight;
m_SymbolsTable.MaxOrdinal = 4;
m_SymbolsTable.Padding = new NMargins(NDesign.HorizontalSpacing, NDesign.VerticalSpacing,
NDesign.HorizontalSpacing * 6, NDesign.VerticalSpacing);
RecreateSymbols();
NScrollContent scrollContent = new NScrollContent(m_SymbolsTable);
scrollContent.HorizontalPlacement = ENHorizontalPlacement.Left;
return scrollContent;
}
public NWidget CreateExampleControls()
{
NStackPanel stack = new NStackPanel();
// Create the color box
m_ColorBox = new NColorBox();
m_ColorBox.SelectedColor = DefaultSymbolColor;
m_ColorBox.SelectedColorChanged += OnColorBoxSelectedColorChanged;
stack.Add(NPairBox.Create("Color:", m_ColorBox));
// Create the size radio button group
NStackPanel radioStack = new NStackPanel();
double size = MinSymbolSize;
int selectedIndex = 0;
for (int i = 0; i < 4; i++)
{
if (size == DefaultSymbolSize)
{
selectedIndex = i;
}
string sizeStr = size.ToString(CultureInfo.InvariantCulture);
NRadioButton radioButton = new NRadioButton(sizeStr + "x" + sizeStr);
radioStack.Add(radioButton);
size *= 2;
}
m_RadioGroup = new NRadioButtonGroup(radioStack);
m_RadioGroup.SelectedIndex = 1;
m_RadioGroup.SelectedIndexChanged += OnRadioGroupSelectedIndexChanged;
NPairBox pairBox = NPairBox.Create("Size:", m_RadioGroup);
pairBox.Box1.VerticalPlacement = ENVerticalPlacement.Top;
stack.Add(pairBox);
return new NUniSizeBoxGroup(stack);
}
public string GetExampleDescription()
{
int symbolCount = NEnum.GetValues().Length;
string symbolCountStr = symbolCount.ToString(CultureInfo.InvariantCulture);
return @"
Nevron Open Vision provides support for drawing of vector based shapes called symbols. The advantage of such vector
based shapes over regular raster images is that they do not blur and look nice at any size. This example demonstrates
how to create and use predefined symbols. Nevron Open Vision currently provides support for " + symbolCountStr + @"
predefined symbols. Use the radio buttons on the right to see the symbols at different sizes.
";
}
///
/// Gets the relevant documentation links for the example
///
///
public (string Name, string Url)[] GetDocumentationUrls()
{
return new[]
{
("Symbols", "https://www.nevron.com/docs/openvision/ui-symbols.html"),
("Widget Elements", "https://www.nevron.com/docs/openvision/ui-widget-elements.html"),
};
}
#endregion
#region Implementation
private void RecreateSymbols()
{
NColor color = m_ColorBox != null ? m_ColorBox.SelectedColor : DefaultSymbolColor;
double length = m_RadioGroup != null ? MinSymbolSize * Math.Pow(2, m_RadioGroup.SelectedIndex) : DefaultSymbolSize;
NSize size = new NSize(length, length);
m_SymbolsTable.Clear();
ENSymbolShape[] symbolShapes = NEnum.GetValues();
int count = symbolShapes.Length / 2 + symbolShapes.Length % 2;
for (int i = 0; i < count; i++)
{
// Add a symbol box to the first column
int column1Index = i;
AddSymbolBox(symbolShapes[column1Index], size, color);
// Add a symbol box to the second column
int column2Index = count + i;
if (column2Index < symbolShapes.Length)
{
NSymbolBox symbolBox = AddSymbolBox(symbolShapes[column2Index], size, color);
symbolBox.Margins = new NMargins(NDesign.HorizontalSpacing * 10, 0, 0, 0);
}
}
}
private NSymbolBox AddSymbolBox(ENSymbolShape symbolShape, NSize size, NColor color)
{
NSymbol symbol = NSymbol.Create(symbolShape, size, color);
NSymbolBox symbolBox = new NSymbolBox(symbol);
m_SymbolsTable.Add(symbolBox);
NLabel label = new NLabel(NStringHelpers.InsertSpacesBeforeUppersAndDigits(symbolShape.ToString()));
label.VerticalPlacement = ENVerticalPlacement.Center;
m_SymbolsTable.Add(label);
return symbolBox;
}
#endregion
#region Event Handlers
private void OnColorBoxSelectedColorChanged(NValueChangeEventArgs arg)
{
RecreateSymbols();
}
private void OnRadioGroupSelectedIndexChanged(NValueChangeEventArgs arg)
{
RecreateSymbols();
}
#endregion
#region Fields
private NTableFlowPanel m_SymbolsTable;
private NColorBox m_ColorBox;
private NRadioButtonGroup m_RadioGroup;
#endregion
#region Static Methods
#endregion
#region Constants
private const double MinSymbolSize = 16;
private const double DefaultSymbolSize = 32;
private static readonly NColor DefaultSymbolColor = NColor.MediumBlue;
#endregion
#region Nested Types
#endregion
}
}