Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
1833
Watermark
posted

Whats the easiest way of creating a watermark on the chart such that it will be visible when using UltraChart1.CopyToClipboard()?

It would be good if I could get it to match the example provided in the thread... http://community.infragistics.com/forums/p/28501/119654.aspx#119654

Thanks

 

  • 28496
    Suggested Answer
    Offline posted

    easiest way:

                BoxAnnotation anno = new BoxAnnotation();
                anno.TextStyle.FontColor = Color.Black;
                anno.Text = "SEAL OF APPROVAL";
                anno.TextStyle.Font = new Font("Arial", 30f, FontStyle.Bold);
                anno.TextStyle.HorizontalAlign = StringAlignment.Near;
                anno.TextStyle.VerticalAlign = StringAlignment.Near;
                anno.Location.Type = LocationType.Percentage;
                anno.Location.LocationX = anno.Location.LocationY = 50;
                anno.PE.StrokeOpacity = 0;
             
                ch.Annotations.Add(anno);

    best way:

    void ch_FillSceneGraph(object sender, FillSceneGraphEventArgs e)
            {
                Rectangle bounds = e.ChartCore.GetBorderLayer().OuterBound;
                Path pathPrimitive = new Path();
                pathPrimitive.GraphicsPath = new GraphicsPath();
                string textString = "SEAL OF APPROVAL";
                pathPrimitive.GraphicsPath.AddString(textString, new FontFamily("Arial"), (int)FontStyle.Bold, 30f, new Point(0, 0), StringFormat.GenericDefault);
                pathPrimitive.PE.ElementType = PaintElementType.Hatch;
                pathPrimitive.PE.Hatch = FillHatchStyle.Sphere;
                pathPrimitive.PE.Fill = Color.Red;
                pathPrimitive.PE.FillStopOpacity = 0;

                SizeF pathSize = pathPrimitive.GraphicsPath.GetBounds().Size;
                GraphicsContext translate = new GraphicsContext();
                translate.Transform = new Matrix();
                translate.Transform.Translate(bounds.Left + bounds.Width / 2f - pathSize.Width / 2f, bounds.Top + bounds.Height / 2f - pathSize.Height / 2f);
                e.SceneGraph.Add(translate);
                e.SceneGraph.Add(pathPrimitive);
                translate = new GraphicsContext();
                translate.ResetTransform = true;
                e.SceneGraph.Add(translate);
            }