Chart for .NET / User's Guide / Panels / Watermarks

Watermarks

Watermarks are represented by NWatermark object that extends the NAutoSizeableDockPanel. Watermarks allow you to display an arbitrary fill style image, gradient etc. in the control canvas. The following code creates a new watermark and adds it to the chart:

C#
Copy Code
NWatermark watermark = new NWatermark();
watermark.FillStyle = new NImageFillStyle("c:\\windows\\Coffee Bean.bmp");
chartControl.Panels.Add(watermark);
Visual Basic
Copy Code
Dim watermark As New NWatermark
watermark.FillStyle = New NImageFillStyle("c:\\windows\\Coffee Bean.bmp")
chartControl.Panels.Add(watermark)

One common usage of watermarks is to apply a background filling for other panels.

 Dynamic Watermarks

The NImageFillStyle object allows you to display bitmaps created on the fly. This allows you to build dynamic watermarks that seamlessly integrate with the rest of the panels in the chart. The following code generates a simple bitmap containing some text and passes it to the watermark.

C#
Copy Code
NWatermark watermark = new NWatermark();

Bitmap simpleDrawing = new Bitmap(260, 70);
Graphics graphics = Graphics.FromImage(simpleDrawing);
Font font = new Font("Arial", 14);
Brush brush = new SolidBrush(Color.Blue);

graphics.Clear(Color.FromArgb(0, 255, 255, 255));
graphics.DrawString("Car sales this year have\r\nbeaten all expectations", font, brush, new RectangleF(10, 10, 240, 50));

graphics.Dispose();
font.Dispose();
brush.Dispose();

watermark.FillStyle = new NImageFillStyle(simpleDrawing);
watermark.StandardFrameStyle.SetPredefinedFrameStyle(PredefinedStandardFrame.None);
chartControl.Panels.Add(watermark);
Visual Basic
Copy Code
Dim watermark As New NWatermark

Dim simpleDrawing As New Bitmap(260, 70)
Dim graphics As Graphics = graphics.FromImage(simpleDrawing)
Dim font As New Font("Arial", 14)
Dim brush As New SolidBrush(Color.Blue)

graphics.Clear(Color.FromArgb(0, 255, 255, 255))
graphics.DrawString("Car sales this year have" + Environment.NewLine + "beaten all expectations", font, brush, New RectangleF(10, 10, 240, 50))

graphics.Dispose()
font.Dispose()
brush.Dispose()

watermark.FillStyle = New NImageFillStyle(simpleDrawing)
watermark.StandardFrameStyle.SetPredefinedFrameStyle(PredefinedStandardFrame.None)
chartControl.Panels.Add(watermark)
Each watermark has an applied standard frame style. Note that the code above disables it. For more information on frame styles take a look at the Nevron Presentation Framework User's Guide.
 Related Examples

Windows forms: Panels\Watermarks\General

Web forms: Panels\Watermarks\General

See Also