Nevron .NET Vision Documentation
Clocks

Nevron Chart for .NET has built-in support for display of time information exposed from the NAnalogClockPanel and NDigitalClockPanel showing time in analog and digital fashion respectively. Both panels inherit their functionality from the abstract base NClockPanel class. The following sections describe how you can work with the functionality of these two panels.

Adding a Clock Panel

To create a clock in the control you must create an instance of the NAnalogClockPanel or NDigitalClockPanel classes and add it to the panels collection. The following code shows how to create a digital clock:

C#
Copy Code
NDigitalClockPanel digitalClock = new NDigitalClockPanel();
nChartControl1.Panels.Clear();
nChartControl1.Panels.Add(digitalClock);
Visual Basic
Copy Code
Dim digitalClock As New NDigitalClockPanel
NChartControl1.Panels.Clear()
NChartControl1.Panels.Add(digitalClock)
Clock Time Modes

The clock can operate in several modes as outlined in the following table:

Mode Description
Static The clock displays static time specified through the StaticTime property
UTC The clock will display the current UTC time adjusted with the value of the TimeZone property.
LocalTime The clock will display the local time of the machine running the component. This mode is the default.

To change the current clock mode you need to touch the ClockTimeMode property. The following code snippet will create a digital clock panel that displays the static time 12:00:

C#
Copy Code
NDigitalClockPanel digitalClock = new NDigitalClockPanel();
digitalClock.ClockTimeMode = ClockTimeMode.Static;
digitalClock.StaticTime = new DateTime(2000, 1, 1, 12, 0, 0);
nChartControl1.Panels.Clear();
nChartControl1.Panels.Add(digitalClock);
Visual Basic
Copy Code
Dim digitalClock As New NDigitalClockPanel
digitalClock.ClockTimeMode = ClockTimeMode.Static
digitalClock.StaticTime = New DateTime(2000, 1, 1, 12, 0, 0)
NChartControl1.Panels.Clear()
NChartControl1.Panels.Add(digitalClock)
Clock Display Modes

In cases when you need to display only specific units from the currently displayed time – for example only hours and minutes you can change the ClockDisplayMode property accepting values from the ClockDisplayMode enum. The possible values are shown in the following table:

Mode Description
SecondMillisecond The clock displays seconds and milliseconds
MinuteSecond The clock displays minutes and seconds
HourMinute The clock displays hours and minutes
HourMinuteSecond The clock displays hours, minutes and seconds (default)

The following code will create an analog clock that shows hours, minutes and seconds:

C#
Copy Code
NAnalogClockPanel analogClock = new NAnalogClockPanel();
analogClock.ClockDisplayMode = ClockDisplayMode.HourMinuteSecond;

nChartControl1.Panels.Clear();
nChartControl1.Panels.Add(analogClock);
Visual Basic
Copy Code
Dim analogClock As New NAnalogClockPanel
analogClock.ClockDisplayMode = ClockDisplayMode.HourMinuteSecond

NChartControl1.Panels.Clear()
NChartControl1.Panels.Add(analogClock)
Customizing Digital Clocks Appearance

Digital clocks have controllable cell style that allows you to change the style of the cells representing the time. This is also coupled with full control over the lit and dim fill style for cell segments as well as control over the cell size and segment gaps. The following code will change the digital cell style and fill styles of a digital clock:

C#
Copy Code
NDigitalClockPanel digitalClock = new NDigitalClockPanel();

digitalClock.ClockDisplayMode = ClockDisplayMode.HourMinuteSecond;
digitalClock.LitFillStyle = new NColorFillStyle(Color.DarkRed);
digitalClock.DimFillStyle = new NColorFillStyle(Color.FromArgb(20, Color.DarkRed));
digitalClock.DisplayStyle = DisplayStyle.SevenSegmentRectangular;

nChartControl1.Panels.Clear();
nChartControl1.Panels.Add(digitalClock);
Visual Basic
Copy Code
Dim digitalClock As New NDigitalClockPanel

digitalClock.ClockDisplayMode = ClockDisplayMode.HourMinuteSecond
digitalClock.LitFillStyle = New NColorFillStyle(Color.DarkRed)
digitalClock.DimFillStyle = New NColorFillStyle(Color.FromArgb(20, Color.DarkRed))
digitalClock.DisplayStyle = DisplayStyle.SevenSegmentRectangular

NChartControl1.Panels.Clear()
NChartControl1.Panels.Add(digitalClock)
Customizing Analog Clocks Appearance

You can modify the shape of each arrow (hour, minute and second arrows) by touching the HoursArrow, MinutesArrow and SecondsArrow properties of the panel respectively. Note that these properties return an object of type NNeedleValueIndicator. This suggests that the analog clock internally uses a radial gauge indicator, that is just being configured in a specific way. For more information on working with indicators and gauges please take a look at the gauge indicators topics.

The following code will change appearance of the clock minute and second arrows:

C#
Copy Code
NAnalogClockPanel analogClock = new NAnalogClockPanel();
analogClock.ClockDisplayMode = ClockDisplayMode.HourMinuteSecond;

analogClock.MinutesArrow.Shape.FillStyle = new NColorFillStyle(Color.Green);
analogClock.MinutesArrow.Shape.StrokeStyle = new NStrokeStyle(Color.DarkGreen);

analogClock.SecondsArrow.Shape.FillStyle = new NColorFillStyle(Color.Green);
analogClock.SecondsArrow.Shape.StrokeStyle = new NStrokeStyle(Color.DarkGreen);

nChartControl1.Panels.Clear();
nChartControl1.Panels.Add(analogClock);
Visual Basic
Copy Code
Dim analogClock As New NAnalogClockPanel
analogClock.ClockDisplayMode = ClockDisplayMode.HourMinuteSecond

analogClock.MinutesArrow.Shape.FillStyle = New NColorFillStyle(Color.Green)
analogClock.MinutesArrow.Shape.StrokeStyle = New NStrokeStyle(Color.DarkGreen)

analogClock.SecondsArrow.Shape.FillStyle = New NColorFillStyle(Color.Blue)
analogClock.SecondsArrow.Shape.StrokeStyle = New NStrokeStyle(Color.DarkBlue)

NChartControl1.Panels.Clear()
NChartControl1.Panels.Add(analogClock)
Related Examples

Gauge Gallery \ Clocks \ Digital Clock

Gauge Gallery \ Clocks \ Analog Clock

See Also

 

 


©2017. Nevron Software LLC.

Send Feedback