Academic Company Events NI Developer Zone Support Solutions Products & Services Contact NI MyNI
What is Developer Zone?
United States

Document TypeTutorial
NI Supported: Yes
Publish Date: Dec 02, 2009


Feedback


Yes No

Related Categories

Related Links - Developer Zone

Related Links -Products and Services

Creating a Custom Line Style for the Measurement Studio Web Forms Graph .NET Controls

0 Ratings | 0.00 out of 5
 Print |  PDF

Overview

With Measurement Studio .NET user interface controls, you can extend various visual elements, such as point styles and borders. You can develop these extensions independent of their context and apply them to any object that accepts the extended type.

Line style is one example of a visual element that you can extend to provide a style that is not already available. To create a custom line style, derive a class from the LineStyle base class. In the derived class, you must provide an implementation for the abstract CreatePen method.

The attached example details the implementation of a custom line style that draws a gradient from red to blue in the plot area of a graph. Use this extended line style for the Plot.LineStyle, Cursor.LineStyle, and CartesianPlot.LineToBaseStyle property values. To implement this custom line style, create a Pen object from a LinearGradientBrush object using the width specified in the LineStyleDrawArgs argument to CreatePen.

Note: When implementing CreatePen, you must ensure that a null reference (Nothing in Visual Basic) is not returned. Implementations of CreatePen must also always create a new Pen object and not return one of the SystemPens objects.

VB.NET

WaveformGraph1.Plots(0).LineStyle = New GradientLineStyle

Dim sineSignal As New SineSignal(1)
Dim data As Double() = sineSignal.Generate(100, 100)
WaveformGraph1.PlotY(data)

C#

waveformGraph1.Plots[0].LineStyle = new GradientLineStyle();

SineSignal sineSignal = new SineSignal(1);
double[] data = sineSignal.Generate(100, 100);
waveformGraph1.PlotY(data);

The following image shows the effect of using the custom line style on a waveform graph:

Downloads

customlinestyle.cs

customlinestyle.vb

0 Ratings | 0.00 out of 5
 Print |  PDF

Reader Comments | Submit a comment »

 

Legal
This tutorial (this "tutorial") was developed by National Instruments ("NI"). Although technical support of this tutorial may be made available by National Instruments, the content in this tutorial may not be completely tested and verified, and NI does not guarantee its quality in any way or that NI will continue to support this content with each new revision of related products and drivers. THIS TUTORIAL IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND AND SUBJECT TO CERTAIN RESTRICTIONS AS MORE SPECIFICALLY SET FORTH IN NI.COM'S TERMS OF USE (http://ni.com/legal/termsofuse/unitedstates/us/).