Beispiel #1
1
        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 = "";
            }
        }
Beispiel #2
0
        public void PlotMouseMove(LineSeries lb, MapStatistics ms, OxyMouseEventArgs e)
        {
            if (lb.Points.Count != 0)
            {
                ms._endPoint1 = lb.InverseTransform(e.Position);
                if (ms._startPoint1.X != 0 || ms._startPoint1.Y != 0)
                {
                    ms._pm.Annotations.Clear();

                    var rectangle = new PolygonAnnotation();
                    rectangle.Layer           = AnnotationLayer.BelowAxes;
                    rectangle.StrokeThickness = 0.5;
                    rectangle.Stroke          = OxyColors.Red;
                    rectangle.Fill            = OxyColors.Transparent;
                    rectangle.LineStyle       = OxyPlot.LineStyle.Dot;

                    rectangle.Points.Add(new DataPoint(ms._startPoint1.X, ms._startPoint1.Y));
                    rectangle.Points.Add(new DataPoint(ms._endPoint1.X, ms._startPoint1.Y));
                    rectangle.Points.Add(new DataPoint(ms._endPoint1.X, ms._endPoint1.Y));
                    rectangle.Points.Add(new DataPoint(ms._startPoint1.X, ms._endPoint1.Y));

                    ms._pm.Annotations.Add(rectangle as Annotation);
                    ms._pm.InvalidatePlot(true);
                }
            }
        }
Beispiel #3
0
        public void PutPolygonAnnotationTest()
        {
            PolygonAnnotation annotation = new PolygonAnnotation()
            {
                Name  = "Updated Test",
                Rect  = new Rectangle(100, 100, 200, 200),
                Flags = new List <AnnotationFlags> {
                    AnnotationFlags.Hidden, AnnotationFlags.NoView
                },
                HorizontalAlignment = HorizontalAlignment.Center,
                RichText            = "Rich Text Updated",
                Subject             = "Subj Updated",
                ZIndex   = 1,
                Title    = "Title Updated",
                Vertices = new List <Point>
                {
                    new Point(10, 10),
                    new Point(20, 10),
                    new Point(10, 20),
                    new Point(10, 10)
                }
            };

            var    lineResponse = api.GetDocumentPolygonAnnotations(Name, folder: FolderName);
            string annotationId = lineResponse.Annotations.List[0].Id;

            var response = api.PutPolygonAnnotation(Name, annotationId, annotation, folder: FolderName);

            Console.WriteLine(response);
        }
Beispiel #4
0
        public ScrollBarArea(OxyAreaSettings settings, List <OxyArea> all_areas, OxyChartPainter owner) : base(settings, owner)
        {
            area_settings  = settings;
            this.all_areas = all_areas;

            plot_view.DefaultTrackerTemplate = new System.Windows.Controls.ControlTemplate();



            screen_viewer_polygon = new PolygonAnnotation()
            {
                Layer             = AnnotationLayer.AboveSeries,
                Selectable        = true,
                Fill              = area_settings.ScrollBarColor,
                EdgeRenderingMode = EdgeRenderingMode.PreferSpeed,
                Tag = "screen_viewer_polygon",
            };

            screen_viewer_polygon.Points.AddRange(new List <OxyPlot.DataPoint>()
            {
                new OxyPlot.DataPoint(0, 0),
                new OxyPlot.DataPoint(0, 0),
                new OxyPlot.DataPoint(0, 0),
                new OxyPlot.DataPoint(0, 0),
            });


            plot_model.MouseDown  += Plot_model_scroll_chart_MouseDown;
            plot_model.MouseUp    += Plot_model_scroll_chart_MouseUp;
            plot_model.MouseLeave += Plot_model_scroll_chart_MouseLeave;
            plot_model.MouseMove  += Plot_model_scroll_chart_MouseMove;

            plot_model.Updated += Plot_model_Updated;
        }
Beispiel #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);

            PolygonAnnotation annot = new PolygonAnnotation(res, owner);

            annot.SetPage(Page, false);
            annot.SetPage(page, true);
            return(annot);
        }
Beispiel #6
0
        private void PlotMouseMove(object sender, OxyMouseEventArgs e)
        {
            if (_cs.Items.Count != 0)
            {
                _endPoint1 = _cs.InverseTransform(e.Position);
                if (_startPoint1.X != 0 || _startPoint1.Y != 0)
                {
                    _ms._pm.Annotations.Clear();

                    var rectangle = new PolygonAnnotation();
                    rectangle.Layer           = AnnotationLayer.BelowAxes;
                    rectangle.StrokeThickness = 1;
                    rectangle.Stroke          = OxyColors.Red;
                    rectangle.Fill            = OxyColors.Transparent;
                    rectangle.LineStyle       = OxyPlot.LineStyle.Dot;

                    rectangle.Points.Add(new DataPoint(_startPoint1.X, _startPoint1.Y));
                    rectangle.Points.Add(new DataPoint(_endPoint1.X, _startPoint1.Y));
                    rectangle.Points.Add(new DataPoint(_endPoint1.X, _endPoint1.Y));
                    rectangle.Points.Add(new DataPoint(_startPoint1.X, _endPoint1.Y));

                    _ms._pm.Annotations.Add(rectangle as Annotation);
                    _ms._pm.InvalidatePlot(true);
                }
            }
        }
        public static PlotModel AnnotationLayerProperty()
        {
            var model = new PlotModel { Title = "Annotation Layers" };
            model.Axes.Add(new LinearAxis { Position = AxisPosition.Bottom, Minimum = -20, Maximum = 30, MajorGridlineStyle = LineStyle.Solid, MajorGridlineThickness = 1 });
            model.Axes.Add(new LinearAxis { Position = AxisPosition.Left, Minimum = -10, Maximum = 10, MajorGridlineStyle = LineStyle.Solid, MajorGridlineThickness = 1 });

            var a1 = new PolygonAnnotation
                         {
                             Layer = AnnotationLayer.BelowAxes,
                             Text = "Layer = BelowAxes"
                         };
            a1.Points.AddRange(new[]
                                   {
                                       new DataPoint(-11, -2), new DataPoint(-7, -4), new DataPoint(-3, 7), new DataPoint(-10, 8),
                                       new DataPoint(-13, 5)
                                   });
            model.Annotations.Add(a1);
            var a2 = new PolygonAnnotation
                         {
                             Layer = AnnotationLayer.BelowSeries,
                             Text = "Layer = BelowSeries"
                         };
            a2.Points.AddRange(new DataPoint[]
                                   {
                                       new DataPoint(4, -2), new DataPoint(8, -4), new DataPoint(12, 7), new DataPoint(5, 8),
                                       new DataPoint(2, 5)
                                   });
            model.Annotations.Add(a2);
            var a3 = new PolygonAnnotation { Layer = AnnotationLayer.AboveSeries, Text = "Layer = AboveSeries" };
            a3.Points.AddRange(new[] { new DataPoint(19, -2), new DataPoint(23, -4), new DataPoint(27, 7), new DataPoint(20, 8), new DataPoint(17, 5) });
            model.Annotations.Add(a3);

            model.Series.Add(new FunctionSeries(Math.Sin, -20, 30, 400));
            return model;
        }
        public static PlotModel PolygonAnnotation()
        {
            var model = new PlotModel("PolygonAnnotation", "Click the polygon");

            model.Axes.Add(new LinearAxis(AxisPosition.Bottom, -20, 20));
            model.Axes.Add(new LinearAxis(AxisPosition.Left, -10, 10));
            var pa = new PolygonAnnotation
            {
                Points =
                    new[]
                {
                    new DataPoint(4, -2), new DataPoint(8, -4), new DataPoint(17, 7), new DataPoint(5, 8),
                    new DataPoint(2, 5)
                },
                Text = "Polygon 1"
            };

            // Handle left mouse clicks
            int hitCount = 1;

            pa.MouseDown += (s, e) =>
            {
                if (e.ChangedButton != OxyMouseButton.Left)
                {
                    return;
                }

                pa.Text = "Hit # " + hitCount++;
                model.InvalidatePlot(false);
                e.Handled = true;
            };

            model.Annotations.Add(pa);
            return(model);
        }
Beispiel #9
0
            public void PolygonAnnotation()
            {
                var s1 = new PolygonAnnotation();
                var s2 = new Annotations.PolygonAnnotation();

                OxyAssert.PropertiesAreEqual(s2, s1);
            }
Beispiel #10
0
        public void PutPolygonAnnotationTest()
        {
            PolygonAnnotation annotation = new PolygonAnnotation(Rect: new Rectangle(100, 100, 200, 200),
                                                                 Vertices: new List <Point>
            {
                new Point(10, 10),
                new Point(20, 10),
                new Point(10, 20),
                new Point(10, 10)
            })
            {
                Name  = "Updated Test",
                Flags = new List <AnnotationFlags> {
                    AnnotationFlags.Hidden, AnnotationFlags.NoView
                },
                HorizontalAlignment = HorizontalAlignment.Center,
                RichText            = "Rich Text Updated",
                Subject             = "Subj Updated",
                ZIndex = 1,
                Title  = "Title Updated"
            };

            var    lineResponse = PdfApi.GetDocumentPolygonAnnotations(Name, folder: TempFolder);
            string annotationId = lineResponse.Annotations.List[0].Id;

            var response = PdfApi.PutPolygonAnnotation(Name, annotationId, annotation, folder: TempFolder);

            Assert.That(response.Code, Is.EqualTo(200));
        }
Beispiel #11
0
        public void CreateNewStarAnnotation()

        {
            // Create annotation group and add it to the chart annotations collection
            AnnotationGroup star = new AnnotationGroup();

            star.X              = 20;
            star.Y              = 20;
            star.Width          = 30;
            star.Height         = 20;
            star.AllowSelecting = true;
            star.AllowMoving    = true;
            star.AllowResizing  = true;

            Chart1.Annotations.Add(star);

            // Add star shaped polygon annotation into the group

            PointF[] starPolygon = new PointF[] {
                new PointF(1, 6), new PointF(27, 23), new PointF(33, 5), new PointF(44, 22), new PointF(58, 0),
                new PointF(57, 19), new PointF(75, 11), new PointF(70, 28), new PointF(100, 37), new PointF(81, 53),
                new PointF(99, 65), new PointF(75, 67), new PointF(87, 98), new PointF(63, 69), new PointF(60, 94),
                new PointF(47, 69), new PointF(34, 100), new PointF(32, 69), new PointF(23, 74), new PointF(26, 61),
                new PointF(4, 72), new PointF(22, 49), new PointF(0, 39), new PointF(23, 32), new PointF(1, 6)
            };

            GraphicsPath starPath = new GraphicsPath();

            starPath.AddPolygon(starPolygon);
            PolygonAnnotation poly = new PolygonAnnotation();

            poly.Name         = "Star";
            poly.GraphicsPath = starPath;
            star.Annotations.Add(poly);

            // Set star polygon annotation position and appearance
            star.Annotations["Star"].X            = 0;
            star.Annotations["Star"].Y            = 0;
            star.Annotations["Star"].Width        = 100;
            star.Annotations["Star"].Height       = 100;
            star.Annotations["Star"].LineColor    = Color.FromArgb(64, 64, 64);
            star.Annotations["Star"].BackColor    = Color.FromArgb(220, 255, 255, 192);
            star.Annotations["Star"].ShadowOffset = 2;

            // Add text in the middle of the star shape
            TextAnnotation textAnnotation = new TextAnnotation();

            textAnnotation.Name   = "StarText";
            textAnnotation.Text   = "New !!!";
            textAnnotation.X      = 20;
            textAnnotation.Y      = 20;
            textAnnotation.Width  = 60;
            textAnnotation.Height = 60;
            star.Annotations.Add(textAnnotation);
            star.Annotations["StarText"].Font      = new Font("MS Sans Serif", 10, FontStyle.Bold | FontStyle.Italic);
            star.Annotations["StarText"].ForeColor = Color.FromArgb(26, 59, 105);
        }
        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);
            }
        }
Beispiel #13
0
        public void DrawCanal()
        {
#if !NEW_CAP
            PolygonAnnotation Border = new PolygonAnnotation();
            Border.Fill = OxyColors.Transparent;
            Border.Points.Add(new DataPoint(0, 10));
            Border.Points.Add(new DataPoint(0, -Settings.Canal.h));
            Border.Points.Add(new DataPoint(Settings.Canal.delta, -Settings.Canal.h));
            Border.Points.Add(new DataPoint(Settings.Canal.delta, 10));
            Border.StrokeThickness = 2;
            Border.Stroke          = OxyColors.Black;
            PlotModel.Annotations.Add(Border);
            PolygonAnnotation BorderDashPart = new PolygonAnnotation();
            BorderDashPart.Fill = OxyColors.Transparent;
            BorderDashPart.Points.Add(new DataPoint(0, -1.0 / 3.0));
            BorderDashPart.Points.Add(new DataPoint(Settings.Canal.delta, 2.0 / 3.0));
            BorderDashPart.StrokeThickness = 1;
            BorderDashPart.LineStyle       = LineStyle.Dot;
            BorderDashPart.Stroke          = OxyColors.Gray;
            PlotModel.Annotations.Add(BorderDashPart);
            TextAnnotation t = new TextAnnotation();
            t.Text            = "x/δ - 1/3";
            t.TextPosition    = new DataPoint(Settings.Canal.delta + 1, 2.0 / 3.0);
            t.TextColor       = OxyColors.Black;
            t.Background      = OxyColors.Transparent;
            t.StrokeThickness = 0;
            t.FontSize        = 20;
            PlotModel.Annotations.Add(t);
#else
            PolygonAnnotation Border = new PolygonAnnotation();
            Border.Fill = OxyColors.Transparent;
            Border.Points.Add(new DataPoint(0, 10));
            Border.Points.Add(new DataPoint(0, -Settings.Canal.h));
            Border.Points.Add(new DataPoint(Settings.Canal.delta, -Settings.Canal.h));
            Border.Points.Add(new DataPoint(Settings.Canal.delta, 10));
            Border.StrokeThickness = 2;
            Border.Stroke          = OxyColors.Black;
            PlotModel.Annotations.Add(Border);
            PolygonAnnotation BorderDashPart = new PolygonAnnotation();
            BorderDashPart.Fill = OxyColors.Transparent;
            BorderDashPart.Points.Add(new DataPoint(0, -Settings.Canal.delta * Math.Sqrt(3) / 6.0));
            BorderDashPart.Points.Add(new DataPoint(Settings.Canal.delta, Settings.Canal.delta * Math.Sqrt(3) / 6.0));
            BorderDashPart.StrokeThickness = 1;
            BorderDashPart.LineStyle       = LineStyle.Dot;
            BorderDashPart.Stroke          = OxyColors.Gray;
            PlotModel.Annotations.Add(BorderDashPart);
            TextAnnotation t = new TextAnnotation();
            t.Text            = "x*sqrt(3)/3 - δ*sqrt(3)/6";
            t.TextPosition    = new DataPoint(Settings.Canal.delta - 4, Settings.Canal.delta * Math.Sqrt(3) / 6.0);
            t.TextColor       = OxyColors.Black;
            t.Background      = OxyColors.Transparent;
            t.StrokeThickness = 0;
            t.FontSize        = 20;
            PlotModel.Annotations.Add(t);
#endif
        }
 public static PlotModel PolygonAnnotationTextPosition()
 {
     var model = new PlotModel { Title = "PolygonAnnotation with fixed text position and alignment" };
     model.Axes.Add(new LinearAxis { Position = AxisPosition.Bottom, Minimum = -20, Maximum = 20 });
     model.Axes.Add(new LinearAxis { Position = AxisPosition.Left, Minimum = -10, Maximum = 10 });
     var a1 = new PolygonAnnotation { Text = "Polygon 1", TextHorizontalAlignment = HorizontalAlignment.Left, TextVerticalAlignment = VerticalAlignment.Bottom, TextPosition = new DataPoint(4.1, -1.9) };
     a1.Points.AddRange(new[] { new DataPoint(4, -2), new DataPoint(8, -2), new DataPoint(17, 7), new DataPoint(5, 8), new DataPoint(4, 5) });
     model.Annotations.Add(a1);
     return model;
 }
 public static PlotModel PolygonAnnotation()
 {
     var model = new PlotModel { Title = "PolygonAnnotation" };
     model.Axes.Add(new LinearAxis { Position = AxisPosition.Bottom, Minimum = -20, Maximum = 20 });
     model.Axes.Add(new LinearAxis { Position = AxisPosition.Left, Minimum = -10, Maximum = 10 });
     var a1 = new PolygonAnnotation { Text = "Polygon 1" };
     a1.Points.AddRange(new[] { new DataPoint(4, -2), new DataPoint(8, -4), new DataPoint(17, 7), new DataPoint(5, 8), new DataPoint(2, 5) });
     model.Annotations.Add(a1);
     return model;
 }
Beispiel #16
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());
            }
        }
        public void CreateNewStarAnnotation()
        {
            // Create annotation group and add it to the chart annotations collection
            AnnotationGroup star = new AnnotationGroup();
            star.X = 20;
            star.Y = 20;
            star.Width = 30;
            star.Height = 20;
            star.AllowSelecting = true;
            star.AllowMoving = true;
            star.AllowResizing = true;

            Chart1.Annotations.Add(star);

            // Add star shaped polygon annotation into the group

            PointF[] starPolygon = new PointF[] {
                                                    new PointF(1,6), new PointF(27,23), new PointF(33,5), new PointF(44,22), new PointF(58,0),
                                                    new PointF(57,19), new PointF(75,11), new PointF(70,28), new PointF(100,37), new PointF(81,53),
                                                    new PointF(99,65), new PointF(75,67), new PointF(87,98), new PointF(63,69), new PointF(60,94),
                                                    new PointF(47,69), new PointF(34,100), new PointF(32,69), new PointF(23,74), new PointF(26,61),
                                                    new PointF(4,72), new PointF(22,49), new PointF(0,39), new PointF(23,32), new PointF(1,6) };

            GraphicsPath starPath = new GraphicsPath();

            starPath.AddPolygon(starPolygon);
            PolygonAnnotation poly = new PolygonAnnotation();
            poly.Name = "Star";
            poly.GraphicsPath = starPath;
            star.Annotations.Add(poly);

            // Set star polygon annotation position and appearance
            star.Annotations["Star"].X = 0;
            star.Annotations["Star"].Y = 0;
            star.Annotations["Star"].Width = 100;
            star.Annotations["Star"].Height = 100;
            star.Annotations["Star"].LineColor = Color.FromArgb(64,64,64);
            star.Annotations["Star"].BackColor = Color.FromArgb(220,255,255,192);
            star.Annotations["Star"].ShadowOffset = 2;

            // Add text in the middle of the star shape
            TextAnnotation textAnnotation = new TextAnnotation();
            textAnnotation.Name = "StarText";
            textAnnotation.Text = "New !!!";
            textAnnotation.X = 20;
            textAnnotation.Y = 20;
            textAnnotation.Width = 60;
            textAnnotation.Height = 60;
            star.Annotations.Add(textAnnotation);
            star.Annotations["StarText"].Font = new Font("MS Sans Serif", 10, FontStyle.Bold|FontStyle.Italic);
            star.Annotations["StarText"].ForeColor= Color.FromArgb(26, 59, 105);
        }
Beispiel #18
0
        private void LoadActivities(string fileUrl)
        {
            SuspendLayout();

            string queryString = @"
                PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
                PREFIX nfo: <http://www.semanticdesktop.org/ontologies/2007/03/22/nfo#>
                PREFIX prov: <http://www.w3.org/ns/prov#>

                SELECT ?agent ?startTime ?endTime WHERE
                {
                  ?activity prov:qualifiedAssociation ?association .
                  ?activity prov:startedAtTime ?startTime .
                  ?activity prov:endedAtTime ?endTime .
                  ?activity prov:used ?entity .

                  ?association prov:agent ?agent .

                  ?entity nfo:fileUrl """ + Uri.EscapeUriString(fileUrl) + @""" .
                }
                ORDER BY DESC(?startTime)";

            IModel model = Models.GetAllActivities();

            SparqlQuery        query  = new SparqlQuery(queryString);
            ISparqlQueryResult result = model.ExecuteQuery(query, true);

            foreach (BindingSet binding in result.GetBindings())
            {
                Agent    agent     = new Agent(new Uri(binding["agent"].ToString()));
                DateTime startTime = ((DateTime)binding["startTime"]).RoundToMinute();
                DateTime endTime   = ((DateTime)binding["endTime"]).RoundToMinute();

                OxyColor color = _palette[agent];

                // Since we're going backward in time, we see the close activities first.
                PolygonAnnotation annotation = new PolygonAnnotation();
                annotation.Layer = AnnotationLayer.BelowAxes;
                annotation.Fill  = OxyColor.FromArgb(125, color.R, color.G, color.B);
                annotation.Points.Add(DateTimeAxis.CreateDataPoint(startTime, 0));
                annotation.Points.Add(DateTimeAxis.CreateDataPoint(startTime, 2));
                annotation.Points.Add(DateTimeAxis.CreateDataPoint(endTime, 2));
                annotation.Points.Add(DateTimeAxis.CreateDataPoint(endTime, 0));

                Model.Annotations.Add(annotation);
            }

            ResumeLayout();
        }
        public static PlotModel AnnotationLayerProperty()
        {
            var model = new PlotModel {
                Title = "Annotation Layers"
            };

            model.Axes.Add(new LinearAxis {
                Position = AxisPosition.Bottom, Minimum = -20, Maximum = 30, MajorGridlineStyle = LineStyle.Solid, MajorGridlineThickness = 1
            });
            model.Axes.Add(new LinearAxis {
                Position = AxisPosition.Left, Minimum = -10, Maximum = 10, MajorGridlineStyle = LineStyle.Solid, MajorGridlineThickness = 1
            });

            var a1 = new PolygonAnnotation
            {
                Layer = AnnotationLayer.BelowAxes,
                Text  = "Layer = BelowAxes"
            };

            a1.Points.AddRange(new[]
            {
                new DataPoint(-11, -2), new DataPoint(-7, -4), new DataPoint(-3, 7), new DataPoint(-10, 8),
                new DataPoint(-13, 5)
            });
            model.Annotations.Add(a1);
            var a2 = new PolygonAnnotation
            {
                Layer = AnnotationLayer.BelowSeries,
                Text  = "Layer = BelowSeries"
            };

            a2.Points.AddRange(new DataPoint[]
            {
                new DataPoint(4, -2), new DataPoint(8, -4), new DataPoint(12, 7), new DataPoint(5, 8),
                new DataPoint(2, 5)
            });
            model.Annotations.Add(a2);
            var a3 = new PolygonAnnotation {
                Layer = AnnotationLayer.AboveSeries, Text = "Layer = AboveSeries"
            };

            a3.Points.AddRange(new[] { new DataPoint(19, -2), new DataPoint(23, -4), new DataPoint(27, 7), new DataPoint(20, 8), new DataPoint(17, 5) });
            model.Annotations.Add(a3);

            model.Series.Add(new FunctionSeries(Math.Sin, -20, 30, 400));
            return(model);
        }
        public static PlotModel TextAnnotations()
        {
            var model = new PlotModel { Title = "TextAnnotation" };
            model.Axes.Add(new LinearAxis { Position = AxisPosition.Bottom, Minimum = -15, Maximum = 25 });
            model.Axes.Add(new LinearAxis { Position = AxisPosition.Left, Minimum = -5, Maximum = 18 });
            model.Annotations.Add(new TextAnnotation { TextPosition = new DataPoint(-6, 0), Text = "Text annotation 1" });
            model.Annotations.Add(new TextAnnotation { TextPosition = new DataPoint(-7, 10), TextRotation = 80, Text = "Text annotation 2" });
            model.Annotations.Add(new TextAnnotation { TextPosition = new DataPoint(2, 2), TextRotation = 20, TextHorizontalAlignment = HorizontalAlignment.Right, TextVerticalAlignment = VerticalAlignment.Top, Text = "Right/Top" });
            model.Annotations.Add(new TextAnnotation { TextPosition = new DataPoint(2, 4), TextRotation = 20, TextHorizontalAlignment = HorizontalAlignment.Right, TextVerticalAlignment = VerticalAlignment.Middle, Text = "Right/Middle" });
            model.Annotations.Add(new TextAnnotation { TextPosition = new DataPoint(2, 6), TextRotation = 20, TextHorizontalAlignment = HorizontalAlignment.Right, TextVerticalAlignment = VerticalAlignment.Bottom, Text = "Right/Bottom" });
            model.Annotations.Add(new TextAnnotation { TextPosition = new DataPoint(10, 2), TextRotation = 20, TextHorizontalAlignment = HorizontalAlignment.Center, TextVerticalAlignment = VerticalAlignment.Top, Text = "Center/Top" });
            model.Annotations.Add(new TextAnnotation { TextPosition = new DataPoint(10, 4), TextRotation = 20, TextHorizontalAlignment = HorizontalAlignment.Center, TextVerticalAlignment = VerticalAlignment.Middle, Text = "Center/Middle" });
            model.Annotations.Add(new TextAnnotation { TextPosition = new DataPoint(10, 6), TextRotation = 20, TextHorizontalAlignment = HorizontalAlignment.Center, TextVerticalAlignment = VerticalAlignment.Bottom, Text = "Center/Bottom" });
            model.Annotations.Add(new TextAnnotation { TextPosition = new DataPoint(18, 2), TextRotation = 20, TextHorizontalAlignment = HorizontalAlignment.Left, TextVerticalAlignment = VerticalAlignment.Top, Text = "Left/Top" });
            model.Annotations.Add(new TextAnnotation { TextPosition = new DataPoint(18, 4), TextRotation = 20, TextHorizontalAlignment = HorizontalAlignment.Left, TextVerticalAlignment = VerticalAlignment.Middle, Text = "Left/Middle" });
            model.Annotations.Add(new TextAnnotation { TextPosition = new DataPoint(18, 6), TextRotation = 20, TextHorizontalAlignment = HorizontalAlignment.Left, TextVerticalAlignment = VerticalAlignment.Bottom, Text = "Left/Bottom" });

            double d = 0.05;

            Action<double, double> addPoint = (x, y) =>
                {
                    var annotation = new PolygonAnnotation
                                         {
                                             Layer = AnnotationLayer.BelowAxes,
                                         };
                    annotation.Points.AddRange(new[]
                                                   {
                                                       new DataPoint(x - d, y - d), new DataPoint(x + d, y - d), new DataPoint(x + d, y + d),
                                                       new DataPoint(x - d, y + d), new DataPoint(x - d, y - d)
                                                   });
                    model.Annotations.Add(annotation);
                };

            foreach (var a in model.Annotations.ToArray())
            {
                var ta = a as TextAnnotation;
                if (ta != null)
                {
                    addPoint(ta.TextPosition.X, ta.TextPosition.Y);
                }
            }

            return model;
        }
        private void SetAnnotationStyle()
        {
            if (AnnotationStyle == null || AnnotationStyle.SelectedIndex == -1)
            {
                return;
            }

            if (Annotation.SelectedItem.Value.ToLower().IndexOf("line") >= 0)
            {
                Chart1.Annotations[0].LineDashStyle =
                    (ChartDashStyle)ChartDashStyle.Parse(typeof(ChartDashStyle), AnnotationStyle.SelectedItem.Value);
            }

            else if (Annotation.SelectedItem.Value == "Text" ||
                     Annotation.SelectedItem.Value == "Rectangle" ||
                     Annotation.SelectedItem.Value == "Ellipse")
            {
                Chart1.Annotations[0].TextStyle =
                    (TextStyle)TextStyle.Parse(typeof(TextStyle), AnnotationStyle.SelectedItem.Value);
            }
            else if (Annotation.SelectedItem.Value == "Arrow")
            {
                ((ArrowAnnotation)Chart1.Annotations[0]).ArrowStyle =
                    (ArrowStyle)ArrowStyle.Parse(typeof(ArrowStyle), AnnotationStyle.SelectedItem.Value);
            }
            else if (Annotation.SelectedItem.Value == "Border3D")
            {
                ((Border3DAnnotation)Chart1.Annotations[0]).BorderSkin.SkinStyle =
                    (BorderSkinStyle)BorderSkinStyle.Parse(typeof(BorderSkinStyle), AnnotationStyle.SelectedItem.Value);
            }
            else if (Annotation.SelectedItem.Value == "Callout")
            {
                ((CalloutAnnotation)Chart1.Annotations[0]).CalloutStyle =
                    (CalloutStyle)CalloutStyle.Parse(typeof(CalloutStyle), AnnotationStyle.SelectedItem.Value);
            }
            else if (Annotation.SelectedItem.Value == "Polygon")
            {
                PolygonAnnotation annotation = (PolygonAnnotation)Chart1.Annotations[0];

                annotation.BackColor = Color.FromArgb(128, Color.FromName(AnnotationStyle.SelectedItem.Value));
            }
        }
        public static PlotModel PolygonAnnotationTextPosition()
        {
            var model = new PlotModel {
                Title = "PolygonAnnotation with fixed text position and alignment"
            };

            model.Axes.Add(new LinearAxis {
                Position = AxisPosition.Bottom, Minimum = -20, Maximum = 20
            });
            model.Axes.Add(new LinearAxis {
                Position = AxisPosition.Left, Minimum = -10, Maximum = 10
            });
            var a1 = new PolygonAnnotation {
                Text = "Polygon 1", TextHorizontalAlignment = HorizontalAlignment.Left, TextVerticalAlignment = VerticalAlignment.Bottom, TextPosition = new DataPoint(4.1, -1.9)
            };

            a1.Points.AddRange(new[] { new DataPoint(4, -2), new DataPoint(8, -2), new DataPoint(17, 7), new DataPoint(5, 8), new DataPoint(4, 5) });
            model.Annotations.Add(a1);
            return(model);
        }
        public static PlotModel PolygonAnnotation()
        {
            var model = new PlotModel {
                Title = "PolygonAnnotation"
            };

            model.Axes.Add(new LinearAxis {
                Position = AxisPosition.Bottom, Minimum = -20, Maximum = 20
            });
            model.Axes.Add(new LinearAxis {
                Position = AxisPosition.Left, Minimum = -10, Maximum = 10
            });
            var a1 = new PolygonAnnotation {
                Text = "Polygon 1"
            };

            a1.Points.AddRange(new[] { new DataPoint(4, -2), new DataPoint(8, -4), new DataPoint(17, 7), new DataPoint(5, 8), new DataPoint(2, 5) });
            model.Annotations.Add(a1);
            return(model);
        }
Beispiel #24
0
        public static PlotModel PolygonAnnotation()
        {
            var model = new PlotModel {
                Title = "PolygonAnnotation", Subtitle = "Click the polygon"
            };

            model.Axes.Add(new LinearAxis {
                Position = AxisPosition.Left, Minimum = -20, Maximum = 20
            });
            model.Axes.Add(new LinearAxis {
                Position = AxisPosition.Bottom, Minimum = -20, Maximum = 20
            });
            var pa = new PolygonAnnotation
            {
                Text = "Polygon 1"
            };

            pa.Points.AddRange(new[]
            {
                new DataPoint(4, -2), new DataPoint(8, -4), new DataPoint(17, 7), new DataPoint(5, 8),
                new DataPoint(2, 5)
            });

            // Handle left mouse clicks
            int hitCount = 1;

            pa.MouseDown += (s, e) =>
            {
                if (e.ChangedButton != OxyMouseButton.Left)
                {
                    return;
                }

                pa.Text = "Hit # " + hitCount++;
                model.InvalidatePlot(false);
                e.Handled = true;
            };

            model.Annotations.Add(pa);
            return(model);
        }
Beispiel #25
0
        private void AnnotationStyle_SelectedIndexChanged(object sender, System.EventArgs e)
        {
            if (Annotation.SelectedItem.ToString().ToLower().IndexOf("line") >= 0)
            {
                Chart1.Annotations[0].LineDashStyle =
                    (ChartDashStyle)ChartDashStyle.Parse(typeof(ChartDashStyle), AnnotationStyle.SelectedItem.ToString());
            }
            else if (Annotation.SelectedItem.ToString() == "Text" ||
                     Annotation.SelectedItem.ToString() == "Rectangle" ||
                     Annotation.SelectedItem.ToString() == "Ellipse")
            {
                //FIXFIX

                /*
                 *              Chart1.Annotations[0].TextStyle =
                 *                      (TextStyle)TextStyle.Parse(typeof(TextStyle), AnnotationStyle.SelectedItem.ToString());*/
            }
            else if (Annotation.SelectedItem.ToString() == "Arrow")
            {
                ((ArrowAnnotation)Chart1.Annotations[0]).ArrowStyle =
                    (ArrowStyle)ArrowStyle.Parse(typeof(ArrowStyle), AnnotationStyle.SelectedItem.ToString());
            }
            else if (Annotation.SelectedItem.ToString() == "Border3D")
            {
                ((Border3DAnnotation)Chart1.Annotations[0]).BorderSkin.SkinStyle =
                    (BorderSkinStyle)BorderSkinStyle.Parse(typeof(BorderSkinStyle), AnnotationStyle.SelectedItem.ToString());
            }
            else if (Annotation.SelectedItem.ToString() == "Callout")
            {
                ((CalloutAnnotation)Chart1.Annotations[0]).CalloutStyle =
                    (CalloutStyle)CalloutStyle.Parse(typeof(CalloutStyle), AnnotationStyle.SelectedItem.ToString());
            }
            else if (Annotation.SelectedItem.ToString() == "Polygon")
            {
                PolygonAnnotation annotation = (PolygonAnnotation)Chart1.Annotations[0];

                annotation.BackColor = Color.FromArgb(128, Color.FromName(AnnotationStyle.SelectedItem.ToString()));
            }
        }
Beispiel #26
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");
        }
Beispiel #27
0
        /**
         * Creates annotation, type of annotation is taken from given properties
         */
        public static Annotation CreateAnnotation(Document doc, Page page, int index, AnnotationProperties props)
        {
            Annotation ann      = null;
            int        addAfter = index - 1;

            switch (props.Subtype)
            {
            case "Line": ann = new LineAnnotation(page, props.BoundingRect, props.StartPoint, props.EndPoint, addAfter); break;

            case "Circle": ann = new CircleAnnotation(page, props.BoundingRect, addAfter); break;

            case "Square": ann = new SquareAnnotation(page, props.BoundingRect, addAfter); break;

            case "FreeText": ann = new FreeTextAnnotation(page, props.BoundingRect, "", addAfter); break;

            case "PolyLine": ann = new PolyLineAnnotation(page, props.BoundingRect, props.Vertices, addAfter); break;

            case "Polygon": ann = new PolygonAnnotation(page, props.BoundingRect, props.Vertices, addAfter); break;

            case "Link": ann = new LinkAnnotation(page, props.BoundingRect, addAfter); break;

            case "Ink": ann = new InkAnnotation(page, props.BoundingRect, addAfter); break;

            case "Underline": ann = new UnderlineAnnotation(page, addAfter, props.Quads); break;

            case "Highlight": ann = new HighlightAnnotation(page, addAfter, props.Quads); break;

            default: throw new Exception("Logic error");
            }
            AnnotationAppearance app = new AnnotationAppearance(doc, ann);

            app.CaptureAnnotation();
            app.Properties.SetFrom(props);
            app.Properties.Dirty = true;
            app.UpdateAppearance();
            app.ReleaseAnnotation();
            return(ann);
        }
        private void DrawPolygon_OnMouseUp(object sender, OxyMouseEventArgs args)
        {
            if (_tempAnnot == null)
                return;

            var polyAnnot = new PolygonAnnotation
            {
                Color = OxyColors.Undefined,
                Fill = OxyColor.FromAColor(byte.Parse(uiSetFillAlphaTextBox.Text),
                                           uiSetFillColorButton.BackColor.ToOxyColor()),
                Layer = (AnnotationLayer) uiSetLayerComboBox.SelectedItem,
                LineStyle = LineStyle.None,
                StrokeThickness = 0,
                Text = uiSetTextTextBox.Text
            };
            polyAnnot.Points.AddRange(((PolylineAnnotation) _tempAnnot).Points);

            ChartModel.Annotations.Remove(_tempAnnot);
            ChartModel.Annotations.Add(polyAnnot);

            _tempAnnot = null;
            ChartModel.InvalidatePlot(false);
            args.Handled = true;
        }
        static void Main(string[] args)
        {
            Console.WriteLine("PolygonAnnotation Sample:");
            // ReSharper disable once UnusedVariable
            using (Library lib = new Library())
            {
                Console.WriteLine("Initialized the library.");

                String sOutput = "PolygonAnnotations-out.pdf";

                if (args.Length > 0)
                {
                    sOutput = args[0];
                }

                Console.WriteLine("Writing to output " + sOutput);

                // Create a new document and blank first page
                Document doc  = new Document();
                Rect     rect = new Rect(0, 0, 612, 792);
                Page     page = doc.CreatePage(Document.BeforeFirstPage, rect);
                Console.WriteLine("Created new document and first page.");

                // Create a vector of polygon vertices
                List <Point> vertices = new List <Point>();
                Point        p        = new Point(100, 100);
                vertices.Add(p);
                p = new Point(200, 300);
                vertices.Add(p);
                p = new Point(400, 200);
                vertices.Add(p);
                Console.WriteLine("Created an array of vertex points.");

                // Create and add a new PolygonAnnotation to the 0th element of first page's annotation array
                PolygonAnnotation polygonAnnot = new PolygonAnnotation(page, rect, vertices, -1);
                Console.WriteLine("Created new PolygonAnnotation as 0th element of annotation array.");

                // Now let's retrieve and display the vertices
                IList <Point> vertices2;
                vertices2 = polygonAnnot.Vertices;
                Console.WriteLine("Retrieved the vertices of the polygon annotation.");
                Console.WriteLine("They are:");
                for (int i = 0; i < vertices2.Count; i++)
                {
                    Console.WriteLine("Vertex " + i + ": " + vertices2[i]);
                }

                // Let's set some colors and then ask the polyline to generate an appearance stream
                Color color = new Color(0.5, 0.3, 0.8);
                polygonAnnot.InteriorColor = color;
                color = new Color(0.9, 0.7, 0.1);
                polygonAnnot.Color = color;
                Console.WriteLine("Set the stroke and fill colors.");
                Form form = polygonAnnot.GenerateAppearance();
                polygonAnnot.NormalAppearance = form;
                Console.WriteLine("Generated the appearance stream.");

                // Update the page's content and save the file with clipping
                page.UpdateContent();
                doc.Save(SaveFlags.Full, sOutput);

                // Dispose the doc object
                doc.Dispose();
                Console.WriteLine("Disposed document object.");
            }
        }
Beispiel #30
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);
        }
        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);
            }
        }
        public static PlotModel PolygonAnnotation()
        {
            var model = new PlotModel("PolygonAnnotation", "Click the polygon");
            model.Axes.Add(new LinearAxis(AxisPosition.Bottom, -20, 20));
            model.Axes.Add(new LinearAxis(AxisPosition.Left, -10, 10));
            var pa = new PolygonAnnotation
                {
                    Points =
                        new[]
                            {
                                new DataPoint(4, -2), new DataPoint(8, -4), new DataPoint(17, 7), new DataPoint(5, 8),
                                new DataPoint(2, 5)
                            },
                    Text = "Polygon 1"
                };

            // Handle left mouse clicks
            int hitCount = 1;
            pa.MouseDown += (s, e) =>
                {
                    if (e.ChangedButton != OxyMouseButton.Left)
                    {
                        return;
                    }

                    pa.Text = "Hit # " + hitCount++;
                    model.InvalidatePlot(false);
                    e.Handled = true;
                };

            model.Annotations.Add(pa);
            return model;
        }
 public void PolygonAnnotation()
 {
     var s1 = new PolygonAnnotation();
     var s2 = new Annotations.PolygonAnnotation();
     OxyAssert.PropertiesAreEqual(s1, s2);
 }
        public static PlotModel TextAnnotations()
        {
            var model = new PlotModel {
                Title = "TextAnnotation"
            };

            model.Axes.Add(new LinearAxis {
                Position = AxisPosition.Bottom, Minimum = -15, Maximum = 25
            });
            model.Axes.Add(new LinearAxis {
                Position = AxisPosition.Left, Minimum = -5, Maximum = 18
            });
            model.Annotations.Add(new TextAnnotation {
                TextPosition = new DataPoint(-6, 0), Text = "Text annotation 1"
            });
            model.Annotations.Add(new TextAnnotation {
                TextPosition = new DataPoint(-7, 10), TextRotation = 80, Text = "Text annotation 2"
            });
            model.Annotations.Add(new TextAnnotation {
                TextPosition = new DataPoint(2, 2), TextRotation = 20, TextHorizontalAlignment = HorizontalAlignment.Right, TextVerticalAlignment = VerticalAlignment.Top, Text = "Right/Top"
            });
            model.Annotations.Add(new TextAnnotation {
                TextPosition = new DataPoint(2, 4), TextRotation = 20, TextHorizontalAlignment = HorizontalAlignment.Right, TextVerticalAlignment = VerticalAlignment.Middle, Text = "Right/Middle"
            });
            model.Annotations.Add(new TextAnnotation {
                TextPosition = new DataPoint(2, 6), TextRotation = 20, TextHorizontalAlignment = HorizontalAlignment.Right, TextVerticalAlignment = VerticalAlignment.Bottom, Text = "Right/Bottom"
            });
            model.Annotations.Add(new TextAnnotation {
                TextPosition = new DataPoint(10, 2), TextRotation = 20, TextHorizontalAlignment = HorizontalAlignment.Center, TextVerticalAlignment = VerticalAlignment.Top, Text = "Center/Top"
            });
            model.Annotations.Add(new TextAnnotation {
                TextPosition = new DataPoint(10, 4), TextRotation = 20, TextHorizontalAlignment = HorizontalAlignment.Center, TextVerticalAlignment = VerticalAlignment.Middle, Text = "Center/Middle"
            });
            model.Annotations.Add(new TextAnnotation {
                TextPosition = new DataPoint(10, 6), TextRotation = 20, TextHorizontalAlignment = HorizontalAlignment.Center, TextVerticalAlignment = VerticalAlignment.Bottom, Text = "Center/Bottom"
            });
            model.Annotations.Add(new TextAnnotation {
                TextPosition = new DataPoint(18, 2), TextRotation = 20, TextHorizontalAlignment = HorizontalAlignment.Left, TextVerticalAlignment = VerticalAlignment.Top, Text = "Left/Top"
            });
            model.Annotations.Add(new TextAnnotation {
                TextPosition = new DataPoint(18, 4), TextRotation = 20, TextHorizontalAlignment = HorizontalAlignment.Left, TextVerticalAlignment = VerticalAlignment.Middle, Text = "Left/Middle"
            });
            model.Annotations.Add(new TextAnnotation {
                TextPosition = new DataPoint(18, 6), TextRotation = 20, TextHorizontalAlignment = HorizontalAlignment.Left, TextVerticalAlignment = VerticalAlignment.Bottom, Text = "Left/Bottom"
            });

            double d = 0.05;

            Action <double, double> addPoint = (x, y) =>
            {
                var annotation = new PolygonAnnotation
                {
                    Layer = AnnotationLayer.BelowAxes,
                };
                annotation.Points.AddRange(new[]
                {
                    new DataPoint(x - d, y - d), new DataPoint(x + d, y - d), new DataPoint(x + d, y + d),
                    new DataPoint(x - d, y + d), new DataPoint(x - d, y - d)
                });
                model.Annotations.Add(annotation);
            };

            foreach (var a in model.Annotations.ToArray())
            {
                var ta = a as TextAnnotation;
                if (ta != null)
                {
                    addPoint(ta.TextPosition.X, ta.TextPosition.Y);
                }
            }

            return(model);
        }
Beispiel #35
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 = "";
            }
        }
        public static BaseAnnotation Translate(ImageDoc.Annotation annotation, float scale, ColourFormat colourFormat, PointF controlOffset, PointF imageOffset)
        {
            BaseAnnotation imagingAnnotation = null;
            ImageDoc.ImagingAnnotationTypes annType = (ImageDoc.ImagingAnnotationTypes)
                Enum.Parse(typeof(ImageDoc.ImagingAnnotationTypes), annotation.AnnotationType);
            switch (annType) {
                case ImageDoc.ImagingAnnotationTypes.FreeLine: {
                    imagingAnnotation
                        = new FreeLineAnnotation(SimpleTypeToColor(annotation.LineColor), annotation.LineThickness, scale, colourFormat, controlOffset, imageOffset);
                    break;

                }
                case ImageDoc.ImagingAnnotationTypes.Highlighter: case ImageDoc.ImagingAnnotationTypes.Polygon: {
                    imagingAnnotation = new PolygonAnnotation(SimpleTypeToColor(annotation.LineColor), annotation.LineThickness, scale, colourFormat, controlOffset, imageOffset);
                }
                    break;
                case ImageDoc.ImagingAnnotationTypes.Stamp: {
                        imagingAnnotation = new StampAnnotation(annotation.LineThickness, scale, colourFormat, controlOffset, imageOffset);
                    }
                    break;
                case ImageDoc.ImagingAnnotationTypes.StraightLine: {
                    imagingAnnotation = new StraightLineAnnotation(SimpleTypeToColor(annotation.LineColor), annotation.LineThickness, scale, colourFormat, controlOffset, imageOffset);
                    }
                    break;
                case ImageDoc.ImagingAnnotationTypes.TextAnnotation: {
                    // Top left of the text
                    Point topLeft = new Point((int)annotation.Rect.TopLeft.X, (int)annotation.Rect.TopLeft.Y);
                    imagingAnnotation = new TextAnnotation(topLeft, controlOffset, imageOffset, scale, colourFormat);
                    }
                    break;
                case ImageDoc.ImagingAnnotationTypes.Svg: {
                        // Top left of the text
                    Point topLeft = new Point((int)annotation.Rect.TopLeft.X, (int)annotation.Rect.TopLeft.Y);
                        imagingAnnotation = new SvgAnnotation(topLeft, controlOffset, imageOffset, scale, colourFormat);
                        (imagingAnnotation as SvgAnnotation).ImageName = annotation.SvgImageName;
                    }
                    break;
            }
            if ((imagingAnnotation is PolygonAnnotation)) {
                (imagingAnnotation as PolygonAnnotation).ShapeName = annotation.SvgImageName;
                foreach (ImageDoc.Point point in annotation.Points) {
                    Point intPoint = new Point((int)point.X, (int)point.Y);
                    (imagingAnnotation as PolygonAnnotation).AddPoint(intPoint);
                }
                // This forces the initialisation of some required objects
                (imagingAnnotation as PolygonAnnotation).EndDrawing();
            }
            if ((imagingAnnotation is StampAnnotation)) {
                foreach (ImageDoc.Point point in annotation.Points) {
                    Point intPoint = new Point((int)point.X, (int)point.Y);
                    (imagingAnnotation as StampAnnotation).Points.Add(intPoint);
                }
            }
            if ((imagingAnnotation is TextAnnotation)) {
                (imagingAnnotation as TextAnnotation).Text = annotation.Text;
                (imagingAnnotation as TextAnnotation).TextFont = annotation.Font.ToFont();
                (imagingAnnotation as TextAnnotation).TextColor = SimpleTypeToColor(annotation.TextColor);
            }
            imagingAnnotation.Rect = SimpleTypeToRect(annotation.Rect);
            imagingAnnotation.Filled = true;
            imagingAnnotation.FillColor = SimpleTypeToColor(annotation.FillColor);
            imagingAnnotation.FillOpacity = annotation.FillOpacity;
            //imagingAnnotation.Outline = annotation.Outline;
            return imagingAnnotation;
        }
Beispiel #37
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());
            }
        }
Beispiel #38
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);
                            }
                        }
                    }
                }
            }
        }
Beispiel #39
0
        public static PlotModel PolygonAnnotation()
        {
            var model = new PlotModel { Title = "PolygonAnnotation", Subtitle = "Click the polygon" };
            model.Axes.Add(new LinearAxis { Position = AxisPosition.Left, Minimum = -20, Maximum = 20 });
            model.Axes.Add(new LinearAxis { Position = AxisPosition.Bottom, Minimum = -20, Maximum = 20 });
            var pa = new PolygonAnnotation
                {
                    Text = "Polygon 1"
                };
            pa.Points.AddRange(new[]
                            {
                                new DataPoint(4, -2), new DataPoint(8, -4), new DataPoint(17, 7), new DataPoint(5, 8),
                                new DataPoint(2, 5)
                            });

            // Handle left mouse clicks
            int hitCount = 1;
            pa.MouseDown += (s, e) =>
                {
                    if (e.ChangedButton != OxyMouseButton.Left)
                    {
                        return;
                    }

                    pa.Text = "Hit # " + hitCount++;
                    model.InvalidatePlot(false);
                    e.Handled = true;
                };

            model.Annotations.Add(pa);
            return model;
        }
Beispiel #40
0
        private static void AddHLThresholdsAnnotation()
        {
            PolygonAnnotation profoundHL = new PolygonAnnotation();

            profoundHL.Text         = AnnotationText.ProfoundHL;
            profoundHL.TextPosition = new DataPoint(AudiogramAxes.FreqAxisMinHz + AnnotationText.AnnotationTextOffset,
                                                    HLThreshold.ProfoundHLdB + AnnotationText.AnnotationTextOffset);
            profoundHL.TextHorizontalAlignment = HorizontalAlignment.Left;
            profoundHL.Layer = AnnotationLayer.BelowAxes;
            profoundHL.Fill  = OxyColor.FromRgb(ProfoundHLFill.Red, ProfoundHLFill.Green, ProfoundHLFill.Blue);
            profoundHL.Points.Add(new DataPoint(AudiogramAxes.FreqAxisMinHz, AudiogramAxes.PowerAxisMaxdB));
            profoundHL.Points.Add(new DataPoint(AudiogramAxes.FreqAxisMaxHz, AudiogramAxes.PowerAxisMaxdB));
            profoundHL.Points.Add(new DataPoint(AudiogramAxes.FreqAxisMaxHz, HLThreshold.ProfoundHLdB));
            profoundHL.Points.Add(new DataPoint(AudiogramAxes.FreqAxisMinHz, HLThreshold.ProfoundHLdB));

            PolygonAnnotation severeHL = new PolygonAnnotation();

            severeHL.Text         = AnnotationText.SevereHL;
            severeHL.TextPosition = new DataPoint(AudiogramAxes.FreqAxisMinHz + AnnotationText.AnnotationTextOffset,
                                                  HLThreshold.SevereHLdB + AnnotationText.AnnotationTextOffset);
            severeHL.TextHorizontalAlignment = HorizontalAlignment.Left;
            severeHL.Layer = AnnotationLayer.BelowAxes;
            severeHL.Fill  = OxyColor.FromRgb(SevereHLFill.Red, SevereHLFill.Green, SevereHLFill.Blue);
            severeHL.Points.Add(new DataPoint(AudiogramAxes.FreqAxisMinHz, HLThreshold.ProfoundHLdB));
            severeHL.Points.Add(new DataPoint(AudiogramAxes.FreqAxisMaxHz, HLThreshold.ProfoundHLdB));
            severeHL.Points.Add(new DataPoint(AudiogramAxes.FreqAxisMaxHz, HLThreshold.SevereHLdB));
            severeHL.Points.Add(new DataPoint(AudiogramAxes.FreqAxisMinHz, HLThreshold.SevereHLdB));

            PolygonAnnotation moderateHL = new PolygonAnnotation();

            moderateHL.Text         = AnnotationText.ModerateHL;
            moderateHL.TextPosition = new DataPoint(AudiogramAxes.FreqAxisMinHz + AnnotationText.AnnotationTextOffset,
                                                    HLThreshold.ModerateHLdB + AnnotationText.AnnotationTextOffset);
            moderateHL.TextHorizontalAlignment = HorizontalAlignment.Left;
            moderateHL.Layer = AnnotationLayer.BelowAxes;
            moderateHL.Fill  = OxyColor.FromRgb(ModerateHLFill.Red, ModerateHLFill.Green, ModerateHLFill.Blue);
            moderateHL.Points.Add(new DataPoint(AudiogramAxes.FreqAxisMinHz, HLThreshold.SevereHLdB));
            moderateHL.Points.Add(new DataPoint(AudiogramAxes.FreqAxisMaxHz, HLThreshold.SevereHLdB));
            moderateHL.Points.Add(new DataPoint(AudiogramAxes.FreqAxisMaxHz, HLThreshold.ModerateHLdB));
            moderateHL.Points.Add(new DataPoint(AudiogramAxes.FreqAxisMinHz, HLThreshold.ModerateHLdB));

            PolygonAnnotation mildHL = new PolygonAnnotation();

            mildHL.Text         = AnnotationText.MildHL;
            mildHL.TextPosition = new DataPoint(AudiogramAxes.FreqAxisMinHz + AnnotationText.AnnotationTextOffset,
                                                HLThreshold.MildHLdB + AnnotationText.AnnotationTextOffset);
            mildHL.TextHorizontalAlignment = HorizontalAlignment.Left;
            mildHL.Layer = AnnotationLayer.BelowAxes;
            mildHL.Fill  = OxyColor.FromRgb(MildHLFill.Red, MildHLFill.Green, MildHLFill.Blue);
            mildHL.Points.Add(new DataPoint(AudiogramAxes.FreqAxisMinHz, HLThreshold.ModerateHLdB));
            mildHL.Points.Add(new DataPoint(AudiogramAxes.FreqAxisMaxHz, HLThreshold.ModerateHLdB));
            mildHL.Points.Add(new DataPoint(AudiogramAxes.FreqAxisMaxHz, HLThreshold.MildHLdB));
            mildHL.Points.Add(new DataPoint(AudiogramAxes.FreqAxisMinHz, HLThreshold.MildHLdB));

            PolygonAnnotation normal = new PolygonAnnotation();

            normal.Text         = AnnotationText.NormalHL;
            normal.TextPosition = new DataPoint(AudiogramAxes.FreqAxisMinHz + AnnotationText.AnnotationTextOffset,
                                                HLThreshold.NormalHLdB + AnnotationText.AnnotationTextOffset);
            normal.TextHorizontalAlignment = HorizontalAlignment.Left;
            normal.Layer = AnnotationLayer.BelowAxes;
            normal.Fill  = OxyColor.FromRgb(NormalFill.Red, NormalFill.Green, NormalFill.Blue);
            normal.Points.Add(new DataPoint(AudiogramAxes.FreqAxisMinHz, HLThreshold.MildHLdB));
            normal.Points.Add(new DataPoint(AudiogramAxes.FreqAxisMaxHz, HLThreshold.MildHLdB));
            normal.Points.Add(new DataPoint(AudiogramAxes.FreqAxisMaxHz, HLThreshold.NormalHLdB));
            normal.Points.Add(new DataPoint(AudiogramAxes.FreqAxisMinHz, HLThreshold.NormalHLdB));

            PlotModel.Annotations.Add(normal);
            PlotModel.Annotations.Add(mildHL);
            PlotModel.Annotations.Add(moderateHL);
            PlotModel.Annotations.Add(severeHL);
            PlotModel.Annotations.Add(profoundHL);
        }