This example demonstrates how to create and use progress bars. The progress bar is a widget that fills to indicate the progress of an operation. The Style property determines whether it is horizontally, vertically oriented or circular. The Minimum and Maximum properties determine the start and the end of the operation and the Value property indicates its current progress. All progress bars can have a label and its style is controlled through the LabelStyle property. Circular progress bars let you specify the width of their rim in percent relative to the size of the progress bar as this example demonstrates.
The Mode property determines the progress bar mode and can be:

| 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.Windows.Forms;
namespace NovWinFormsProject
{
public partial class Form1 : Form
{
#region Constructors
public Form1()
{
InitializeComponent();
// Set form title
Text = "NOV WinForms - NProgressBarExample";
// 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()
{
NStackPanel stack = new NStackPanel();
stack.HorizontalPlacement = ENHorizontalPlacement.Left;
stack.VerticalPlacement = ENVerticalPlacement.Top;
// Horizontal progress bar
m_HorizontalProgressBar = new NProgressBar();
m_HorizontalProgressBar.Style = ENProgressBarStyle.Horizontal;
m_HorizontalProgressBar.Mode = DefaultMode;
m_HorizontalProgressBar.Value = DefaultValue;
m_HorizontalProgressBar.BufferedValue = DefaultBufferedValue;
m_HorizontalProgressBar.PreferredSize = new NSize(300, 30);
m_HorizontalProgressBar.VerticalPlacement = ENVerticalPlacement.Top;
stack.Add(new NGroupBox("Horizontal", m_HorizontalProgressBar));
// Vertical progress bar
m_VerticalProgressBar = new NProgressBar();
m_VerticalProgressBar.Style = ENProgressBarStyle.Vertical;
m_VerticalProgressBar.Mode = DefaultMode;
m_VerticalProgressBar.Value = DefaultValue;
m_VerticalProgressBar.BufferedValue = DefaultBufferedValue;
m_VerticalProgressBar.PreferredSize = new NSize(30, 300);
m_VerticalProgressBar.HorizontalPlacement = ENHorizontalPlacement.Left;
stack.Add(new NGroupBox("Vertical", m_VerticalProgressBar));
// Circular progress bar - 50% rim
m_CircularProgressBar1 = new NProgressBar();
m_CircularProgressBar1.Style = ENProgressBarStyle.Circular;
m_CircularProgressBar1.Mode = DefaultMode;
m_CircularProgressBar1.Value = DefaultValue;
m_CircularProgressBar1.BufferedValue = DefaultBufferedValue;
m_CircularProgressBar1.PreferredSize = new NSize(150, 150);
// Circular progress bar - 100% rim
m_CircularProgressBar2 = new NProgressBar();
m_CircularProgressBar2.Style = ENProgressBarStyle.Circular;
m_CircularProgressBar2.Mode = DefaultMode;
m_CircularProgressBar2.Value = DefaultValue;
m_CircularProgressBar2.BufferedValue = DefaultBufferedValue;
m_CircularProgressBar2.RimWidthPercent = 100;
m_CircularProgressBar2.PreferredSize = new NSize(150, 150);
NPairBox pairBox = new NPairBox(m_CircularProgressBar1, m_CircularProgressBar2);
pairBox.Spacing = 30;
stack.Add(new NGroupBox("Circular", pairBox));
// Create the Progress bars array
m_ProgressBars = new NProgressBar[4];
m_ProgressBars[0] = m_HorizontalProgressBar;
m_ProgressBars[1] = m_VerticalProgressBar;
m_ProgressBars[2] = m_CircularProgressBar1;
m_ProgressBars[3] = m_CircularProgressBar2;
return stack;
}
public NWidget CreateExampleControls()
{
NStackPanel stack = new NStackPanel();
stack.HorizontalPlacement = ENHorizontalPlacement.Left;
stack.Direction = ENHVDirection.TopToBottom;
// The Mode combo box
NComboBox comboBox = new NComboBox();
comboBox.Items.FillFromEnum();
comboBox.SelectedIndex = (int)m_HorizontalProgressBar.Mode;
comboBox.SelectedIndexChanged += OnModeSelected;
stack.Add(NPairBox.Create("Mode:", comboBox));
// The Label style combo box
comboBox = new NComboBox();
comboBox.Items.FillFromEnum();
comboBox.SelectedIndex = (int)m_HorizontalProgressBar.LabelStyle;
comboBox.SelectedIndexChanged += OnLabelStyleSelected;
stack.Add(NPairBox.Create("Label Style:", comboBox));
// The Value numeric up down
NNumericUpDown valueUpDown = new NNumericUpDown(0, 100, DefaultValue);
valueUpDown.ValueChanged += OnValueChanged;
m_ValuePairBox = NPairBox.Create("Value:", valueUpDown);
stack.Add(m_ValuePairBox);
// The Buffered value numeric up down
NNumericUpDown bufferedValueUpDown = new NNumericUpDown(0, 100, DefaultBufferedValue);
bufferedValueUpDown.ValueChanged += OnBufferedValueChanged;
m_BufferedValuePairBox = NPairBox.Create("Buffered Value:", bufferedValueUpDown);
stack.Add(m_BufferedValuePairBox);
// The Indeterminate part size numeric up down
NNumericUpDown indeterminateSizeUpDown = new NNumericUpDown(1, 100, 25);
indeterminateSizeUpDown.ValueChanged += OnIndeterminateSizeUpDownValueChanged;
m_IndeterminatePartSizePairBox = NPairBox.Create("Indeterminate Size (%):", indeterminateSizeUpDown);
stack.Add(m_IndeterminatePartSizePairBox);
// The Animation speed numeric up down
NNumericUpDown animationSpeedUpDown = new NNumericUpDown(0.1, 99, 2);
animationSpeedUpDown.DecimalPlaces = 1;
animationSpeedUpDown.Step = 0.1;
animationSpeedUpDown.ValueChanged += OnAnimationSpeedUpDownValueChanged;
m_AnimationSpeedPairBox = NPairBox.Create("Animation Speed (%):", animationSpeedUpDown);
stack.Add(m_AnimationSpeedPairBox);
// Update controls visibility
UpdateControlsVisibility(DefaultMode);
return new NUniSizeBoxGroup(stack);
}
public string GetExampleDescription()
{
return @"
This example demonstrates how to create and use progress bars. The progress bar is a widget that
fills to indicate the progress of an operation. The Style property determines whether
it is horizontally, vertically oriented or circular. The Minimum and Maximum properties
determine the start and the end of the operation and the Value property indicates its current progress.
All progress bars can have a label and its style is controlled through the LabelStyle property.
Circular progress bars let you specify the width of their rim in percent relative to the size of the
progress bar as this example demonstrates.
The Mode property determines the progress bar mode and can be:
- Determinate - the progress bar shows the progress of an operation from 0 to 100%. This is the default mode.
- Indeterminate - the progress bar shows an animation indicating that a long-running operation is executing. No specific
progress is shown. This mode should be used for operations whose progress cannot be estimated, for example a long-running database query.
- Buffered - the progress bar shows the progress of an operation from 0 to 100%. It also additionally shows the buffered
value of the operation with a lighter color. The buffered value is specified through the BufferedValue property.
";
}
///
/// Gets the relevant documentation links for the example
///
///
public (string Name, string Url)[] GetDocumentationUrls()
{
return new[]
{
("Progress Bar", "https://www.nevron.com/docs/openvision/ui-progress-bar.html"),
("Range Based Widgets Overview", "https://www.nevron.com/docs/openvision/ui-range-based-widgets-overview.html"),
};
}
#endregion
#region Implementation
private void UpdateControlsVisibility(ENProgressBarMode mode)
{
switch (mode)
{
case ENProgressBarMode.Determinate:
m_ValuePairBox.Visibility = ENVisibility.Visible;
m_BufferedValuePairBox.Visibility = ENVisibility.Collapsed;
m_IndeterminatePartSizePairBox.Visibility = ENVisibility.Collapsed;
m_AnimationSpeedPairBox.Visibility = ENVisibility.Collapsed;
break;
case ENProgressBarMode.Indeterminate:
m_ValuePairBox.Visibility = ENVisibility.Collapsed;
m_BufferedValuePairBox.Visibility = ENVisibility.Collapsed;
m_IndeterminatePartSizePairBox.Visibility = ENVisibility.Visible;
m_AnimationSpeedPairBox.Visibility = ENVisibility.Visible;
break;
case ENProgressBarMode.Buffered:
m_ValuePairBox.Visibility = ENVisibility.Visible;
m_BufferedValuePairBox.Visibility = ENVisibility.Visible;
m_IndeterminatePartSizePairBox.Visibility = ENVisibility.Collapsed;
m_AnimationSpeedPairBox.Visibility = ENVisibility.Collapsed;
break;
}
}
#endregion
#region Event Handlers
private void OnModeSelected(NValueChangeEventArgs arg)
{
ENProgressBarMode mode = (ENProgressBarMode)(int)arg.NewValue;
for (int i = 0; i < m_ProgressBars.Length; i++)
{
m_ProgressBars[i].Mode = mode;
}
UpdateControlsVisibility(mode);
}
private void OnLabelStyleSelected(NValueChangeEventArgs arg)
{
ENProgressBarLabelStyle labelStyle = (ENProgressBarLabelStyle)(int)arg.NewValue;
for (int i = 0; i < m_ProgressBars.Length; i++)
{
m_ProgressBars[i].LabelStyle = labelStyle;
}
}
private void OnValueChanged(NValueChangeEventArgs args)
{
double value = (double)args.NewValue;
for (int i = 0; i < m_ProgressBars.Length; i++)
{
m_ProgressBars[i].Value = value;
}
}
private void OnBufferedValueChanged(NValueChangeEventArgs args)
{
double bufferedValue = (double)args.NewValue;
for (int i = 0; i < m_ProgressBars.Length; i++)
{
m_ProgressBars[i].BufferedValue = bufferedValue;
}
}
private void OnIndeterminateSizeUpDownValueChanged(NValueChangeEventArgs arg)
{
double indeterminateSize = (double)arg.NewValue;
for (int i = 0; i < m_ProgressBars.Length; i++)
{
m_ProgressBars[i].IndeterminatePartSizePercent = indeterminateSize;
}
}
private void OnAnimationSpeedUpDownValueChanged(NValueChangeEventArgs arg)
{
double animationSpeed = (double)arg.NewValue;
for (int i = 0; i < m_ProgressBars.Length; i++)
{
m_ProgressBars[i].AnimationSpeed = animationSpeed;
}
}
#endregion
#region Fields
private NProgressBar m_HorizontalProgressBar;
private NProgressBar m_VerticalProgressBar;
private NProgressBar m_CircularProgressBar1;
private NProgressBar m_CircularProgressBar2;
private NProgressBar[] m_ProgressBars;
private NPairBox m_ValuePairBox;
private NPairBox m_BufferedValuePairBox;
private NPairBox m_IndeterminatePartSizePairBox;
private NPairBox m_AnimationSpeedPairBox;
#endregion
#region Static Methods
#endregion
#region Constants
private const ENProgressBarMode DefaultMode = ENProgressBarMode.Buffered;
private const double DefaultValue = 40;
private const double DefaultBufferedValue = 60;
#endregion
#region Nested Types
#endregion
}
} | Language: VB.NET |
Imports Nevron.Nov
Imports Nevron.Nov.Dom
Imports Nevron.Nov.Graphics
Imports Nevron.Nov.Layout
Imports Nevron.Nov.UI
Imports Nevron.Nov.Windows.Forms
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 - NProgressBarExample"
' 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
Dim stack As NStackPanel = New NStackPanel()
stack.HorizontalPlacement = ENHorizontalPlacement.Left
stack.VerticalPlacement = ENVerticalPlacement.Top
' Horizontal progress bar
m_HorizontalProgressBar = New NProgressBar()
m_HorizontalProgressBar.Style = ENProgressBarStyle.Horizontal
m_HorizontalProgressBar.Mode = DefaultMode
m_HorizontalProgressBar.Value = DefaultValue
m_HorizontalProgressBar.BufferedValue = DefaultBufferedValue
m_HorizontalProgressBar.PreferredSize = New NSize(300, 30)
m_HorizontalProgressBar.VerticalPlacement = ENVerticalPlacement.Top
stack.Add(New NGroupBox("Horizontal", m_HorizontalProgressBar))
' Vertical progress bar
m_VerticalProgressBar = New NProgressBar()
m_VerticalProgressBar.Style = ENProgressBarStyle.Vertical
m_VerticalProgressBar.Mode = DefaultMode
m_VerticalProgressBar.Value = DefaultValue
m_VerticalProgressBar.BufferedValue = DefaultBufferedValue
m_VerticalProgressBar.PreferredSize = New NSize(30, 300)
m_VerticalProgressBar.HorizontalPlacement = ENHorizontalPlacement.Left
stack.Add(New NGroupBox("Vertical", m_VerticalProgressBar))
' Circular progress bar - 50% rim
m_CircularProgressBar1 = New NProgressBar()
m_CircularProgressBar1.Style = ENProgressBarStyle.Circular
m_CircularProgressBar1.Mode = DefaultMode
m_CircularProgressBar1.Value = DefaultValue
m_CircularProgressBar1.BufferedValue = DefaultBufferedValue
m_CircularProgressBar1.PreferredSize = New NSize(150, 150)
' Circular progress bar - 100% rim
m_CircularProgressBar2 = New NProgressBar()
m_CircularProgressBar2.Style = ENProgressBarStyle.Circular
m_CircularProgressBar2.Mode = DefaultMode
m_CircularProgressBar2.Value = DefaultValue
m_CircularProgressBar2.BufferedValue = DefaultBufferedValue
m_CircularProgressBar2.RimWidthPercent = 100
m_CircularProgressBar2.PreferredSize = New NSize(150, 150)
Dim pairBox As NPairBox = New NPairBox(m_CircularProgressBar1, m_CircularProgressBar2)
pairBox.Spacing = 30
stack.Add(New NGroupBox("Circular", pairBox))
' Create the Progress bars array
m_ProgressBars = New NProgressBar(3) {}
m_ProgressBars(0) = m_HorizontalProgressBar
m_ProgressBars(1) = m_VerticalProgressBar
m_ProgressBars(2) = m_CircularProgressBar1
m_ProgressBars(3) = m_CircularProgressBar2
Return stack
End Function
Public Function CreateExampleControls() As NWidget
Dim stack As NStackPanel = New NStackPanel()
stack.HorizontalPlacement = ENHorizontalPlacement.Left
stack.Direction = ENHVDirection.TopToBottom
' The Mode combo box
Dim comboBox As NComboBox = New NComboBox()
comboBox.Items.FillFromEnum(Of ENProgressBarMode)()
comboBox.SelectedIndex = m_HorizontalProgressBar.Mode
comboBox.SelectedIndexChanged += AddressOf OnModeSelected
stack.Add(NPairBox.Create("Mode:", comboBox))
' The Label style combo box
comboBox = New NComboBox()
comboBox.Items.FillFromEnum(Of ENProgressBarLabelStyle)()
comboBox.SelectedIndex = m_HorizontalProgressBar.LabelStyle
comboBox.SelectedIndexChanged += AddressOf OnLabelStyleSelected
stack.Add(NPairBox.Create("Label Style:", comboBox))
' The Value numeric up down
Dim valueUpDown As NNumericUpDown = New NNumericUpDown(0, 100, DefaultValue)
valueUpDown.ValueChanged += AddressOf OnValueChanged
m_ValuePairBox = NPairBox.Create("Value:", valueUpDown)
stack.Add(m_ValuePairBox)
' The Buffered value numeric up down
Dim bufferedValueUpDown As NNumericUpDown = New NNumericUpDown(0, 100, DefaultBufferedValue)
bufferedValueUpDown.ValueChanged += AddressOf OnBufferedValueChanged
m_BufferedValuePairBox = NPairBox.Create("Buffered Value:", bufferedValueUpDown)
stack.Add(m_BufferedValuePairBox)
' The Indeterminate part size numeric up down
Dim indeterminateSizeUpDown As NNumericUpDown = New NNumericUpDown(1, 100, 25)
indeterminateSizeUpDown.ValueChanged += AddressOf OnIndeterminateSizeUpDownValueChanged
m_IndeterminatePartSizePairBox = NPairBox.Create("Indeterminate Size (%):", indeterminateSizeUpDown)
stack.Add(m_IndeterminatePartSizePairBox)
' The Animation speed numeric up down
Dim animationSpeedUpDown As NNumericUpDown = New NNumericUpDown(0.1, 99, 2)
animationSpeedUpDown.DecimalPlaces = 1
animationSpeedUpDown.Step = 0.1
animationSpeedUpDown.ValueChanged += AddressOf OnAnimationSpeedUpDownValueChanged
m_AnimationSpeedPairBox = NPairBox.Create("Animation Speed (%):", animationSpeedUpDown)
stack.Add(m_AnimationSpeedPairBox)
' Update controls visibility
UpdateControlsVisibility(DefaultMode)
Return New NUniSizeBoxGroup(stack)
End Function
Public Function GetExampleDescription() As String
Return "
This example demonstrates how to create and use progress bars. The progress bar is a widget that
fills to indicate the progress of an operation. The Style property determines whether
it is horizontally, vertically oriented or circular. The Minimum and Maximum properties
determine the start and the end of the operation and the Value property indicates its current progress.
All progress bars can have a label and its style is controlled through the LabelStyle property.
Circular progress bars let you specify the width of their rim in percent relative to the size of the
progress bar as this example demonstrates.
The Mode property determines the progress bar mode and can be:
- Determinate - the progress bar shows the progress of an operation from 0 to 100%. This is the default mode.
- Indeterminate - the progress bar shows an animation indicating that a long-running operation is executing. No specific
progress is shown. This mode should be used for operations whose progress cannot be estimated, for example a long-running database query.
- Buffered - the progress bar shows the progress of an operation from 0 to 100%. It also additionally shows the buffered
value of the operation with a lighter color. The buffered value is specified through the BufferedValue property.
"
End Function
'''
''' Gets the relevant documentation links for the example
'''
'''
Public Function GetDocumentationUrls() As (String, String)()
Return {("Progress Bar", "https://www.nevron.com/docs/openvision/ui-progress-bar.html"), ("Range Based Widgets Overview", "https://www.nevron.com/docs/openvision/ui-range-based-widgets-overview.html")}
End Function
#End Region
#Region "Implementation"
Private Sub UpdateControlsVisibility(mode As ENProgressBarMode)
Select Case mode
Case ENProgressBarMode.Determinate
m_ValuePairBox.Visibility = ENVisibility.Visible
m_BufferedValuePairBox.Visibility = ENVisibility.Collapsed
m_IndeterminatePartSizePairBox.Visibility = ENVisibility.Collapsed
m_AnimationSpeedPairBox.Visibility = ENVisibility.Collapsed
Case ENProgressBarMode.Indeterminate
m_ValuePairBox.Visibility = ENVisibility.Collapsed
m_BufferedValuePairBox.Visibility = ENVisibility.Collapsed
m_IndeterminatePartSizePairBox.Visibility = ENVisibility.Visible
m_AnimationSpeedPairBox.Visibility = ENVisibility.Visible
Case ENProgressBarMode.Buffered
m_ValuePairBox.Visibility = ENVisibility.Visible
m_BufferedValuePairBox.Visibility = ENVisibility.Visible
m_IndeterminatePartSizePairBox.Visibility = ENVisibility.Collapsed
m_AnimationSpeedPairBox.Visibility = ENVisibility.Collapsed
End Select
End Sub
#End Region
#Region "Event Handlers"
Private Sub OnModeSelected(arg As NValueChangeEventArgs)
Dim mode As ENProgressBarMode = arg.NewValue
For i = 0 To m_ProgressBars.Length - 1
m_ProgressBars(i).Mode = mode
Next
UpdateControlsVisibility(mode)
End Sub
Private Sub OnLabelStyleSelected(arg As NValueChangeEventArgs)
Dim labelStyle As ENProgressBarLabelStyle = arg.NewValue
For i = 0 To m_ProgressBars.Length - 1
m_ProgressBars(i).LabelStyle = labelStyle
Next
End Sub
Private Sub OnValueChanged(args As NValueChangeEventArgs)
Dim value As Double = args.NewValue
For i = 0 To m_ProgressBars.Length - 1
m_ProgressBars(i).Value = value
Next
End Sub
Private Sub OnBufferedValueChanged(args As NValueChangeEventArgs)
Dim bufferedValue As Double = args.NewValue
For i = 0 To m_ProgressBars.Length - 1
m_ProgressBars(i).BufferedValue = bufferedValue
Next
End Sub
Private Sub OnIndeterminateSizeUpDownValueChanged(arg As NValueChangeEventArgs)
Dim indeterminateSize As Double = arg.NewValue
For i = 0 To m_ProgressBars.Length - 1
m_ProgressBars(i).IndeterminatePartSizePercent = indeterminateSize
Next
End Sub
Private Sub OnAnimationSpeedUpDownValueChanged(arg As NValueChangeEventArgs)
Dim animationSpeed As Double = arg.NewValue
For i = 0 To m_ProgressBars.Length - 1
m_ProgressBars(i).AnimationSpeed = animationSpeed
Next
End Sub
#End Region
#Region "Fields"
Private m_HorizontalProgressBar As NProgressBar
Private m_VerticalProgressBar As NProgressBar
Private m_CircularProgressBar1 As NProgressBar
Private m_CircularProgressBar2 As NProgressBar
Private m_ProgressBars As NProgressBar()
Private m_ValuePairBox As NPairBox
Private m_BufferedValuePairBox As NPairBox
Private m_IndeterminatePartSizePairBox As NPairBox
Private m_AnimationSpeedPairBox As NPairBox
#End Region
#Region "Static Methods"
#End Region
#Region "Constants"
Private Const DefaultMode As ENProgressBarMode = ENProgressBarMode.Buffered
Private Const DefaultValue As Double = 40
Private Const DefaultBufferedValue As Double = 60
#End Region
#Region "Nested Types"
#End Region
End Class