public static void Run()
        {
            // ExStart:UseMeasureWithPolylineAnnotation
            // The path to the documents directory.
            string dataDir = RunExamples.GetDataDir_AsposePdf_Miscellaneous();

            Document doc = new Document( dataDir + "input.pdf");
            Point[] vertices = new Point[]
            {
	            new Point(100, 600),
	            new Point(500, 600),
	            new Point(500, 500),
	            new Point(400, 300),
	            new Point(100, 500),
	            new Point(100, 600)
            };
            Rectangle rect = new Rectangle(100, 500, 500, 600);

            // Area or perimeter line
            PolylineAnnotation area = new PolylineAnnotation(doc.Pages[1], rect, vertices);
            area.Color = Color.Red;

            // Line endings can be set for perimeter line.
            area.StartingStyle = LineEnding.OpenArrow;
            area.EndingStyle = LineEnding.OpenArrow;
            area.Measure = new Measure(area);
            area.Measure.DistanceFormat = new Measure.NumberFormatList(area.Measure);
            area.Measure.DistanceFormat.Add(new Measure.NumberFormat(area.Measure));
            area.Measure.DistanceFormat[1].UnitLabel = "mm";
            doc.Pages[1].Annotations.Add(area);
            doc.Save( dataDir + "UseMeasureWithPolylineAnnotation_out.pdf");
            // ExEnd:UseMeasureWithPolylineAnnotation
        }
Пример #2
0
        static void Main()
        {
            // Create new document
            Document pdfDocument = new Document();

            pdfDocument.RegistrationName = "demo";
            pdfDocument.RegistrationKey  = "demo";

            // If you wish to load an existing document uncomment the line below and comment the Add page section instead
            // pdfDocument.Load(@".\existing_document.pdf");

            // Add page
            Page page = new Page(PaperFormat.A4);

            pdfDocument.Pages.Add(page);

            // Draw sample markup annotations

            SquareAnnotation squareAnnotation = new SquareAnnotation(20, 20, 80, 80);

            squareAnnotation.BackgroundColor         = new ColorRGB(255, 240, 240);
            squareAnnotation.BorderStyle.Style       = BorderStyle.Dashed;
            squareAnnotation.BorderStyle.DashPattern = new DashPattern(new float[] { 3, 1, 3 });
            page.Annotations.Add(squareAnnotation);

            CircleAnnotation circleAnnotation = new CircleAnnotation(120, 20, 80, 80);

            circleAnnotation.BackgroundColor        = new ColorRGB(240, 250, 240);
            circleAnnotation.Color                  = new ColorRGB(128, 0, 128);
            circleAnnotation.BorderEffect.Effect    = BorderEffect.Cloudy;
            circleAnnotation.BorderEffect.Intensity = 2;
            page.Annotations.Add(circleAnnotation);

            LineAnnotation lineAnnotation = new LineAnnotation(20, 180, 100, 120);

            lineAnnotation.Color          = new ColorRGB(255, 0, 0);
            lineAnnotation.StartLineStyle = LineEndingStyle.Butt;
            lineAnnotation.EndLineStyle   = LineEndingStyle.OpenArrow;
            page.Annotations.Add(lineAnnotation);

            PointF[]           pp                 = { new PointF(120, 120), new PointF(130, 130), new PointF(140, 120), new PointF(150, 130), new PointF(160, 120), new PointF(170, 130) };
            PointsArray        points             = new PointsArray(pp);
            PolylineAnnotation polylineAnnotation = new PolylineAnnotation(points);

            polylineAnnotation.BorderStyle.Width = 2;
            page.Annotations.Add(polylineAnnotation);


            // Save document to file
            pdfDocument.Save("result.pdf");

            // Cleanup
            pdfDocument.Dispose();

            // Open result document in default associated application (for demo purpose)
            ProcessStartInfo processStartInfo = new ProcessStartInfo("result.pdf");

            processStartInfo.UseShellExecute = true;
            Process.Start(processStartInfo);
        }
Пример #3
0
            public void PolylineAnnotation()
            {
                var s1 = new PolylineAnnotation();
                var s2 = new Annotations.PolylineAnnotation();

                OxyAssert.PropertiesAreEqual(s2, s1);
            }
        public static PlotModel PolylineAnnotations()
        {
            var model = new PlotModel {
                Title = "PolylineAnnotation"
            };

            model.Axes.Add(new LinearAxis {
                Position = AxisPosition.Bottom, Minimum = 0, Maximum = 30
            });
            model.Axes.Add(new LinearAxis {
                Position = AxisPosition.Left, Minimum = 0, Maximum = 30
            });
            var a1 = new PolylineAnnotation {
                Text = "Polyline"
            };

            a1.Points.AddRange(new[] { new DataPoint(0, 10), new DataPoint(5, 5), new DataPoint(20, 1), new DataPoint(30, 20) });
            var a2 = new PolylineAnnotation {
                Smooth = true, Text = "Smooth Polyline"
            };

            a2.Points.AddRange(new[] { new DataPoint(0, 15), new DataPoint(3, 23), new DataPoint(9, 30), new DataPoint(20, 12), new DataPoint(30, 10) });
            model.Annotations.Add(a1);
            model.Annotations.Add(a2);
            return(model);
        }
Пример #5
0
        //TODO : IT

        internal override Annotation Clone(IDocumentEssential owner, Page page)
        {
            if (Page == null)
            {
                PointF[] points = Vertices.ToArray();
                ApplyOwner(owner);
                SetPage(page, true);

                Vertices.Clear();
                Vertices.Page = page;
                Vertices.AddRange(points);

                return(this);
            }

            PDFDictionary res = AnnotationBase.Copy(Dictionary);

            MarkupAnnotationBase.CopyTo(Dictionary, res);
            PolygonPolylineAnnotation.CopyTo(Dictionary, res, Page, page);

            PolylineAnnotation annot = new PolylineAnnotation(res, owner);

            annot.SetPage(Page, false);
            annot.SetPage(page, true);
            return(annot);
        }
        public static void Run()
        {
            // ExStart:UseMeasureWithPolylineAnnotation
            // The path to the documents directory.
            string dataDir = RunExamples.GetDataDir_AsposePdf_Miscellaneous();

            Document doc = new Document(dataDir + "input.pdf");

            Point[] vertices = new Point[]
            {
                new Point(100, 600),
                new Point(500, 600),
                new Point(500, 500),
                new Point(400, 300),
                new Point(100, 500),
                new Point(100, 600)
            };
            Rectangle rect = new Rectangle(100, 500, 500, 600);

            //Area or perimeter line
            PolylineAnnotation area = new PolylineAnnotation(doc.Pages[1], rect, vertices);

            area.Color = Color.Red;

            //Line endings can be set for perimeter line.
            area.StartingStyle          = LineEnding.OpenArrow;
            area.EndingStyle            = LineEnding.OpenArrow;
            area.Measure                = new Measure(area);
            area.Measure.DistanceFormat = new Measure.NumberFormatList(area.Measure);
            area.Measure.DistanceFormat.Add(new Measure.NumberFormat(area.Measure));
            area.Measure.DistanceFormat[1].UnitLabel = "mm";
            doc.Pages[1].Annotations.Add(area);
            doc.Save(dataDir + "UseMeasureWithPolylineAnnotation_out_.pdf");
            // ExEnd:UseMeasureWithPolylineAnnotation
        }
Пример #7
0
        private void SetAnnotationStyle2()
        {
            if (AnnotationStyle2 == null || AnnotationStyle2.SelectedIndex == -1)
            {
                return;
            }

            if (Annotation.SelectedItem.Value == "Line")
            {
                LineAnnotation annotation = (LineAnnotation)Chart1.Annotations[0];

                annotation.EndCap =
                    (LineAnchorCapStyle)LineAnchorCapStyle.Parse(typeof(LineAnchorCapStyle), AnnotationStyle2.SelectedItem.Value);
            }
            else if (Annotation.SelectedItem.Value == "Vertical Line")
            {
                VerticalLineAnnotation annotation = (VerticalLineAnnotation)Chart1.Annotations[0];

                annotation.EndCap =
                    (LineAnchorCapStyle)LineAnchorCapStyle.Parse(typeof(LineAnchorCapStyle), AnnotationStyle2.SelectedItem.Value);
            }
            else if (Annotation.SelectedItem.Value == "Horizontal Line")
            {
                HorizontalLineAnnotation annotation = (HorizontalLineAnnotation)Chart1.Annotations[0];

                annotation.EndCap =
                    (LineAnchorCapStyle)LineAnchorCapStyle.Parse(typeof(LineAnchorCapStyle), AnnotationStyle2.SelectedItem.Value);
            }
            else if (Annotation.SelectedItem.Value == "Polyline")
            {
                PolylineAnnotation annotation = (PolylineAnnotation)Chart1.Annotations[0];

                annotation.EndCap =
                    (LineAnchorCapStyle)LineAnchorCapStyle.Parse(typeof(LineAnchorCapStyle), AnnotationStyle2.SelectedItem.Value);
            }
            else if (Annotation.SelectedItem.Value == "Rectangle")
            {
                RectangleAnnotation annotation = (RectangleAnnotation)Chart1.Annotations[0];

                annotation.LineDashStyle =
                    (ChartDashStyle)ChartDashStyle.Parse(typeof(ChartDashStyle), AnnotationStyle2.SelectedItem.Value);
            }
            else if (Annotation.SelectedItem.Value == "Ellipse")
            {
                EllipseAnnotation annotation = (EllipseAnnotation)Chart1.Annotations[0];

                annotation.LineDashStyle =
                    (ChartDashStyle)ChartDashStyle.Parse(typeof(ChartDashStyle), AnnotationStyle2.SelectedItem.Value);
            }
            else if (Annotation.SelectedItem.Value == "Polygon")
            {
                PolygonAnnotation annotation = (PolygonAnnotation)Chart1.Annotations[0];

                annotation.LineDashStyle =
                    (ChartDashStyle)ChartDashStyle.Parse(typeof(ChartDashStyle), AnnotationStyle2.SelectedItem.Value);
            }
        }
        public static Geojson.Feature ToFeature(this PolylineAnnotation annotation)
        {
            var coords = annotation.Coordinates
                         .Select(position => ToCoords(position))
                         .ToArray();

            var geometry = Geojson.LineString.FromCoordinates(coords);

            return(Geojson.Feature.FromGeometry(geometry));
        }
        public static Feature ToFeature(this PolylineAnnotation annotation)
        {
            var coords = annotation.Coordinates
                         .Select(position => ToCoords(position))
                         .ToArray();

            var geometry = LineString.FromLngLats(MultiPoint.FromLngLats(coords));

            return(Feature.FromGeometry(geometry));
        }
Пример #10
0
 public PolylineAnnotator(AnnotationDataEntity annotationData, PageInfo pageInfo)
     : base(annotationData, pageInfo)
 {
     this.polylineAnnotation = new PolylineAnnotation
     {
         Box      = GetBox(),
         PenColor = 1201033,
         PenWidth = 2,
         SvgPath  = annotationData.svgPath
     };
 }
Пример #11
0
        static void Main()
        {
            // Create new document
            Document pdfDocument = new Document();

            pdfDocument.RegistrationName = "demo";
            pdfDocument.RegistrationKey  = "demo";
            // Add page
            Page page = new Page(PaperFormat.A4);

            pdfDocument.Pages.Add(page);

            // Draw sample markup annotations

            SquareAnnotation squareAnnotation = new SquareAnnotation(20, 20, 80, 80);

            squareAnnotation.BackgroundColor         = new ColorRGB(255, 240, 240);
            squareAnnotation.BorderStyle.Style       = BorderStyle.Dashed;
            squareAnnotation.BorderStyle.DashPattern = new DashPattern(new float[] { 3, 1, 3 });
            page.Annotations.Add(squareAnnotation);

            CircleAnnotation circleAnnotation = new CircleAnnotation(120, 20, 80, 80);

            circleAnnotation.BackgroundColor        = new ColorRGB(240, 250, 240);
            circleAnnotation.Color                  = new ColorRGB(128, 0, 128);
            circleAnnotation.BorderEffect.Effect    = BorderEffect.Cloudy;
            circleAnnotation.BorderEffect.Intensity = 2;
            page.Annotations.Add(circleAnnotation);

            LineAnnotation lineAnnotation = new LineAnnotation(20, 180, 100, 120);

            lineAnnotation.Color          = new ColorRGB(255, 0, 0);
            lineAnnotation.StartLineStyle = LineEndingStyle.Butt;
            lineAnnotation.EndLineStyle   = LineEndingStyle.OpenArrow;
            page.Annotations.Add(lineAnnotation);

            PointF[]           pp                 = { new PointF(120, 120), new PointF(130, 130), new PointF(140, 120), new PointF(150, 130), new PointF(160, 120), new PointF(170, 130) };
            PointsArray        points             = new PointsArray(pp);
            PolylineAnnotation polylineAnnotation = new PolylineAnnotation(points);

            polylineAnnotation.BorderStyle.Width = 2;
            page.Annotations.Add(polylineAnnotation);


            // Save document to file
            pdfDocument.Save("result.pdf");

            // Cleanup
            pdfDocument.Dispose();

            // Open document in default PDF viewer app
            Process.Start("result.pdf");
        }
Пример #12
0
        private void AnnotationStyle2_SelectedIndexChanged(object sender, System.EventArgs e)
        {
            if (Annotation.SelectedItem.ToString() == "Line")
            {
                LineAnnotation annotation = (LineAnnotation)Chart1.Annotations[0];

                annotation.EndCap =
                    (LineAnchorCapStyle)LineAnchorCapStyle.Parse(typeof(LineAnchorCapStyle), AnnotationStyle2.SelectedItem.ToString());
            }
            else if (Annotation.SelectedItem.ToString() == "Vertical Line")
            {
                VerticalLineAnnotation annotation = (VerticalLineAnnotation)Chart1.Annotations[0];

                annotation.EndCap =
                    (LineAnchorCapStyle)LineAnchorCapStyle.Parse(typeof(LineAnchorCapStyle), AnnotationStyle2.SelectedItem.ToString());
            }
            else if (Annotation.SelectedItem.ToString() == "Horizontal Line")
            {
                HorizontalLineAnnotation annotation = (HorizontalLineAnnotation)Chart1.Annotations[0];

                annotation.EndCap =
                    (LineAnchorCapStyle)LineAnchorCapStyle.Parse(typeof(LineAnchorCapStyle), AnnotationStyle2.SelectedItem.ToString());
            }
            else if (Annotation.SelectedItem.ToString() == "Polyline")
            {
                PolylineAnnotation annotation = (PolylineAnnotation)Chart1.Annotations[0];

                annotation.EndCap =
                    (LineAnchorCapStyle)LineAnchorCapStyle.Parse(typeof(LineAnchorCapStyle), AnnotationStyle2.SelectedItem.ToString());
            }
            else if (Annotation.SelectedItem.ToString() == "Rectangle")
            {
                RectangleAnnotation annotation = (RectangleAnnotation)Chart1.Annotations[0];

                annotation.LineDashStyle =
                    (ChartDashStyle)ChartDashStyle.Parse(typeof(ChartDashStyle), AnnotationStyle2.SelectedItem.ToString());
            }
            else if (Annotation.SelectedItem.ToString() == "Ellipse")
            {
                EllipseAnnotation annotation = (EllipseAnnotation)Chart1.Annotations[0];

                annotation.LineDashStyle =
                    (ChartDashStyle)ChartDashStyle.Parse(typeof(ChartDashStyle), AnnotationStyle2.SelectedItem.ToString());
            }
            else if (Annotation.SelectedItem.ToString() == "Polygon")
            {
                PolygonAnnotation annotation = (PolygonAnnotation)Chart1.Annotations[0];

                annotation.LineDashStyle =
                    (ChartDashStyle)ChartDashStyle.Parse(typeof(ChartDashStyle), AnnotationStyle2.SelectedItem.ToString());
            }
        }
        private void DrawAnnotation()
        {
            PolylineAnnotation polyline = new PolylineAnnotation();

            polyline.LineColor           = Color.FromArgb(255, 227, 130);
            polyline.LineWidth           = 2;
            polyline.ShadowOffset        = 2;
            polyline.AllowPathEditing    = true;
            polyline.AllowSelecting      = true;
            polyline.AllowMoving         = true;
            polyline.IsFreeDrawPlacement = true;
            Chart1.Annotations.Add(polyline);
            polyline.BeginPlacement();
        }
Пример #14
0
        public void TestPolygonAndPolylineAnnotation()
        {
            Document document = new Document();

            document.Pages.Add(new Page(PaperFormat.A4));
            Random  rnd  = new Random();
            InkList list = new InkList();

            PointF[] f = new PointF[10];
            for (int j = 0; j < 10; ++j)
            {
                int min = rnd.Next(100);
                int max = rnd.Next(100, 600);
                for (int i = 0; i < f.Length; ++i)
                {
                    f[i].X = rnd.Next(min, max);
                    f[i].Y = rnd.Next(min, max);
                }
                list.AddArray(new PointsArray(f));
            }
            PolygonAnnotation  annotation  = new PolygonAnnotation(list[0]);
            PolylineAnnotation annotation1 = new PolylineAnnotation(list[1]);

            annotation1.StartLineStyle  = LineEndingStyle.Circle;
            annotation1.EndLineStyle    = LineEndingStyle.RClosedArrow;
            annotation1.BackgroundColor = new ColorRGB((byte)rnd.Next(255), (byte)rnd.Next(255), (byte)rnd.Next(255));
            annotation1.Contents        = "PDF polygon annotation";
            annotation.BackgroundColor  = new ColorRGB((byte)rnd.Next(255), (byte)rnd.Next(255), (byte)rnd.Next(255));
            annotation.Color            = new ColorRGB((byte)rnd.Next(255), (byte)rnd.Next(255), (byte)rnd.Next(255));
            annotation1.Color           = new ColorRGB((byte)rnd.Next(255), (byte)rnd.Next(255), (byte)rnd.Next(255));
            annotation1.Contents        = "PDF polyline annotation";
            document.Pages[0].Annotations.Add(annotation);
            document.Pages[0].Annotations.Add(annotation1);
            document.Save(OutputFolder + @"\TestPolygonAndPolylineAnnotation.pdf");
            document.Dispose();

            //Process.Start("TestPolygonAndPolylineAnnotation.pdf");
        }
Пример #15
0
        public void TesPolylineAnnotation()
        {
            Document document = new Document();

            document.Pages.Add(new Page(PaperFormat.A4));
            PointsArray points = new PointsArray();

            points.AddPoint(new Point(150, 275));
            points.AddPoint(new Point(250, 150));
            points.AddPoint(new Point(350, 275));
            points.AddPoint(new Point(125, 200));
            points.AddPoint(new Point(375, 200));
            points.AddPoint(new Point(150, 275));
            PolylineAnnotation annot = new PolylineAnnotation(points);

            annot.Contents = "Polyline annotations...";

            document.Pages[0].Annotations.Add(annot);
            document.Save(OutputFolder + @"\TestPolylineAnnotation.pdf");
            document.Dispose();

            //Process.Start("TestPolylineAnnotation.pdf");
        }
Пример #16
0
 /// <summary>
 /// Default public constructor.
 /// </summary>
 public AnnotationPathPointCollection(PolylineAnnotation annotation)
     : base(annotation)
 {
     this.annotation = annotation;
 }
Пример #17
0
        private void AnnotationStyle1_SelectedIndexChanged(object sender, System.EventArgs e)
        {
            if (Annotation.SelectedItem.ToString() == "Line")
            {
                LineAnnotation annotation = (LineAnnotation)Chart1.Annotations[0];

                annotation.StartCap =
                    (LineAnchorCapStyle)LineAnchorCapStyle.Parse(typeof(LineAnchorCapStyle), AnnotationStyle1.SelectedItem.ToString());
            }
            else if (Annotation.SelectedItem.ToString() == "Vertical Line")
            {
                VerticalLineAnnotation annotation = (VerticalLineAnnotation)Chart1.Annotations[0];

                annotation.StartCap =
                    (LineAnchorCapStyle)LineAnchorCapStyle.Parse(typeof(LineAnchorCapStyle), AnnotationStyle1.SelectedItem.ToString());
            }
            else if (Annotation.SelectedItem.ToString() == "Horizontal Line")
            {
                HorizontalLineAnnotation annotation = (HorizontalLineAnnotation)Chart1.Annotations[0];

                annotation.StartCap =
                    (LineAnchorCapStyle)LineAnchorCapStyle.Parse(typeof(LineAnchorCapStyle), AnnotationStyle1.SelectedItem.ToString());
            }
            else if (Annotation.SelectedItem.ToString() == "Polyline")
            {
                PolylineAnnotation annotation = (PolylineAnnotation)Chart1.Annotations[0];

                annotation.StartCap =
                    (LineAnchorCapStyle)LineAnchorCapStyle.Parse(typeof(LineAnchorCapStyle), AnnotationStyle1.SelectedItem.ToString());
            }
            else if (Annotation.SelectedItem.ToString() == "Rectangle")
            {
                RectangleAnnotation annotation = (RectangleAnnotation)Chart1.Annotations[0];

                annotation.BackColor = Color.FromArgb(128, Color.FromName(AnnotationStyle1.SelectedItem.ToString()));
            }
            else if (Annotation.SelectedItem.ToString() == "Ellipse")
            {
                EllipseAnnotation annotation = (EllipseAnnotation)Chart1.Annotations[0];

                annotation.BackColor = Color.FromArgb(128, Color.FromName(AnnotationStyle1.SelectedItem.ToString()));
            }
            else if (Annotation.SelectedItem.ToString() == "Arrow")
            {
                ArrowAnnotation annotation = (ArrowAnnotation)Chart1.Annotations[0];

                if (AnnotationStyle1.SelectedItem.ToString() != "")
                {
                    annotation.ArrowSize = int.Parse(AnnotationStyle1.SelectedItem.ToString());
                }
            }
            else if (Annotation.SelectedItem.ToString() == "Border3D")
            {
                Border3DAnnotation annotation = (Border3DAnnotation)Chart1.Annotations[0];

                annotation.BorderSkin.BackColor = Color.FromArgb(128, Color.FromName(AnnotationStyle1.SelectedItem.ToString()));
            }
            else if (Annotation.SelectedItem.ToString() == "Callout")
            {
                CalloutAnnotation annotation = (CalloutAnnotation)Chart1.Annotations[0];

                annotation.BackColor = Color.FromArgb(128, Color.FromName(AnnotationStyle1.SelectedItem.ToString()));
            }
            else if (Annotation.SelectedItem.ToString() == "Polygon")
            {
                PolygonAnnotation annotation = (PolygonAnnotation)Chart1.Annotations[0];

                annotation.LineColor = Color.FromName(AnnotationStyle1.SelectedItem.ToString());
            }
        }
Пример #18
0
        private void Annotation_SelectedIndexChanged(object sender, System.EventArgs e)
        {
            Chart1.Annotations.Clear();

            AnnotationStyle.Items.Clear();
            AnnotationStyle.Enabled = false;

            AnnotationStyle1.Items.Clear();
            AnnotationStyle1.Enabled = false;
            AnnotationStyle2.Items.Clear();
            AnnotationStyle2.Visible = false;

            if (Annotation.SelectedItem.ToString() == "Line")
            {
                LineAnnotation annotation = new LineAnnotation();
                annotation.AnchorDataPoint = Chart1.Series[0].Points[1];
                annotation.Height          = -25;
                annotation.Width           = -25;
                annotation.LineWidth       = 2;

                Chart1.Annotations.Add(annotation);

                SetLineControls(true);
            }
            else if (Annotation.SelectedItem.ToString() == "Vertical Line")
            {
                VerticalLineAnnotation annotation = new VerticalLineAnnotation();
                annotation.AnchorDataPoint = Chart1.Series[0].Points[1];
                annotation.Height          = -25;
                annotation.LineWidth       = 2;

                Chart1.Annotations.Add(annotation);

                SetLineControls(true);
            }
            else if (Annotation.SelectedItem.ToString() == "Horizontal Line")
            {
                HorizontalLineAnnotation annotation = new HorizontalLineAnnotation();
                annotation.AnchorDataPoint = Chart1.Series[0].Points[1];
                annotation.Width           = -25;
                annotation.LineWidth       = 2;

                Chart1.Annotations.Add(annotation);

                SetLineControls(true);
            }
            else if (Annotation.SelectedItem.ToString() == "Polyline")
            {
                PolylineAnnotation annotation = new PolylineAnnotation();
                annotation.AnchorDataPoint = Chart1.Series[0].Points[1];

                // explicitly set the relative height and width
                annotation.Height = 50;
                annotation.Width  = 30;

                PointF [] points = new PointF[5];
                points[0].X = 0;
                points[0].Y = 0;

                points[1].X = 100;
                points[1].Y = 0;

                points[2].X = 0;
                points[2].Y = 100;

                points[3].X = 100;
                points[3].Y = 100;

                points[4].X = 0;
                points[4].Y = 50;

                annotation.GraphicsPath.AddPolygon(points);

                Chart1.Annotations.Add(annotation);

                SetLineControls(false);
            }
            else if (Annotation.SelectedItem.ToString() == "Text")
            {
                TextAnnotation annotation = new TextAnnotation();
                annotation.AnchorDataPoint = Chart1.Series[0].Points[1];
                annotation.Text            = "I am a TextAnnotation";
                annotation.ForeColor       = Color.Black;
                annotation.Font            = new Font("Arial", 12);;

                Chart1.Annotations.Add(annotation);
                SetTextControls();
            }
            else if (Annotation.SelectedItem.ToString() == "Rectangle")
            {
                RectangleAnnotation annotation = new RectangleAnnotation();
                annotation.AnchorDataPoint = Chart1.Series[0].Points[1];
                annotation.Text            = "I am a\nRectangleAnnotation";
                annotation.ForeColor       = Color.Black;
                annotation.Font            = new Font("Arial", 12);;
                annotation.LineWidth       = 2;

                Chart1.Annotations.Add(annotation);

                SetTextControls();
                SetColorLineControls();
                AnnotationStyle1.SelectedIndex = 2;
            }
            else if (Annotation.SelectedItem.ToString() == "Ellipse")
            {
                EllipseAnnotation annotation = new EllipseAnnotation();
                annotation.AnchorDataPoint = Chart1.Series[0].Points[1];
                annotation.Text            = "I am an EllipseAnnotation";
                annotation.ForeColor       = Color.Black;
                annotation.Font            = new Font("Arial", 12);;
                annotation.LineWidth       = 2;
                annotation.Height          = 35;
                annotation.Width           = 60;

                Chart1.Annotations.Add(annotation);

                SetTextControls();
                SetColorLineControls();
                AnnotationStyle1.SelectedIndex = 2;
            }
            else if (Annotation.SelectedItem.ToString() == "Arrow")
            {
                ArrowAnnotation annotation = new ArrowAnnotation();
                annotation.AnchorDataPoint = Chart1.Series[0].Points[1];
                annotation.Height          = -25;
                annotation.Width           = -25;
                annotation.LineWidth       = 2;

                Chart1.Annotations.Add(annotation);

                SetArrowControls();
            }
            else if (Annotation.SelectedItem.ToString() == "Border3D")
            {
                Border3DAnnotation annotation = new Border3DAnnotation();
                annotation.AnchorDataPoint = Chart1.Series[0].Points[1];
                annotation.Text            = "I am a Border3DAnnotation";
                annotation.ForeColor       = Color.Black;
                annotation.Font            = new Font("Arial", 12);
                annotation.Height          = 40;
                annotation.Width           = 50;

                Chart1.Annotations.Add(annotation);

                SetBorder3DControls();
            }
            else if (Annotation.SelectedItem.ToString() == "Callout")
            {
                CalloutAnnotation annotation = new CalloutAnnotation();
                annotation.AnchorDataPoint = Chart1.Series[0].Points[1];
                annotation.Text            = "I am a\nCalloutAnnotation";
                annotation.ForeColor       = Color.Black;
                annotation.Font            = new Font("Arial", 10);;
                annotation.Height          = 35;
                annotation.Width           = 50;

                Chart1.Annotations.Add(annotation);

                SetCalloutControls();
            }
            else if (Annotation.SelectedItem.ToString() == "Polygon")
            {
                PolygonAnnotation annotation = new PolygonAnnotation();
                annotation.AnchorDataPoint = Chart1.Series[0].Points[1];

                // explicitly set the relative height and width
                annotation.Height = 50;
                annotation.Width  = 30;

                annotation.BackColor = Color.FromArgb(128, Color.Orange);

                // define relative value points for a polygon
                PointF [] points = new PointF[5];
                points[0].X = 0;
                points[0].Y = 0;

                points[1].X = 100;
                points[1].Y = 0;

                points[2].X = 100;
                points[2].Y = 100;

                points[3].X = 0;
                points[3].Y = 100;

                points[4].X = 50;
                points[4].Y = 50;

                annotation.GraphicsPath.AddPolygon(points);

                Chart1.Annotations.Add(annotation);

                SetColorControl();
                SetColorLineControls();
            }
            else if (Annotation.SelectedItem.ToString() == "Image")
            {
                if (Chart1.Images.IndexOf("MyBmp") < 0)
                {
                    Bitmap   Bmp = new Bitmap(200, 75);
                    Graphics g   = Graphics.FromImage(Bmp);
                    g.FillRectangle(new SolidBrush(Color.Transparent), 0, 0, Bmp.Width, Bmp.Height);
                    g.FillRectangle(new SolidBrush(Color.PaleGoldenrod), Bmp.Width / 2, 0, Bmp.Width / 2, Bmp.Height);
                    g.FillRectangle(new SolidBrush(Color.PaleVioletRed), 0, 0, Bmp.Width / 2, Bmp.Height);
                    g.FillRectangle(new SolidBrush(Color.FromArgb(128, Color.DarkOrange)), 0, Bmp.Height / 2, Bmp.Width, Bmp.Height / 2);
                    g.DrawString("I am an ImageAnnotation", new Font("Arial", 12),
                                 new SolidBrush(Color.Black),
                                 new Rectangle(0, 0, Bmp.Width, Bmp.Height));

                    g.Dispose();

                    Chart1.Images.Add(new NamedImage("MyBmp", Bmp));
                }

                ImageAnnotation annotation = new ImageAnnotation();
                annotation.AnchorDataPoint = Chart1.Series[0].Points[1];
                annotation.Image           = "MyBmp";

                Chart1.Annotations.Add(annotation);
                StyleLabel1.Text = "";
                StyleLabel2.Text = "";
            }
        }
Пример #19
0
        private void parseAnnotations()
        {
            for (int i = 0; i < _array.Count; ++i)
            {
                PDFDictionary annotDict = _array[i] as PDFDictionary;
                if (annotDict != null)
                {
                    if (annotDict["IRT"] == null)
                    {
                        PDFName subtype = annotDict["Subtype"] as PDFName;
                        if (subtype != null)
                        {
                            Annotation annot = null;
                            switch (subtype.GetValue())
                            {
                            case "Text":
                                annot = new TextAnnotation(annotDict, _owner);
                                break;

                            case "Link":
                                annot = new LinkAnnotation(annotDict, _owner);
                                break;

                            case "FreeText":
                                annot = new FreeTextAnnotation(annotDict, _owner);
                                break;

                            case "Line":
                                annot = new LineAnnotation(annotDict, _owner);
                                break;

                            case "Square":
                                annot = new SquareAnnotation(annotDict, _owner);
                                break;

                            case "Circle":
                                annot = new CircleAnnotation(annotDict, _owner);
                                break;

                            case "Polygon":
                                annot = new PolygonAnnotation(annotDict, _owner);
                                break;

                            case "PolyLine":
                                annot = new PolylineAnnotation(annotDict, _owner);
                                break;

                            case "Highlight":
                                annot = new HighlightAnnotation(annotDict, _owner);
                                break;

                            case "Underline":
                                annot = new UnderlineAnnotation(annotDict, _owner);
                                break;

                            case "Squiggly":
                                annot = new SquigglyAnnotation(annotDict, _owner);
                                break;

                            case "StrikeOut":
                                annot = new StrikeOutAnnotation(annotDict, _owner);
                                break;

                            case "Stamp":
                                annot = new RubberStampAnnotation(annotDict, _owner);
                                break;

                            case "Caret":
                                annot = new CaretAnnotation(annotDict, _owner);
                                break;

                            case "Ink":
                                annot = new InkAnnotation(annotDict, _owner);
                                break;

                            case "FileAttachment":
                                annot = new FileAttachmentAnnotation(annotDict, _owner);
                                break;

                            case "Sound":
                                annot = new SoundAnnotation(annotDict, _owner);
                                break;

                            case "Movie":
                                annot = new MovieAnnotation(annotDict, _owner);
                                break;

                            case "Screen":
                                annot = new ScreenAnnotation(annotDict, _owner);
                                break;

                            case "3D":
                                annot = new ThreeDAnnotation(annotDict, _owner);
                                break;

                            case "Widget":
                                PDFName ft = annotDict["FT"] as PDFName;
                                if (ft == null)
                                {
                                    PDFDictionary parent = annotDict["Parent"] as PDFDictionary;
                                    if (parent != null)
                                    {
                                        ft = parent["FT"] as PDFName;
                                    }
                                }

                                if (ft != null)
                                {
                                    switch (ft.GetValue())
                                    {
                                    case "Tx":
                                        annot = new EditBox(annotDict, _owner);
                                        break;

                                    case "Ch":
                                        uint flag = getFlag(annotDict);
                                        if ((flag >> 17) % 2 != 0)
                                        {
                                            annot = new ComboBox(annotDict, _owner);
                                        }
                                        else
                                        {
                                            annot = new ListBox(annotDict, _owner);
                                        }
                                        break;

                                    case "Btn":
                                        flag = getFlag(annotDict);
                                        if ((flag >> 16) % 2 != 0)
                                        {
                                            annot = new PushButton(annotDict, _owner);
                                        }
                                        else if ((flag >> 15) % 2 != 0)
                                        {
                                            annot = new RadioButton(annotDict, _owner);
                                        }
                                        else
                                        {
                                            annot = new CheckBox(annotDict, _owner);
                                        }
                                        break;
                                    }
                                }
                                break;
                            }

                            if (annot != null)
                            {
                                annot.SetPage(_page, false);
                                _annotations.Add(annot);
                            }
                        }
                    }
                }
            }
        }
Пример #20
0
        private void SetAnnotationStyle1()
        {
            if (AnnotationStyle1 == null || AnnotationStyle1.SelectedIndex == -1)
            {
                return;
            }

            if (Annotation.SelectedItem.Value == "Line")
            {
                LineAnnotation annotation = (LineAnnotation)Chart1.Annotations[0];

                annotation.StartCap =
                    (LineAnchorCapStyle)LineAnchorCapStyle.Parse(typeof(LineAnchorCapStyle), AnnotationStyle1.SelectedItem.Value);
            }
            else if (Annotation.SelectedItem.Value == "Vertical Line")
            {
                VerticalLineAnnotation annotation = (VerticalLineAnnotation)Chart1.Annotations[0];

                annotation.StartCap =
                    (LineAnchorCapStyle)LineAnchorCapStyle.Parse(typeof(LineAnchorCapStyle), AnnotationStyle1.SelectedItem.Value);
            }
            else if (Annotation.SelectedItem.Value == "Horizontal Line")
            {
                HorizontalLineAnnotation annotation = (HorizontalLineAnnotation)Chart1.Annotations[0];

                annotation.StartCap =
                    (LineAnchorCapStyle)LineAnchorCapStyle.Parse(typeof(LineAnchorCapStyle), AnnotationStyle1.SelectedItem.Value);
            }
            else if (Annotation.SelectedItem.Value == "Polyline")
            {
                PolylineAnnotation annotation = (PolylineAnnotation)Chart1.Annotations[0];

                annotation.StartCap =
                    (LineAnchorCapStyle)LineAnchorCapStyle.Parse(typeof(LineAnchorCapStyle), AnnotationStyle1.SelectedItem.Value);
            }
            else if (Annotation.SelectedItem.Value == "Rectangle")
            {
                RectangleAnnotation annotation = (RectangleAnnotation)Chart1.Annotations[0];

                annotation.BackColor = Color.FromArgb(128, Color.FromName(AnnotationStyle1.SelectedItem.Value));
            }
            else if (Annotation.SelectedItem.Value == "Ellipse")
            {
                EllipseAnnotation annotation = (EllipseAnnotation)Chart1.Annotations[0];

                annotation.BackColor = Color.FromArgb(128, Color.FromName(AnnotationStyle1.SelectedItem.Value));
            }
            else if (Annotation.SelectedItem.Value == "Arrow")
            {
                ArrowAnnotation annotation = (ArrowAnnotation)Chart1.Annotations[0];

                if (AnnotationStyle1.SelectedItem.Value != "")
                {
                    annotation.ArrowSize = int.Parse(AnnotationStyle1.SelectedItem.Value);
                }
            }
            else if (Annotation.SelectedItem.Value == "Border3D")
            {
                Border3DAnnotation annotation = (Border3DAnnotation)Chart1.Annotations[0];

                annotation.BorderSkin.BackColor = Color.FromArgb(128, Color.FromName(AnnotationStyle1.SelectedItem.Value));
            }
            else if (Annotation.SelectedItem.Value == "Callout")
            {
                CalloutAnnotation annotation = (CalloutAnnotation)Chart1.Annotations[0];

                annotation.BackColor = Color.FromArgb(128, Color.FromName(AnnotationStyle1.SelectedItem.Value));
            }
            else if (Annotation.SelectedItem.Value == "Polygon")
            {
                PolygonAnnotation annotation = (PolygonAnnotation)Chart1.Annotations[0];

                annotation.LineColor = Color.FromName(AnnotationStyle1.SelectedItem.Value);
            }
        }
Пример #21
0
        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            List <StandardData> standardData;
            TestData            testData;

            //准备数据
            PrepareData(out standardData, out testData);

            double minimumX = Double.MaxValue;
            double maximumX = Double.MinValue;
            double minimumY = Double.MaxValue;
            double maximumY = Double.MinValue;

            for (int i = 0; i < standardData.Count; ++i)
            {
                if (standardData[i].Salinity < minimumX)
                {
                    minimumX = standardData[i].Salinity;
                }

                if (standardData[i].Salinity > maximumX)
                {
                    maximumX = standardData[i].Salinity;
                }

                //

                if (standardData[i].Watertemp < minimumY)
                {
                    minimumY = standardData[i].Watertemp;
                }

                if (standardData[i].Watertemp > maximumY)
                {
                    maximumY = standardData[i].Watertemp;
                }
            }

            if (testData.Salinity < minimumX)
            {
                minimumX = testData.Salinity;
            }
            if (testData.Salinity > maximumX)
            {
                maximumX = testData.Salinity;
            }

            //

            if (testData.Watertemp < minimumY)
            {
                minimumY = testData.Watertemp;
            }

            if (testData.Watertemp > maximumY)
            {
                maximumY = testData.Watertemp;
            }

            //plotView.Model = new OxyPlot.PlotModel { Title = "T-S-D 点聚图", IsLegendVisible = true, LegendBackground = OxyColor.FromRgb(255, 255, 255), Background = OxyColor.FromRgb(232, 233, 255) };
            plotView.Model = new OxyPlot.PlotModel {
                Title = "T-S-D 点聚图", IsLegendVisible = true
            };
            plotView.Model.Axes.Add(new LinearAxis()
            {
                Position = AxisPosition.Bottom, Title = "盐度", Minimum = minimumX - 10, Maximum = maximumX + 10
            });
            plotView.Model.Axes.Add(new LinearAxis()
            {
                Position = AxisPosition.Left, Title = "温度", Minimum = minimumY - 10, Maximum = maximumY + 10
            });

            plotView.Model.Series.Clear();

            //标准数据
            {
                ScatterSeries ss = new ScatterSeries()
                {
                    Title = "标准数据", MarkerType = MarkerType.Circle, MarkerFill = OxyColor.FromRgb(0, 0, 255)
                };
                for (int i = 0; i < standardData.Count; ++i)
                {
                    ss.Points.Add(new ScatterPoint(standardData[i].Salinity, standardData[i].Watertemp));
                }
                plotView.Model.Series.Add(ss);
            }

            //测试数据
            {
                ScatterSeries ss = new ScatterSeries()
                {
                    Title = "被检数据", MarkerType = MarkerType.Diamond, MarkerFill = OxyColor.FromRgb(255, 0, 0)
                };
                ScatterPoint pt = new ScatterPoint(testData.Salinity, testData.Watertemp);
                pt.Tag = "深度:" + testData.ToString();
                ss.Points.Add(pt);

                plotView.Model.Series.Add(ss);
            }

            double     n;
            List <int> standardDataConvexHullIndices;
            List <TestDataConvexHull> testDataConvexHullIndices;

            calculationConvexHull(standardData, testData, out n, out standardDataConvexHullIndices, out testDataConvexHullIndices);

            double Xc;
            double Yc;
            double dipAngle;
            double a2;
            double b2;

            calculationEllipse(
                testDataConvexHullIndices[0].MinEllipse[0]
                , testDataConvexHullIndices[0].MinEllipse[1]
                , testDataConvexHullIndices[0].MinEllipse[2]
                , testDataConvexHullIndices[0].MinEllipse[3]
                , testDataConvexHullIndices[0].MinEllipse[4]
                , testDataConvexHullIndices[0].MinEllipse[5]
                , out Xc
                , out Yc
                , out dipAngle
                , out a2
                , out b2
                );

            PolylineAnnotation polylineAnnotation = new PolylineAnnotation();

            for (int i = 0; i < standardDataConvexHullIndices.Count; ++i)
            {
                polylineAnnotation.Points.Add(new DataPoint(
                                                  standardData[standardDataConvexHullIndices[i]].Salinity
                                                  ,
                                                  standardData[standardDataConvexHullIndices[i]].Watertemp
                                                  ));
            }
            //为了闭合
            polylineAnnotation.Points.Add(new DataPoint(
                                              standardData[standardDataConvexHullIndices[0]].Salinity
                                              ,
                                              standardData[standardDataConvexHullIndices[0]].Watertemp
                                              ));

            plotView.Model.Annotations.Add(polylineAnnotation);

            //斜椭圆的参数方程
            //x = a * cost * cosθ - b * sint * sinθ + Xc,
            //y = a * cost * sinθ + b * sint * cosθ + Yc.
            //θ为椭圆倾斜角,
            //a,b分别为长、短半轴;
            //t为参数

            {
                PolygonAnnotation polygonAnnotation = new PolygonAnnotation();
                polygonAnnotation.Fill            = OxyColor.FromArgb(0, 0, 0, 0);
                polygonAnnotation.Stroke          = OxyColor.FromArgb(255, 255, 0, 0);
                polygonAnnotation.StrokeThickness = 1;
                for (double angle = -1 * Math.PI; angle < Math.PI; angle += 0.001)
                {
                    DataPoint point = new DataPoint(
                        Math.Sqrt(a2) * Math.Cos(angle) * Math.Cos(dipAngle) - Math.Sqrt(b2) * Math.Sin(angle) * Math.Sin(dipAngle) + Xc,
                        Math.Sqrt(a2) * Math.Cos(angle) * Math.Sin(dipAngle) + Math.Sqrt(b2) * Math.Sin(angle) * Math.Cos(dipAngle) + Yc
                        );
                    polygonAnnotation.Points.Add(point);
                }
                plotView.Model.Annotations.Add(polygonAnnotation);
            }


            //测试用的参考
            //{
            //    PolygonAnnotation polygonAnnotation = new PolygonAnnotation();
            //    polygonAnnotation.Fill = OxyColor.FromArgb(0, 0, 0, 0);
            //    polygonAnnotation.Stroke = OxyColor.FromArgb(255, 0, 255, 0);
            //    polygonAnnotation.StrokeThickness = 1;
            //    for (double angle = -1 * Math.PI; angle < Math.PI; angle += 0.001)
            //    {
            //        DataPoint point = new DataPoint(
            //            Math.Sqrt(b2) * Math.Cos(angle) * Math.Cos(dipAngle) - Math.Sqrt(a2) * Math.Sin(angle) * Math.Sin(dipAngle) + Xc,
            //            Math.Sqrt(b2) * Math.Cos(angle) * Math.Sin(dipAngle) + Math.Sqrt(a2) * Math.Sin(angle) * Math.Cos(dipAngle) + Yc
            //            );
            //        polygonAnnotation.Points.Add(point);
            //    }
            //    plotView.Model.Annotations.Add(polygonAnnotation);
            //}



            //不要通过使用EllipseAnnotation,因为他画出的椭圆是正椭圆,无法旋转,只能采用PolygonAnnotation根据椭圆的参数方程进行绘制
            //EllipseAnnotation ellipseAnnotation = new EllipseAnnotation();
            //ellipseAnnotation.Fill = OxyColor.FromArgb(0, 0, 0, 0);
            //ellipseAnnotation.Stroke = OxyColor.FromArgb(255, 255, 0, 0);
            //ellipseAnnotation.StrokeThickness = 1;
            //ellipseAnnotation.X = Xc;
            //ellipseAnnotation.Y = Yc;
            //ellipseAnnotation.Width = Math.Sqrt(a2) * 2;
            //ellipseAnnotation.Height = Math.Sqrt(b2) * 2;
            //plotView.Model.Annotations.Add(ellipseAnnotation);


            plotView.Model.InvalidatePlot(true);
        }
Пример #22
0
 public override AnnotationBase AnnotateSlides()
 {
     polylineAnnotation = InitAnnotationBase(polylineAnnotation) as PolylineAnnotation;
     FillCreatorName(polylineAnnotation, annotationData);
     return(polylineAnnotation);
 }
Пример #23
0
 public override AnnotationBase AnnotateWord()
 {
     polylineAnnotation = InitAnnotationBase(polylineAnnotation) as PolylineAnnotation;
     return(polylineAnnotation);
 }
Пример #24
0
 public void PolylineAnnotation()
 {
     var s1 = new PolylineAnnotation();
     var s2 = new Annotations.PolylineAnnotation();
     OxyAssert.PropertiesAreEqual(s2, s1);
 }
Пример #25
0
        private void SetAnnotationType()
        {
            Chart1.Annotations.Clear();

            if(Annotation.SelectedItem.Value == "Line")
            {
                LineAnnotation annotation = new LineAnnotation();
                annotation.AnchorDataPoint = Chart1.Series[0].Points[2];
                annotation.Height = -25;
                annotation.Width = -25;
                annotation.LineWidth = 2;

                Chart1.Annotations.Add(annotation);
            }
            else if(Annotation.SelectedItem.Value == "Vertical Line")
            {
                VerticalLineAnnotation annotation = new VerticalLineAnnotation();
                annotation.AnchorDataPoint = Chart1.Series[0].Points[2];
                annotation.Height = -25;
                annotation.LineWidth = 2;

                Chart1.Annotations.Add(annotation);
            }
            else if(Annotation.SelectedItem.Value == "Horizontal Line")
            {
                HorizontalLineAnnotation annotation = new HorizontalLineAnnotation();
                annotation.AnchorDataPoint = Chart1.Series[0].Points[2];
                annotation.Width = -25;
                annotation.LineWidth = 2;

                Chart1.Annotations.Add(annotation);
            }
            else if(Annotation.SelectedItem.Value == "Polyline")
            {
                PolylineAnnotation annotation = new PolylineAnnotation();
                annotation.AnchorDataPoint = Chart1.Series[0].Points[2];

                // explicitly set the relative height and width
                annotation.Height = 50;
                annotation.Width = 30;

                PointF [] points = new PointF[5];
                points[0].X = 0;
                points[0].Y = 0;

                points[1].X = 100;
                points[1].Y = 0;

                points[2].X = 0;
                points[2].Y = 100;

                points[3].X = 100;
                points[3].Y = 100;

                points[4].X = 0;
                points[4].Y = 50;

                annotation.GraphicsPath.AddPolygon(points);

                Chart1.Annotations.Add(annotation);
            }
            else if(Annotation.SelectedItem.Value == "Text")
            {
                TextAnnotation annotation = new TextAnnotation();
                annotation.AnchorDataPoint = Chart1.Series[0].Points[2];
                annotation.Text = "I am a TextAnnotation";
                annotation.ForeColor = Color.Black;
                annotation.Font = new Font("Arial", 12);;

                Chart1.Annotations.Add(annotation);
            }
            else if(Annotation.SelectedItem.Value == "Rectangle")
            {
                RectangleAnnotation annotation = new RectangleAnnotation();
                annotation.AnchorDataPoint = Chart1.Series[0].Points[2];
                annotation.Text = "I am a\nRectangleAnnotation";
                annotation.ForeColor = Color.Black;
                annotation.Font = new Font("Arial", 12);;
                annotation.LineWidth = 2;

                Chart1.Annotations.Add(annotation);
            }
            else if(Annotation.SelectedItem.Value == "Ellipse")
            {
                EllipseAnnotation annotation = new EllipseAnnotation();
                annotation.AnchorDataPoint = Chart1.Series[0].Points[2];
                annotation.Text = "I am an EllipseAnnotation";
                annotation.ForeColor = Color.Black;
                annotation.Font = new Font("Arial", 12);;
                annotation.LineWidth = 2;
                annotation.Height = 35;
                annotation.Width = 60;

                Chart1.Annotations.Add(annotation);
            }
            else if(Annotation.SelectedItem.Value == "Arrow")
            {
                ArrowAnnotation annotation = new ArrowAnnotation();
                annotation.AnchorDataPoint = Chart1.Series[0].Points[2];
                annotation.Height = -25;
                annotation.Width = -25;
                annotation.LineWidth = 2;

                Chart1.Annotations.Add(annotation);
            }
            else if(Annotation.SelectedItem.Value == "Border3D")
            {
                Border3DAnnotation annotation = new Border3DAnnotation();
                annotation.AnchorDataPoint = Chart1.Series[0].Points[2];
                annotation.Text = "I am a Border3DAnnotation";
                annotation.ForeColor = Color.Black;
                annotation.Font = new Font("Arial", 12);;
                annotation.Height = 40;
                annotation.Width = 50;

                Chart1.Annotations.Add(annotation);
            }
            else if(Annotation.SelectedItem.Value == "Callout")
            {
                CalloutAnnotation annotation = new CalloutAnnotation();
                annotation.AnchorDataPoint = Chart1.Series[0].Points[1];
                annotation.Text = "I am a\nCalloutAnnotation";
                annotation.ForeColor = Color.Black;
                annotation.Font = new Font("Arial", 10);;
                annotation.Height = 35;
                annotation.Width = 50;

                Chart1.Annotations.Add(annotation);
            }
            else if(Annotation.SelectedItem.Value == "Polygon")
            {
                PolygonAnnotation annotation = new PolygonAnnotation();
                annotation.AnchorDataPoint = Chart1.Series[0].Points[2];

                // explicitly set the relative height and width
                annotation.Height = 50;
                annotation.Width = 30;

                annotation.BackColor = Color.FromArgb(128, Color.Orange);

                // define relative value points for a polygon
                PointF [] points = new PointF[5];
                points[0].X = 0;
                points[0].Y = 0;

                points[1].X = 100;
                points[1].Y = 0;

                points[2].X = 100;
                points[2].Y = 100;

                points[3].X = 0;
                points[3].Y = 100;

                points[4].X = 50;
                points[4].Y = 50;

                annotation.GraphicsPath.AddPolygon(points);

                Chart1.Annotations.Add(annotation);
            }
            else if(Annotation.SelectedItem.Value == "Image")
            {
                if (Chart1.Images.IndexOf("MyBmp") < 0)
                {
                    Bitmap Bmp = new Bitmap(200, 75);
                    Graphics g = Graphics.FromImage(Bmp);
                    g.FillRectangle(new SolidBrush(Color.Transparent), 0, 0, Bmp.Width, Bmp.Height);
                    g.FillRectangle(new SolidBrush(Color.PaleGoldenrod), Bmp.Width/2, 0, Bmp.Width/2, Bmp.Height);
                    g.FillRectangle(new SolidBrush(Color.PaleVioletRed), 0, 0, Bmp.Width/2, Bmp.Height);
                    g.FillRectangle(new SolidBrush(Color.FromArgb(128, Color.DarkOrange)), 0, Bmp.Height/2, Bmp.Width, Bmp.Height/2);
                    g.DrawString("I am an ImageAnnotation", new Font("Arial", 12),
                        new SolidBrush(Color.Black),
                        new Rectangle( 0, 0, Bmp.Width, Bmp.Height));

                    g.Dispose();

                    Chart1.Images.Add(new NamedImage("MyBmp", Bmp));
                }

                ImageAnnotation annotation = new ImageAnnotation();
                annotation.AnchorDataPoint = Chart1.Series[0].Points[2];
                annotation.Image = "MyBmp";

                Chart1.Annotations.Add(annotation);
            }
        }