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) |