Esempio n. 1
1
 public static bool AddCustomSnapshot( Chart TimeLineChart, CursorEventArgs Event )
 {
     if( TimeLineChart.Series["Allocated Memory"].Points.Count == 0 )
     {
         return false;
     }
     else
     {
         VerticalLineAnnotation A = new VerticalLineAnnotation();
         A.AxisX = Event.Axis;
         A.AnchorX = ( int )Event.NewSelectionStart + 1;
         A.ToolTip = "Snapshot";
         A.IsInfinitive = true;
         TimeLineChart.Annotations.Add( A );
         return true;
     }
 }
Esempio n. 2
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 = "";
            }
        }
        private void UpdateLabel(VerticalLineAnnotation annotation)
        {
            var expr = annotation.GetBindingExpression(LineAnnotationWithLabelsBase.LabelValueProperty);

            if (expr != null)
            {
                var binding = expr.ParentBinding;
                annotation.SetBinding(LineAnnotationWithLabelsBase.LabelValueProperty, binding);
            }
        }
Esempio n. 4
0
        /// <summary>
        /// Method to create a vertical line on graphics.
        /// The verticale line is situated with a double value
        /// </summary>
        void CreateVerticalLineByValue(double value, Color line_color)
        {
            VerticalLineAnnotation LA = new VerticalLineAnnotation();

            LA.LineColor       = line_color;
            LA.LineWidth       = 3;
            LA.IsInfinitive    = true;
            LA.AnchorDataPoint = ProportionsChart.Series["Pings"].Points[0];
            LA.X = value;
            LA.ClipToChartArea = ProportionsChart.ChartAreas[0].Name;
            ProportionsChart.Annotations.Add(LA);
        }
Esempio n. 5
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());
            }
        }
Esempio n. 6
0
        public void findLine()
        {
            List <Series> s_list = new List <Series>();

            for (int i = 0; i < chart1.Series.Count / 2; i++)
            {
                s_list.Add(chart1.Series[i]);
            }

            int    count   = 0;
            string current = "None";

            for (int i = 0; i < s_list[0].Points.Count; i++)
            {
                double max = s_list.Select(x => x.Points[i].YValues[0]).Max();
                //Console.WriteLine(max.ToString());
                if (max != 0)
                {
                    Series s = s_list[s_list.Select(x => x.Points[i].YValues[0]).ToList().IndexOf(max)];
                    Console.WriteLine(s.Name);
                    if (current != s.Name)
                    {
                        if (count != 0)
                        {
                            VerticalLineAnnotation VA = new VerticalLineAnnotation();
                            VA.AxisX         = chart1.ChartAreas[0].AxisX;
                            VA.IsInfinitive  = true;
                            VA.LineColor     = Color.Black;
                            VA.LineWidth     = 3;
                            VA.LineDashStyle = ChartDashStyle.Dash;
                            VA.X             = i;
                            VA.Name          = "VA Bayes : " + i;
                            chart1.Annotations.Add(VA);

                            TextAnnotation TA = new TextAnnotation();
                            TA.AxisX = chart1.ChartAreas[0].AxisX;
                            TA.X     = i;
                            TA.Y     = 0;
                            TA.Name  = "TA Bayes : " + i;
                            TA.Text  = i + "";
                            if (asc.currentSize != 0)
                            {
                                TA.Font = new Font(TA.Font.Name, asc.currentSize);
                            }
                            chart1.Annotations.Add(TA);
                        }
                        current = s.Name;
                        count++;
                    }
                }
            }
        }
        public HS(int G)
        {
            InitializeComponent();
            button3.Enabled                    = false;
            chart1.Series[0].ChartType         = System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Line;
            chart1.Series[0].BorderWidth       = 3;
            chart1.Series[0].Color             = Color.Red;
            chart1.Series[0].IsVisibleInLegend = false;
            chart1.Series.Add(new Series());
            chart1.Series[1].ChartType         = SeriesChartType.Point;
            chart1.Series[1].IsVisibleInLegend = false;
            chart1.ChartAreas[0].AxisY.Minimum = 2000;
            chart1.ChartAreas[0].AxisY.Maximum = 4000;
            chart1.ChartAreas[0].AxisX.Minimum = 6000;
            chart1.ChartAreas[0].AxisX.Maximum = 8000;
            chart1.ChartAreas[0].AxisX.Title   = "S, Дж/кгК";
            chart1.ChartAreas[0].AxisY.Title   = "H, кДж/кг";
            comboBox1.Items.Add("Отсеке");
            comboBox1.SelectedIndex = 0;
            this.G = G;
            for (int i = 0; i < G; i++)
            {
                comboBox1.Items.Add("" + (i + 1));
            }
            Hi  = new VerticalLineAnnotation[G];
            RHi = new TextAnnotation[G];
            for (int i = 0; i < G; i++)
            {
                RHi[i]       = new TextAnnotation();
                RHi[i].AxisX = chart1.ChartAreas[0].AxisX;
                RHi[i].AxisY = chart1.ChartAreas[0].AxisY;
                RHi[i].IsSizeAlwaysRelative = false;
                RHi[i].Text      = "Hi" + (i + 1);
                RHi[i].ForeColor = Color.Black;
                RHi[i].Font      = new Font("Arial", 12);
                RHi[i].LineWidth = 2;


                Hi[i]       = new VerticalLineAnnotation();
                Hi[i].AxisX = chart1.ChartAreas[0].AxisX;
                Hi[i].AxisY = chart1.ChartAreas[0].AxisY;
                Hi[i].IsSizeAlwaysRelative = false;

                Hi[i].StartCap        = LineAnchorCapStyle.Arrow;
                Hi[i].EndCap          = LineAnchorCapStyle.Arrow;
                Hi[i].IsInfinitive    = false;
                Hi[i].ClipToChartArea = chart1.ChartAreas[0].Name;
                Hi[i].LineColor       = Color.Black; Hi[i].LineWidth = 2;
            }
            Construct(G);
        }
Esempio n. 8
0
        private void AddDataRangeBoundaryAnnotation(double x)
        {
            var anot = new VerticalLineAnnotation()
            {
                CoordinateMode = AnnotationCoordinateMode.Absolute,
                Stroke         = new SolidColorBrush(Colors.Red),
                YAxisId        = "mainYAxis",
                X1             = GetXAxisDataValueFixed(x),
                IsEditable     = false,
                Name           = LineAnnotationNamePrefix + _dataRangeLinesCount
            };

            ParentSurface.Annotations.Add(anot);
        }
Esempio n. 9
0
        // metoda rysująca podziałki
        public void VerticalLine(Chart chart, int x, List <double> time)
        {
            VerticalLineAnnotation VA = new VerticalLineAnnotation();

            VA.AxisX         = chart.ChartAreas[0].AxisX;
            VA.AllowMoving   = false;
            VA.Visible       = true;
            VA.AnchorOffsetX = 0;
            VA.IsInfinitive  = true;
            VA.LineColor     = Color.BlueViolet;
            VA.LineWidth     = 1;
            VA.X             = time[x];
            chart.Annotations.Add(VA);
        }
        public void Annotations(int i, Chart chart1)
        {
            Hi[i].AnchorY  = P.i0[i] * 0.001 - P.Hi[i];
            Hi[i].Height   = P.Hi[i];
            Hi[i].AnchorX  = P.s0[i] + DHS;
            RHi[i].AnchorX = Hi[i].AnchorX + 20;
            RHi[i].AnchorY = Hi[i].AnchorY + Hi[i].Height / 2;
            chart1.Annotations.Add(Hi[i]);
            chart1.Annotations.Add(RHi[i]);
            if (once1 && i == P.Z - 1)
            {
                once1 = false;
                TextAnnotation annotation = new TextAnnotation();
                annotation.AxisX = chart1.ChartAreas[0].AxisX;
                annotation.AxisY = chart1.ChartAreas[0].AxisY;
                annotation.IsSizeAlwaysRelative = false;
                annotation.Text      = "H0";
                annotation.ForeColor = Color.Black;
                annotation.Font      = new Font("Arial", 12);
                annotation.LineWidth = 2;


                VerticalLineAnnotation ann = new VerticalLineAnnotation();
                ann.AxisX = chart1.ChartAreas[0].AxisX;
                ann.AxisY = chart1.ChartAreas[0].AxisY;
                ann.IsSizeAlwaysRelative = false;
                if (P.HS > 0)
                {
                    ann.AnchorY = P.i0[0] * 0.001 - P.HS;
                    ann.Height  = P.HS;
                }
                else
                {
                    ann.AnchorY = P.i0[0] * 0.001 - P.H0[0];
                    ann.Height  = P.H0[0];
                }
                ann.AnchorX         = P.s0[0] - DHS;
                ann.StartCap        = LineAnchorCapStyle.Arrow;
                ann.EndCap          = LineAnchorCapStyle.Arrow;
                ann.IsInfinitive    = false;
                ann.ClipToChartArea = chart1.ChartAreas[0].Name;
                ann.LineColor       = Color.Black; ann.LineWidth = 2;

                annotation.AnchorX = ann.AnchorX - 15;
                annotation.AnchorY = ann.AnchorY + ann.Height / 2;

                chart1.Annotations.Add(ann);
                chart1.Annotations.Add(annotation);
            }
        }
        private void GenerateHistogramData()
        {
            if (this.Image != null)
            {
                Emgu.CV.Image <Bgr, byte> img = new Emgu.CV.Image <Bgr, byte>(this.Image as Bitmap);

                Emgu.CV.Image <Gray, byte>[] channels = img.Split();

                List <Color> colors = new List <Color>()
                {
                    Color.FromArgb(128, 0, 0, 255),
                    Color.FromArgb(128, 0, 255, 0),
                    Color.FromArgb(128, 255, 0, 0),
                };

                for (int c = 0; c < channels.Length; c++)
                {
                    Emgu.CV.DenseHistogram histo = new Emgu.CV.DenseHistogram(256, new RangeF(0, 255));
                    histo.Calculate <byte>(new Emgu.CV.Image <Gray, byte>[] { channels[c] }, false, null);
                    float[] values = histo.GetBinValues();

                    Series channelSeries = new Series()
                    {
                        ChartType = SeriesChartType.Column,
                        Color     = colors[c],
                    };

                    for (int i = 0; i < 256; i++)
                    {
                        channelSeries.Points.AddXY(i, values[i]);
                    }

                    VerticalLineAnnotation va = new VerticalLineAnnotation()
                    {
                        LineColor         = colors[c],
                        LineWidth         = 3,
                        AxisX             = chartHisto.ChartAreas[0].AxisX,
                        AxisY             = chartHisto.ChartAreas[0].AxisY,
                        AllowMoving       = true,
                        IsInfinitive      = true,
                        ClipToChartArea   = chartHisto.ChartAreas[0].Name,
                        AllowAnchorMoving = false,
                    };

                    this.chartHisto.Annotations.Add(va);
                    this.chartHisto.Series.Add(channelSeries);
                }
            }
        }
        private void CreateFiringAnnotation(double xAnchor, bool isStart)
        {
            var firingAnnotation = new VerticalLineAnnotation
            {
                AxisX        = MainChart.ChartAreas[0].AxisX,
                AxisY        = MainChart.ChartAreas[0].AxisY,
                AnchorX      = xAnchor,
                LineColor    = isStart ? Color.CornflowerBlue : Color.CadetBlue,
                LineWidth    = 1,
                IsInfinitive = true
            };

            MainChart.Annotations.Add(firingAnnotation);
            firingAnnotation.ClipToChartArea = MainChart.ChartAreas[0].Name;
        }
Esempio n. 13
0
        private void InitialSelectLine()
        {
            _chartLine                 = new VerticalLineAnnotation();
            _chartLine.AxisX           = _chartArea.AxisX;
            _chartLine.AllowMoving     = true;
            _chartLine.IsInfinitive    = true;
            _chartLine.ClipToChartArea = _chartArea.Name;
            //_chartLine.Name = "Select";
            _chartLine.LineColor = Color.Red;
            _chartLine.LineWidth = 3;
            _chartLine.X         = _range.Min;

            ResultValue = _range.Min;

            _chart.Annotations.Add(_chartLine);
        }
Esempio n. 14
0
 public static bool AddCustomSnapshot(Chart TimeLineChart, CursorEventArgs Event)
 {
     if (TimeLineChart.Series[FTimeLineChartView.AllocatedMemory].Points.Count == 0)
     {
         return(false);
     }
     else
     {
         VerticalLineAnnotation A = new VerticalLineAnnotation();
         A.AxisX        = Event.Axis;
         A.AnchorX      = ( int )Event.NewSelectionStart + 1;
         A.ToolTip      = "Snapshot";
         A.IsInfinitive = true;
         TimeLineChart.Annotations.Add(A);
         return(true);
     }
 }
Esempio n. 15
0
        /// <summary>
        /// Add a vertical line to our chart
        /// </summary>
        /// <param name="Chart"></param>
        /// <param name="Value"></param>
        /// <param name="Title"></param>
        /// <param name="TargetColor"></param>
        /// <param name="Width"></param>
        private void AddVerticalLine(Chart Chart, float Value, String Title, Color TargetColor, float Width = 1f)
        {
            if (float.IsNaN(Value))
            {
                return;
            }

            VerticalLineAnnotation vla = new VerticalLineAnnotation();

            vla.ClipToChartArea = Chart.ChartAreas[0].Name;
            vla.AxisX           = Chart.ChartAreas[0].AxisX;
            vla.LineColor       = TargetColor;
            vla.LineWidth       = (int)Width;
            vla.IsInfinitive    = true;
            vla.AxisY           = Chart.ChartAreas[0].AxisY;
            vla.X = Value;
            Chart.Annotations.Add(vla);
        }
        private void AddAnnotation()
        {
            var label = new MyAnnotationLabel()
            {
                LabelPlacement = LabelPlacement.Auto
            };

            var annotation = new VerticalLineAnnotation()
            {
                Stroke          = new SolidColorBrush(Colors.Orange),
                StrokeThickness = 1,
                X1               = DateTime.Now.AddSeconds(100),
                IsEditable       = true,
                XAxisId          = "XAxis",
                YAxisId          = "YAxis",
                AnnotationLabels = { label },
            };

            sliceModifier.VerticalLines.Add(annotation);
        }
Esempio n. 17
0
        private void OnCreateSliceClick(object sender, RoutedEventArgs e)
        {
            MouseButtonEventHandler mouseClick = null;

            mouseClick = (s, arg) =>
            {
                this.MouseLeftButtonUp -= mouseClick;
                var mousePoint = arg.GetPosition((UIElement)this.sciChart.GridLinesPanel).X;

                var slice = new VerticalLineAnnotation()
                {
                    X1    = this.sciChart.XAxis.GetDataValue(mousePoint),
                    Style = (Style)Resources["sliceStyle"]
                };

                sliceModifier.VerticalLines.Add(slice);
            };

            this.MouseLeftButtonUp += mouseClick;
        }
Esempio n. 18
0
        protected void chartSTOCH_Click(object sender, ImageMapEventArgs e)
        {
            int      chartIndex = System.Convert.ToInt32(e.PostBackValue.Split(',')[0]);
            DateTime xDate      = System.Convert.ToDateTime(e.PostBackValue.Split(',')[1]);
            double   lineWidth  = xDate.ToOADate();

            double lineHeight = System.Convert.ToDouble(e.PostBackValue.Split(',')[2]);

            //double lineHeight = -35;

            if (chartSTOCH.Annotations.Count > 0)
            {
                chartSTOCH.Annotations.Clear();
            }

            HorizontalLineAnnotation HA = new HorizontalLineAnnotation();

            HA.AxisX = chartSTOCH.ChartAreas[chartIndex].AxisX;
            HA.AxisY = chartSTOCH.ChartAreas[chartIndex].AxisY;
            HA.IsSizeAlwaysRelative = false;
            HA.AnchorY         = lineHeight;
            HA.IsInfinitive    = true;
            HA.ClipToChartArea = chartSTOCH.ChartAreas[chartIndex].Name;
            HA.LineDashStyle   = ChartDashStyle.Dash;
            HA.LineColor       = Color.Red;
            HA.LineWidth       = 1;
            chartSTOCH.Annotations.Add(HA);

            VerticalLineAnnotation VA = new VerticalLineAnnotation();

            VA.AxisX = chartSTOCH.ChartAreas[chartIndex].AxisX;
            VA.AxisY = chartSTOCH.ChartAreas[chartIndex].AxisY;
            VA.IsSizeAlwaysRelative = false;
            VA.AnchorX         = lineWidth;
            VA.IsInfinitive    = true;
            VA.ClipToChartArea = chartSTOCH.ChartAreas[chartIndex].Name;
            VA.LineDashStyle   = ChartDashStyle.Dash;
            VA.LineColor       = Color.Red;
            VA.LineWidth       = 1;
            chartSTOCH.Annotations.Add(VA);
        }
Esempio n. 19
0
        protected void drawLine2(string e)
        {
            DateTime xDate     = System.Convert.ToDateTime(e.Split(',')[0]);
            double   lineWidth = xDate.ToOADate();

            double lineHeight = System.Convert.ToDouble(e.Split(',')[1]);

            //double lineHeight = -35;

            if (chartBollingerBands.Annotations.Count > 0)
            {
                chartBollingerBands.Annotations.Clear();
            }

            HorizontalLineAnnotation HA = new HorizontalLineAnnotation();

            HA.AxisX = chartBollingerBands.ChartAreas[0].AxisX;
            HA.AxisY = chartBollingerBands.ChartAreas[0].AxisY;
            HA.IsSizeAlwaysRelative = false;
            HA.AnchorY         = lineHeight;
            HA.IsInfinitive    = true;
            HA.ClipToChartArea = chartBollingerBands.ChartAreas[0].Name;
            HA.LineDashStyle   = ChartDashStyle.Dash;
            HA.LineColor       = Color.Red;
            HA.LineWidth       = 1;
            chartBollingerBands.Annotations.Add(HA);

            VerticalLineAnnotation VA = new VerticalLineAnnotation();

            VA.AxisX = chartBollingerBands.ChartAreas[0].AxisX;
            VA.AxisY = chartBollingerBands.ChartAreas[0].AxisY;
            VA.IsSizeAlwaysRelative = false;
            VA.AnchorX         = lineWidth;
            VA.IsInfinitive    = true;
            VA.ClipToChartArea = chartBollingerBands.ChartAreas[0].Name;
            VA.LineDashStyle   = ChartDashStyle.Dash;
            VA.LineColor       = Color.Red;
            VA.LineWidth       = 1;
            chartBollingerBands.Annotations.Add(VA);
        }
Esempio n. 20
0
        /// <summary>
        /// Отрисовка атрибутов сегментов в исходном сигнале
        /// </summary>
        /// <param name="bounds"></param>
        /// <param name="chartSignal"></param>
        private void DrawSegmentsAttributes(Dictionary <string, SignalUtilities.SegmentBounds> bounds, Chart chartSignal)
        {
            ChartArea CA = chartQstSignal.ChartAreas[0];

            chartSignal.Annotations.Clear();

            foreach (var bound in bounds)
            {
                var va = new VerticalLineAnnotation
                {
                    AxisX           = CA.AxisX,
                    AllowMoving     = false,
                    IsInfinitive    = true,
                    ClipToChartArea = CA.Name,
                    Name            = $"line{bound.Key}",
                    LineColor       = Color.Aqua,
                    LineWidth       = 1,
                    X = bound.Value.boundIndexMax,
                };
                var ra = new RectangleAnnotation
                {
                    AxisX = CA.AxisX,
                    AxisY = CA.AxisY,
                    IsSizeAlwaysRelative = false,
                    Width     = 200,
                    Height    = 1,
                    Name      = $"label{bound.Key}",
                    LineColor = Color.Black,
                    BackColor = Color.PowderBlue,
                    Y         = CA.AxisY.Minimum + CA.AxisY.LabelStyle.Interval / 2,
                    X         = va.X - 200,
                    Text      = bound.Key,
                    ForeColor = Color.Black,
                    Font      = new Font("Arial", 8f)
                };

                chartSignal.Annotations.Add(va);
                chartSignal.Annotations.Add(ra);
            }
        }
Esempio n. 21
0
        private void InitializeHistogramChart()
        {
            // Add new series
            m_HistogramSeries = m_AnglesChart.Series.Add(c_HistogramSeriesName);

            // Set new series chart type and other attributes
            m_HistogramSeries.ChartType        = SeriesChartType.Column;
            m_HistogramSeries.BorderColor      = Color.Black;
            m_HistogramSeries.BorderWidth      = 1;
            m_HistogramSeries.BorderDashStyle  = ChartDashStyle.Solid;
            m_HistogramSeries["PointWidth"]    = "1.0";
            m_HistogramSeries["BarLabelStyle"] = "Center";

            // This series is solely used for anchoring the annotation that indicates the current heading change
            m_CurrentHeadingChangeSeries            = m_AnglesChart.Series.Add(c_CurrentHeadingChangeSeriesName);
            m_CurrentHeadingChangeSeries.ChartType  = SeriesChartType.Point;
            m_CurrentHeadingChangeSeries.ChartArea  = m_HistogramSeries.ChartArea;
            m_CurrentHeadingChangeSeries.MarkerSize = 0;

            // Adjust chart area
            ChartArea chartArea = m_AnglesChart.ChartAreas[m_HistogramSeries.ChartArea];

            chartArea.AxisY.Title   = "Frequency";
            chartArea.AxisX.Minimum = m_Histogram.Min;
            chartArea.AxisX.Maximum = m_Histogram.Max;

            chartArea.AxisX.Interval               = 0.5;
            chartArea.AxisX.MajorGrid.Interval     = 0.5;
            chartArea.AxisX.MajorTickMark.Interval = 0.1;

            m_CurrentHeadingChangeAnnotation = new VerticalLineAnnotation();

            m_CurrentHeadingChangeAnnotation.Height    = -100;
            m_CurrentHeadingChangeAnnotation.LineWidth = 2;
            m_CurrentHeadingChangeAnnotation.LineColor = Color.Red;

            m_AnglesChart.Annotations.Add(m_CurrentHeadingChangeAnnotation);
        }
Esempio n. 22
0
        private void linkLabel8_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
        {
            VerticalLineAnnotation l = new VerticalLineAnnotation();

            l.AxisX = chart1.ChartAreas["Default"].AxisX;
            ArrayList data = GetData.RunQuery("show grp_len;");
            ItemState row  = (ItemState)data[1];

            string[] rd;
            rd = row.data;
            int interval = int.Parse(row.data[0]);

            if (interval == 0)
            {
                interval = 1;
            }
            l.AnchorX         = 162144 / interval;// int.Parse(data[1]);
            limit             = (int)l.AnchorX;
            l.IsInfinitive    = true;
            l.ClipToChartArea = chart1.ChartAreas["Default"].Name;
            l.LineColor       = Color.Blue;
            chart1.Annotations.Add(l);
        }
Esempio n. 23
0
        private void UpdateFaults()
        {
            _faults.Clear();
            _annotations.Clear();

            foreach (var trendViewModel in _trends)
            {
                foreach (var faultViewModel in trendViewModel.Faults)
                {
                    if (!_faults.Contains(faultViewModel))
                    {
                        _faults.Add(faultViewModel);

                        var line = new VerticalLineAnnotation()
                        {
                            X1         = faultViewModel.AccuredAt,
                            LabelValue = faultViewModel.Name
                        };
                        Annotations.Add(line);
                    }
                }
            }
        }
Esempio n. 24
0
        /// <summary>
        /// Constructor
        /// </summary>
        /// <param name="graph_visualizer"></param>
        public Train(GraphVisualizer graph_visualizer)
            : base(graph_visualizer)
        {
            Position             = new DataPoint();
            Position.XValue      = 0;
            hidden_point         = new DataPoint(0, 0);
            hidden_point.IsEmpty = true;

            TopLeft     = new DataPoint();
            BottomLeft  = new DataPoint();
            BottomRight = new DataPoint();
            TopRight    = new DataPoint();

            under_reading_amount = 0;
            over_reading_amount  = 0;
            SpeedLowerBound      = 0.08;
            SpeedUpperBound      = 0.08;

            TrainAnnotation = new ImageAnnotation();
            TrainAnnotation.AnchorDataPoint = Position;
            TrainAnnotation.AnchorOffsetY   = -4;
            TrainAnnotation.Image           = "TrainMoving";

            TrainLineAnnotation                      = new VerticalLineAnnotation();
            TrainLineAnnotation.AxisX                = GraphVisualizer.AxisX;
            TrainLineAnnotation.AxisY                = GraphVisualizer.AxisY;
            TrainLineAnnotation.LineColor            = Color.LightGray;
            TrainLineAnnotation.LineDashStyle        = ChartDashStyle.Dash;
            TrainLineAnnotation.LineWidth            = 2;
            TrainLineAnnotation.IsSizeAlwaysRelative = false;

            UpdateToolTip();

            InitializeProperties(SeriesChartType.Line, "Train position and accuracy",
                                 "Represents the position of the train and the odometry accuracy", Color.Red);
        }
Esempio n. 25
0
        public void drawLine(string eventargs)
        {
            string[] sargs = eventargs.Split(',');

            double lineWidthClient = System.Convert.ToDouble(sargs[0]);

            double lineHeightClient = System.Convert.ToDouble(sargs[1]);
            double lineWidthScreen  = System.Convert.ToDouble(sargs[2]);

            double lineHeightScreen = System.Convert.ToDouble(sargs[3]);

            //double lineHeight = -35;

            if (chartBollingerBands.Annotations.Count > 0)
            {
                chartBollingerBands.Annotations.Clear();
            }

            HorizontalLineAnnotation HA = new HorizontalLineAnnotation();

            HA.AxisX = chartBollingerBands.ChartAreas[0].AxisX;
            HA.AxisY = chartBollingerBands.ChartAreas[0].AxisY;
            HA.IsSizeAlwaysRelative = false;
            HA.AnchorY         = lineHeightClient;
            HA.IsInfinitive    = true;
            HA.ClipToChartArea = chartBollingerBands.ChartAreas[0].Name;
            HA.LineDashStyle   = ChartDashStyle.Dash;
            HA.LineColor       = Color.Red;
            HA.LineWidth       = 1;
            chartBollingerBands.Annotations.Add(HA);

            VerticalLineAnnotation VA = new VerticalLineAnnotation();

            VA.AxisX = chartBollingerBands.ChartAreas[0].AxisX;
            VA.AxisY = chartBollingerBands.ChartAreas[0].AxisY;
            VA.IsSizeAlwaysRelative = false;
            VA.AnchorX         = lineWidthClient;
            VA.IsInfinitive    = true;
            VA.ClipToChartArea = chartBollingerBands.ChartAreas[0].Name;
            VA.LineDashStyle   = ChartDashStyle.Dash;
            VA.LineColor       = Color.Red;
            VA.LineWidth       = 1;
            chartBollingerBands.Annotations.Add(VA);

            HorizontalLineAnnotation HA2 = new HorizontalLineAnnotation();

            HA2.AxisX = chartBollingerBands.ChartAreas[0].AxisX;
            HA2.AxisY = chartBollingerBands.ChartAreas[0].AxisY;
            HA2.IsSizeAlwaysRelative = false;
            HA2.AnchorY         = lineHeightScreen;
            HA2.IsInfinitive    = true;
            HA2.ClipToChartArea = chartBollingerBands.ChartAreas[0].Name;
            HA2.LineDashStyle   = ChartDashStyle.Dash;
            HA2.LineColor       = Color.Blue;
            HA2.LineWidth       = 1;
            chartBollingerBands.Annotations.Add(HA2);

            VerticalLineAnnotation VA2 = new VerticalLineAnnotation();

            VA2.AxisX = chartBollingerBands.ChartAreas[0].AxisX;
            VA2.AxisY = chartBollingerBands.ChartAreas[0].AxisY;
            VA2.IsSizeAlwaysRelative = false;
            VA2.AnchorX         = lineWidthScreen;
            VA2.IsInfinitive    = true;
            VA2.ClipToChartArea = chartBollingerBands.ChartAreas[0].Name;
            VA2.LineDashStyle   = ChartDashStyle.Dash;
            VA2.LineColor       = Color.Blue;
            VA2.LineWidth       = 1;
            chartBollingerBands.Annotations.Add(VA2);
        }
        /// <summary>
        /// Displays the history variation for the current statistics.
        /// </summary>
        /// <param name="history">The views history.</param>
        /// <param name="axisX">The X axis.</param>
        /// <param name="axisY">The Y axis.</param>
        private void DisplayHistoryVariation(AjaxViewsHistory history, string axisX, string axisY)
        {
            if (null == history) return;

            this.chart.Series.Clear();
            this.chart.Annotations.Clear();
            this.listViewDiscovery.Items.Clear();

            // Update the chart.
            Series series = new Series("Video {0}".FormatWith(this.textBox));
            series.ChartType = SeriesChartType.Line;
            series.XValueType = ChartValueType.DateTime;
            series.YValueType = ChartValueType.Int32;
            series.Font = new Font(this.Font.FontFamily, this.Font.Size, this.Font.Style);
            series.MarkerStyle = MarkerStyle.Circle;

            DateTime[] time = new DateTime[history.Series.Length - 1];
            double[] popularity = new double[history.Series.Length - 1];
            for (int index = 1; index < history.Series.Length; index++)
            {
                TimeSpan dx = history.Series[index].Time - history.Series[index - 1].Time;
                time[index - 1] = new DateTime((history.Series[index].Time.Ticks + history.Series[index - 1].Time.Ticks) / 2);
                double dy = history.Series[index].Value - history.Series[index - 1].Value;
                popularity[index - 1] = dy / dx.TotalDays;

                series.Points.AddXY(time[index - 1], popularity[index - 1]);
            }

            this.chart.Series.Add(series);
            this.chart.ChartAreas[0].AxisX.Title = axisX;
            this.chart.ChartAreas[0].AxisY.Title = axisY;

            AjaxHistoryMarker? lastMarker = null;
            RectangleAnnotation lastAnnotation = null;

            // For all markers.
            foreach (AjaxHistoryMarker marker in history.Markers)
            {
                // Get the history point closest to the marker.
                AjaxHistoryPoint? point = history.GetPointAt(marker);

                // If the point does not exist, continue.
                if (null == point) continue;

                // Get index of the point.
                int index = Array.IndexOf<AjaxHistoryPoint>(history.Series, point.Value);

                // If the index is not found, skip the point.
                if (-1 == index) continue;

                // If the index is greater than the number of popularity points, limit the index to the size of the popularity array.
                if (index >= popularity.Length) index = popularity.Length - 1;

                // If the last marker and last annotation exist.
                if ((lastMarker != null) && (lastAnnotation != null))
                {
                    // If the last marker has the same date with the current one, only update the annotation text.
                    if (lastMarker.Value.Time == marker.Time)
                    {
                        lastAnnotation.Text += " " + marker.Name;
                        continue;
                    }
                }

                RectangleAnnotation rect = new RectangleAnnotation();
                rect.Text = marker.Name;
                rect.ForeColor = Color.Black;
                rect.AxisX = this.chart.ChartAreas[0].AxisX;
                rect.AxisY = this.chart.ChartAreas[0].AxisY;
                rect.AnchorX = time[index].ToOADate();
                rect.AnchorY = popularity[index];
                rect.AnchorOffsetX = 0;
                rect.AnchorOffsetY = 5;
                rect.ShadowColor = Color.Gray;
                rect.ShadowOffset = 5;

                VerticalLineAnnotation line = new VerticalLineAnnotation();
                line.AxisX = this.chart.ChartAreas[0].AxisX;
                line.AxisY = this.chart.ChartAreas[0].AxisY;
                line.AnchorX = time[index].ToOADate();
                line.AnchorY = popularity[index];
                line.Height = -5;

                this.chart.Annotations.Add(line);
                this.chart.Annotations.Add(rect);
                this.chart.ResetAutoValues();

                lastAnnotation = rect;
                lastMarker = marker;
            }

            // Add discovery events.
            foreach (KeyValuePair<string, AjaxViewsHistoryDiscoveryEvent> evt in history.DiscoveryEvents)
            {
                ListViewItem item = new ListViewItem(new string[] {
                        evt.Value.Name,
                        evt.Value.Marker != null ? evt.Value.Marker.Value.Time.ToString() : "Unknown",
                        AjaxViewsHistoryDiscoveryEvent.GetTypeDescription(evt.Value.Type),
                        evt.Value.Extra != null ? evt.Value.Extra : string.Empty }, 0);
                item.Tag = evt.Value;

                this.listViewDiscovery.Items.Add(item);
            }
        }
        private void CompileForm()
        {
            if (!GuideLogFilePath.Text.Contains(".log"))
            {
                MessageBox.Show("File not a log file");
                return;
            }

            PrepGraphs();

            //Acquire header object (XML)
            LogHeaderXML xH = new LogHeaderXML(GuideLogFilePath.Text);

            //Fill in basic information
            BuildBox.Text      = xH.Detail(xH.TheSkyXBuild);
            MountBox.Text      = xH.Detail(xH.Mount);
            CameraBox.Text     = xH.Detail(xH.Camera);
            DateBox.Text       = (xH.Detail(xH.LocalStartDateTime)).Split(' ')[0];
            TimeBox.Text       = (xH.Detail(xH.LocalStartDateTime)).Split(' ')[1];
            ExposureBox.Text   = (xH.Detail(xH.ExposureTime));
            BinningBox.Text    = (xH.Detail(xH.BinX) + " x " + xH.Detail(xH.BinY));
            CalDecBox.Text     = (xH.Detail(xH.Calibrationdeclination));
            CurrentDecBox.Text = (xH.Detail(xH.Declinationnow));
            CalPABox.Text      = (xH.Detail(xH.Calibrationpositionangle));
            CurrentPABox.Text  = (xH.Detail(xH.Positionanglenow));

            AxisControlBox.Text = xH.Detail(xH.XPlusAxis) +
                                  " / " +
                                  xH.Detail(xH.XMinusAxis) +
                                  " / " +
                                  xH.Detail(xH.YPlusAxis) +
                                  " / " +
                                  xH.Detail(xH.YMinusAxis);
            AxisControlBox.Text    = AxisControlBox.Text.Replace("Not Enabled", "Off");
            AxisControlBox.Text    = AxisControlBox.Text.Replace("Enabled", "On");
            MountControlGroup.Text = xH.Detail(xH.Autoguide);
            AggressivenessBox.Text = xH.Detail(xH.AggressivenessFactorXPlus) +
                                     " / " +
                                     xH.Detail(xH.AggressivenessFactorXMinus) +
                                     " / " +
                                     xH.Detail(xH.AggressivenessFactorYPlus) +
                                     " / " +
                                     xH.Detail(xH.AggressivenessFactorYMinus);
            MoveBox.Text = xH.Detail(xH.MinimumMove) + " (sec) / " + xH.Detail(xH.MaximumMove) + " (sec)";

            //if (Convert.ToInt16(xH.Detail("BinX") != 0) int binY = Convert.ToInt16(xH.Detail("BinY"));
            // int binX = if (Convert.ToInt16(xH.Detail("BinX"));
            //int binY = Convert.ToInt16(xH.Detail("BinY"));
            int binX = Convert.ToInt16(xH.Detail("BinX"));
            int binY = Convert.ToInt16(xH.Detail("BinY"));

            double scaleX; // = 1.0 / (double)binX;
            double scaleY; // = 1.0 / (double)binY;
            double scaleT;

            double xSlope = 0;
            double ySlope = 0;
            double tSlope = 0;

            string scaleXString = xH.Detail("ImageScaleXatbinning" + binX.ToString("0"));
            string scaleYString = xH.Detail("ImageScaleYatbinning" + binY.ToString("0"));

            if (scaleXString.Contains("NA"))
            {
                scaleX = enteredImageScale;
            }
            else
            {
                scaleX = Convert.ToDouble(scaleXString);
            }
            if (scaleYString.Contains("NA"))
            {
                scaleY = enteredImageScale;
            }
            else
            {
                scaleY = Convert.ToDouble(scaleYString);
            }

            scaleT = Math.Sqrt(Math.Pow(scaleX, 2) + Math.Pow(scaleY, 2));
            //double scaleT = scaleX;
            ImageScaleBox.Text = scaleXString + " / " + scaleYString;

            AOAggressivenessBox.Text = xH.Detail(xH.AOAggressiveness);
            AORelayBumpSizeBox.Text  = xH.Detail(xH.AORelayBumpSize);
            AORelayThresholdBox.Text = xH.Detail(xH.AORelayThreshold);
            AOSlewRateBox.Text       = xH.Detail(xH.AOSlewRate);
            AOTrackSizeBox.Text      = xH.Detail(xH.AOTrackBoxSize);

            //Acquire data from log
            LogReader guideLog = new LogReader(GuideLogFilePath.Text);
            //Make a complex vector of guideLog data
            int vLen = guideLog.GetLogSize() - 1;

            Complex[] errorValsTcplx   = new Complex[vLen];
            Complex[] errorValsXcplx   = new Complex[vLen];
            Complex[] errorValsYcplx   = new Complex[vLen];
            double[]  errorValsTdbl    = new double[vLen];
            double[]  errorValsXdbl    = new double[vLen];
            double[]  errorValsYdbl    = new double[vLen];
            Double[]  correctionXPlus  = new double[vLen];
            Double[]  correctionXMinus = new double[vLen];
            Double[]  correctionYPlus  = new double[vLen];
            Double[]  correctionYMinus = new double[vLen];
            double[]  wormIndexRA      = new double[vLen];
            double[]  wormIndexDec     = new double[vLen];
            double[]  guideStarSignal  = new double[vLen];

            double FFTTimeIncrement = 0; //time per sample in sec
            double nowTime          = 0;

            //time domain plot of log data, total, X and Y, mean, and guidestarsignal
            for (int i = 0; i < vLen; i++)
            {
                errorValsTdbl[i] = guideLog.GetLogValue(i, LogReader.LogVal.TotGuideErr) * scaleT;
                errorValsXdbl[i] = guideLog.GetLogValue(i, LogReader.LogVal.GuideErrX) * scaleX;
                errorValsYdbl[i] = guideLog.GetLogValue(i, LogReader.LogVal.GuideErrY) * scaleY;

                correctionXPlus[i]  = guideLog.GetLogValue(i, LogReader.LogVal.XPlusRelay);
                correctionXMinus[i] = guideLog.GetLogValue(i, LogReader.LogVal.XMinusRelay);
                correctionYPlus[i]  = guideLog.GetLogValue(i, LogReader.LogVal.XPlusRelay);
                correctionYMinus[i] = guideLog.GetLogValue(i, LogReader.LogVal.YMinusRelay);
                wormIndexRA[i]      = guideLog.GetLogValue(i, LogReader.LogVal.PECIndexRA);
                wormIndexDec[i]     = guideLog.GetLogValue(i, LogReader.LogVal.PECIndexDec);
                guideStarSignal[i]  = guideLog.GetLogValue(i, LogReader.LogVal.GuideStarSignal);
            }

            if (RemoveDriftCheckBox.Checked)
            {
                tSlope = Analysis.RemoveOffsetAndSlope(ref errorValsTdbl, false);
                xSlope = Analysis.RemoveOffsetAndSlope(ref errorValsXdbl, false);
                ySlope = Analysis.RemoveOffsetAndSlope(ref errorValsYdbl, false);
            }
            else
            {
                tSlope = Analysis.RemoveOffsetAndSlope(ref errorValsTdbl, true); //Slope only
                xSlope = Analysis.RemoveOffsetAndSlope(ref errorValsXdbl, true); //Slope only
                ySlope = Analysis.RemoveOffsetAndSlope(ref errorValsYdbl, true); //Slope only
            }

            for (int i = 0; i < vLen; i++)
            {
                errorValsTcplx[i] = new Complex(errorValsTdbl[i], 0);
                errorValsXcplx[i] = new Complex(errorValsXdbl[i], 0);
                errorValsYcplx[i] = new Complex(errorValsYdbl[i], 0);
            }


            for (int i = 0; i < vLen; i++)
            {
                nowTime = guideLog.GetLogValue(i, LogReader.LogVal.ElapsedSecs);
                if (i < (vLen - 1))
                {
                    FFTTimeIncrement += guideLog.GetLogValue(i + 1, LogReader.LogVal.ElapsedSecs) - nowTime;
                }
                tGraphT.Points.AddXY((nowTime / 60), errorValsTcplx[i].Real);
                tGraphX.Points.AddXY((nowTime / 60), errorValsXcplx[i].Real);
                tGraphY.Points.AddXY((nowTime / 60), errorValsYcplx[i].Real);
            }
            tGraphT.Color = Color.Red;
            tGraphX.Color = Color.Blue;
            tGraphY.Color = Color.Green;

            Show();
            //Determine if wormIndex data is present and post results
            double pesum = 0;

            for (int i = 0; i < vLen; i++)
            {
                pesum += (wormIndexDec[i] + wormIndexRA[i]);
            }
            if (pesum == 0)
            {
                PEIndexTextBox.Text = "No";
            }
            else
            {
                PEIndexTextBox.Text = "Yes";
            }

            //frequency domain plot of log data, long period and short period
            FourierTransform.DFT(errorValsTcplx, FourierTransform.Direction.Forward);
            FourierTransform.DFT(errorValsXcplx, FourierTransform.Direction.Forward);
            FourierTransform.DFT(errorValsYcplx, FourierTransform.Direction.Forward);
            //
            int FFTLen = errorValsTcplx.Length;

            FFTTimeIncrement /= (vLen - 1);
            double FFTSampleRate = 1 / FFTTimeIncrement; //frequency increment per sample in cycles/sec

            SampleRateBox.Text = FFTTimeIncrement.ToString("00.00") + " (sec) / " + FFTSampleRate.ToString("0.00") + " (cps)";
            double FFTmagT   = 0;
            double FFTmagX   = 0;
            double FFTmagY   = 0;
            double FFTperiod = 0;
            //double maxFreq = FFTFreqIncrement * (FFTLen / 2);
            int    maxLongPeriod  = 6;  //minutes
            double maxShortPeriod = .5; //minutes

            double[,] errorFreq = new double[FFTLen / 2, 3];

            for (int i = 1; i < (FFTLen / 2); i++)
            {
                //fGraph.Points.Add(XPlusVals[i].Real);
                //FFTmagT = Math.Pow(errorValsTcplx[i].Real, 2) + Math.Pow(errorValsTcplx[i].Imaginary, 2);
                //FFTmagX = Math.Pow(errorValsXcplx[i].Real, 2) + Math.Pow(errorValsTcplx[i].Imaginary, 2);
                //FFTmagY = Math.Pow(errorValsYcplx[i].Real, 2) + Math.Pow(errorValsTcplx[i].Imaginary, 2);

                FFTmagT = errorValsTcplx[i].Magnitude;
                FFTmagX = errorValsXcplx[i].Magnitude;
                FFTmagY = errorValsYcplx[i].Magnitude;

                errorFreq[i, 0] = FFTmagT;
                errorFreq[i, 1] = FFTmagX;
                errorFreq[i, 2] = FFTmagY;

                FFTperiod = FFTLen / (i * FFTSampleRate * 60);
                if (FFTperiod <= maxLongPeriod)
                {
                    fGraphT.Points.AddXY(FFTperiod, FFTmagT);
                    fGraphX.Points.AddXY(FFTperiod, FFTmagX);
                    fGraphY.Points.AddXY(FFTperiod, FFTmagY);
                    fGraphT.Color = Color.Red;
                    fGraphX.Color = Color.Blue;
                    fGraphY.Color = Color.Green;
                }
                if (FFTperiod <= maxShortPeriod)
                {
                    mGraphT.Points.AddXY((FFTperiod * 60), FFTmagT);
                    mGraphX.Points.AddXY((FFTperiod * 60), FFTmagX);
                    mGraphY.Points.AddXY((FFTperiod * 60), FFTmagY);
                    mGraphT.Color = Color.Red;
                    mGraphX.Color = Color.Blue;
                    mGraphY.Color = Color.Green;
                }
            }
            //Calibration Plot
            double xpAngle = guideLog.GetMountVelocityVector(LogReader.Calibration.XPlus, LogReader.Vector.Angle);
            double xmAngle = guideLog.GetMountVelocityVector(LogReader.Calibration.XMinus, LogReader.Vector.Angle);
            double ypAngle = guideLog.GetMountVelocityVector(LogReader.Calibration.YPlus, LogReader.Vector.Angle);
            double ymAngle = guideLog.GetMountVelocityVector(LogReader.Calibration.YMinus, LogReader.Vector.Angle);
            double xpSpeed = Math.Abs(guideLog.GetMountVelocityVector(LogReader.Calibration.XPlus, LogReader.Vector.XSpeed));
            double xmSpeed = Math.Abs(guideLog.GetMountVelocityVector(LogReader.Calibration.XMinus, LogReader.Vector.XSpeed));
            double ypSpeed = Math.Abs(guideLog.GetMountVelocityVector(LogReader.Calibration.YPlus, LogReader.Vector.YSpeed));
            double ymSpeed = Math.Abs(guideLog.GetMountVelocityVector(LogReader.Calibration.YMinus, LogReader.Vector.YSpeed));

            cGraphPX.Points.Add(0, 0);
            cGraphPX.Points.AddXY(xpAngle, xpSpeed);
            cGraphPX.Points[cGraphPX.Points.Count - 1].MarkerStyle = MarkerStyle.Cross;
            cGraphPX.Points.Add(0, 0);
            cGraphPX.Points.AddXY(xmAngle, xmSpeed);
            cGraphPX.Points[cGraphPX.Points.Count - 1].MarkerStyle = MarkerStyle.Circle;
            cGraphPY.Points.Add(0, 0);
            cGraphPY.Points.AddXY(ypAngle, ypSpeed);
            cGraphPY.Points[cGraphPY.Points.Count - 1].MarkerStyle = MarkerStyle.Cross;
            cGraphPY.Points.Add(0, 0);
            cGraphPY.Points.AddXY(ymAngle, ymSpeed);
            cGraphPY.Points[cGraphPY.Points.Count - 1].MarkerStyle = MarkerStyle.Circle;

            foreach (System.Windows.Forms.DataVisualization.Charting.DataPoint point in cGraphPX.Points)
            {
                if ((double)point.YValues.GetValue(0) == 0)
                {
                    point.IsValueShownAsLabel = false;
                    point.MarkerStyle         = MarkerStyle.None;
                }
                else
                {
                    point.IsValueShownAsLabel = true;
                }
            }

            foreach (System.Windows.Forms.DataVisualization.Charting.DataPoint point in cGraphPY.Points)
            {
                if ((double)point.YValues.GetValue(0) == 0)
                {
                    point.IsValueShownAsLabel = false;
                    point.MarkerStyle         = MarkerStyle.None;
                }
                else
                {
                    point.IsValueShownAsLabel = true;
                }
            }
            //Add vertical lines for Paramount
            ChartArea CA      = chart2.ChartAreas[0];
            double    hPeriod = 0;

            if (MountBox.Text.Contains("MX"))
            {
                hPeriod = 229.77;
            }
            else if (MountBox.Text.Contains("MYT"))
            {
                hPeriod = 269.26;
            }
            else if (MountBox.Text.Contains("ME"))
            {
                hPeriod = 149.99;
            }

            if (hPeriod != 0)
            {
                chart2.Annotations.Clear();

                double harmonic0 = hPeriod / 60;
                double harmonic1 = harmonic0 / 2;
                double harmonic2 = harmonic0 / 3;
                double harmonic3 = harmonic0 / 4;
                double harmonic4 = harmonic0 / 5;
                double harmonic5 = harmonic0 / 6;
                double harmonic6 = harmonic0 / 7;
                double harmonic7 = harmonic0 / 8;


                VerticalLineAnnotation VA0 = new VerticalLineAnnotation
                {
                    AxisX           = CA.AxisX,
                    AllowMoving     = false,
                    IsInfinitive    = true,
                    ClipToChartArea = CA.Name,
                    Name            = "myLine0",
                    LineColor       = Color.DarkOrange,
                    LineWidth       = 2,
                    X = harmonic0
                };
                VerticalLineAnnotation VA1 = new VerticalLineAnnotation
                {
                    AxisX           = CA.AxisX,
                    AllowMoving     = false,
                    IsInfinitive    = true,
                    ClipToChartArea = CA.Name,
                    Name            = "myLine1",
                    LineColor       = Color.DarkOrange,
                    LineWidth       = 2,
                    X = harmonic1
                };
                VerticalLineAnnotation VA2 = new VerticalLineAnnotation
                {
                    AxisX           = CA.AxisX,
                    AllowMoving     = false,
                    IsInfinitive    = true,
                    ClipToChartArea = CA.Name,
                    Name            = "myLine2",
                    LineColor       = Color.DarkOrange,
                    LineWidth       = 2,
                    X = harmonic2
                };
                VerticalLineAnnotation VA3 = new VerticalLineAnnotation
                {
                    AxisX           = CA.AxisX,
                    AllowMoving     = false,
                    IsInfinitive    = true,
                    ClipToChartArea = CA.Name,
                    Name            = "myLine3",
                    LineColor       = Color.DarkOrange,
                    LineWidth       = 2,   // use your numbers!
                    X = harmonic3
                };
                VerticalLineAnnotation VA4 = new VerticalLineAnnotation
                {
                    AxisX           = CA.AxisX,
                    AllowMoving     = false,
                    IsInfinitive    = true,
                    ClipToChartArea = CA.Name,
                    Name            = "myLine4",
                    LineColor       = Color.DarkOrange,
                    LineWidth       = 2,   // use your numbers!
                    X = harmonic4
                };
                VerticalLineAnnotation VA5 = new VerticalLineAnnotation
                {
                    AxisX           = CA.AxisX,
                    AllowMoving     = false,
                    IsInfinitive    = true,
                    ClipToChartArea = CA.Name,
                    Name            = "myLine5",
                    LineColor       = Color.DarkOrange,
                    LineWidth       = 2,   // use your numbers!
                    X = harmonic5
                };
                VerticalLineAnnotation VA6 = new VerticalLineAnnotation
                {
                    AxisX           = CA.AxisX,
                    AllowMoving     = false,
                    IsInfinitive    = true,
                    ClipToChartArea = CA.Name,
                    Name            = "myLine6",
                    LineColor       = Color.DarkOrange,
                    LineWidth       = 2,   // use your numbers!
                    X = harmonic6
                };

                VerticalLineAnnotation VA7 = new VerticalLineAnnotation
                {
                    AxisX           = CA.AxisX,
                    AllowMoving     = false,
                    IsInfinitive    = true,
                    ClipToChartArea = CA.Name,
                    Name            = "myLine7",
                    LineColor       = Color.DarkOrange,
                    LineWidth       = 2,   // use your numbers!
                    X = harmonic7
                };

                chart2.Annotations.Add(VA0);
                chart2.Annotations.Add(VA1);
                chart2.Annotations.Add(VA2);
                chart2.Annotations.Add(VA3);
                chart2.Annotations.Add(VA4);
                chart2.Annotations.Add(VA5);
                chart2.Annotations.Add(VA6);
                chart2.Annotations.Add(VA7);
            }

            Show();

            //Determine the percentage of saturated star observations
            double percentSat  = Analysis.PercentSaturated(guideStarSignal);
            double percentLost = Analysis.PercentLost(guideStarSignal);

            SaturatedTextBox.Text = percentSat.ToString("0.0") + "% / " + percentLost.ToString("0.0") + "%";

            //Determine percentage of moves vrs non-moves in X and Y
            double movePointsXPlus  = Analysis.PercentErrorsCorrected(correctionXPlus);
            double movePointsXMinus = Analysis.PercentErrorsCorrected(correctionXMinus);
            double movePointsYPlus  = Analysis.PercentErrorsCorrected(correctionYPlus);
            double movePointsYMinus = Analysis.PercentErrorsCorrected(correctionYMinus);

            CorrectionEachPercentBox.Text = movePointsXPlus.ToString("0") + "% / " +
                                            movePointsXMinus.ToString("0") + "% / " +
                                            movePointsYPlus.ToString("0") + "% / " +
                                            movePointsYMinus.ToString("0") + "%";
            double movePointsX = Analysis.PercentErrorsCorrected(correctionXPlus, correctionXMinus);
            double movePointsY = Analysis.PercentErrorsCorrected(correctionYPlus, correctionYMinus);

            CorrectionXorYPercentBox.Text = movePointsX.ToString("0") + "% / " + movePointsY.ToString("0") + "%";
            double movePoints = Analysis.PercentErrorsCorrected(correctionXPlus, correctionXMinus, correctionYPlus, correctionYMinus);

            CorrectionXandYPercentBox.Text = movePoints.ToString("0") + "%";
            Show();

            double switchBackX = Analysis.PercentSwitchBacks(correctionXPlus, correctionXMinus);
            double switchBackY = Analysis.PercentSwitchBacks(correctionYPlus, correctionYMinus);

            SwitchBackPercentBox.Text = switchBackX.ToString("0") + "% / " + switchBackY.ToString("0") + "%";
            Show();

            double TrackingX = Analysis.PercentTracking(correctionXPlus, correctionXMinus);
            double TrackingY = Analysis.PercentTracking(correctionYPlus, correctionYMinus);

            TrackingPercentBox.Text = TrackingX.ToString("0") + "% / " + TrackingY.ToString("0") + "%";
            Show();

            double overshootX = Analysis.PercentOvershoot(errorValsXdbl);
            double overshootY = Analysis.PercentOvershoot(errorValsYdbl);

            OvershootPercentBox.Text = overshootX.ToString("0") + "% / " + overshootY.ToString("0") + "%";
            Show();

            double[] RMSStats = Analysis.RMSError(errorValsXdbl, errorValsYdbl, errorValsTdbl);
            ErrorRMSBox.Text = RMSStats[0].ToString("0.0") + " / " + RMSStats[1].ToString("0.0") + " / " + RMSStats[2].ToString("0.0");
            Show();

            double[] mdrStats = Analysis.MDRStats(errorValsXcplx, errorValsYcplx, errorValsTcplx, FFTSampleRate);
            //double sigToNoiseAvg = (mdrStats[0] - mdrStats[1]) / mdrStats[1];
            MDRBox.Text = (mdrStats[2] * 100).ToString("0") + " %";

            double[] FreqMedStats = Analysis.FrequencyMedian(errorFreq);
            double   iToF         = FFTSampleRate / FFTLen;

            FrequencyBalanceBox.Text = (1 / (iToF * FreqMedStats[0])).ToString("0") + " sec / " + (1 / (iToF * FreqMedStats[1])).ToString("0") + " sec";

            AvgDriftTextBox.Text = (xSlope * 60.0 / FFTTimeIncrement).ToString("0.0") + " / " + (ySlope * 60.0 / FFTTimeIncrement).ToString("0.0") + " / " + (tSlope * 60.0 / FFTTimeIncrement).ToString("0.0");


            Show();
        }
Esempio n. 28
0
        private void Startbutton_Click(object sender, EventArgs e)
        {
            Spiel sp = new Spiel(_leiterschlangen.ToList());
            var statistik = sp.Spielen((int)anzSimulationennumericUpDown.Value);
            label4.Text = statistik.DurchschnittWürfe.ToString();
            label5.Text = statistik.MinWürfe.ToString();
            label6.Text = statistik.MaxWürfe.ToString();

            chart1.Annotations.Clear();
            //Durschschnitt
            try
            {
                VerticalLineAnnotation va = new VerticalLineAnnotation();
                ChartArea ca = chartSimulation.ChartAreas[0];
                Series s1 = chartSimulation.Series[0];
                va.AxisX = ca.AxisX;
                //va.AllowMoving = true;
                va.IsInfinitive = true;
                va.ClipToChartArea = ca.Name;
                va.Name = "Sim Durchschnitt";
                va.LineColor = Color.Red;
                va.LineWidth = 2;
                va.X = (int)statistik.DurchschnittWürfe;
                chartSimulation.Annotations.Add(va);

                ErgebnisMatrixdgv.Rows[(int)statistik.DurchschnittWürfe - 1].DefaultCellStyle.BackColor = Color.Red;
            }
            catch (Exception ex)
            {

            }
            //Minimum
            try
            {
                VerticalLineAnnotation va = new VerticalLineAnnotation();
                ChartArea ca = chartSimulation.ChartAreas[0];
                Series s1 = chartSimulation.Series[0];
                va.AxisX = ca.AxisX;
                //va.AllowMoving = true;
                va.IsInfinitive = true;
                va.ClipToChartArea = ca.Name;
                va.Name = "Sim Minimum";
                va.LineColor = Color.Blue;
                va.LineWidth = 2;
                va.X = (int)statistik.MinWürfe;
                chartSimulation.Annotations.Add(va);
                ErgebnisMatrixdgv.Rows[(int)statistik.MinWürfe - 1].DefaultCellStyle.BackColor = Color.DeepSkyBlue;
            }
            catch (Exception)
            {

            }
            //Maximum
            try
            {
                VerticalLineAnnotation va = new VerticalLineAnnotation();
                ChartArea ca = chartSimulation.ChartAreas[0];
                Series s1 = chartSimulation.Series[0];
                va.AxisX = ca.AxisX;
                //va.AllowMoving = true;
                va.IsInfinitive = true;
                va.ClipToChartArea = ca.Name;
                va.Name = "Sim Maximum";
                va.LineColor = Color.Green;
                va.LineWidth = 2;
                va.X = (int)statistik.MaxWürfe;
                chartSimulation.Annotations.Add(va);
                ErgebnisMatrixdgv.Rows[(int)statistik.MaxWürfe - 1].DefaultCellStyle.BackColor = Color.LawnGreen;
            }
            catch (Exception)
            {

            }

            //ChartSimulation
            chartSimulation.Series[0].Points.Clear();
            for (int i = 0; i < statistik.Würfe.Length; i++)
            {
                chartSimulation.Series[0].Points.AddY(statistik.Würfe[i] / (decimal)statistik.GesammtSpiele);
            }

            chartSimulation.Series[1].Points.Clear();
            int[] value = new int[statistik.Würfe.Length];
            decimal gesammt = 0;
            for (int i = 0; i < statistik.Würfe.Length; i++)
            {
                gesammt += statistik.Würfe[i] * i;
                value[i] = (int)gesammt;
            }

            for (int i = 0; i < statistik.Würfe.Length; i++)
            {
                chartSimulation.Series[1].Points.AddY(value[i] / gesammt);
            }

            Berechnungen(statistik.MaxWürfe);
        }
        /// <summary>
        /// Draw a vertical line on chart.
        /// </summary>
        /// <param name="sender">Source Chart.</param>
        /// <param name="x">XAxis value.</param>
        /// <param name="lineColor">Line color.</param>
        /// <param name="name">Annotation name.</param>
        /// <param name="lineWidth">Line width</param>
        /// <param name="lineStyle">Line style</param>
        public static void DrawVerticalLine(this Chart sender, double x,
            Drawing.Color lineColor, string name = "",
            int lineWidth = 1, ChartDashStyle lineStyle = ChartDashStyle.Solid)
        {
            VerticalLineAnnotation vertLine = new VerticalLineAnnotation();
            string chartAreaName = sender.ChartAreas[0].Name;
            vertLine.ClipToChartArea = chartAreaName;
            vertLine.AxisXName = chartAreaName + "\\rX";
            vertLine.YAxisName = chartAreaName + "\\rY";
            vertLine.IsInfinitive = true;
            vertLine.IsSizeAlwaysRelative = false;

            vertLine.X = x;
            vertLine.LineColor = lineColor;
            vertLine.LineWidth = lineWidth;
            vertLine.LineDashStyle = lineStyle;
            sender.Annotations.Add(vertLine);

            if (!string.IsNullOrEmpty(name)) vertLine.Name = name;
        }
Esempio n. 30
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 = "";
            }
        }
Esempio n. 31
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());
            }
        }
		private void InitializeHistogramChart()
		{
			// Add new series
			m_HistogramSeries = m_AnglesChart.Series.Add(c_HistogramSeriesName);

			// Set new series chart type and other attributes
			m_HistogramSeries.ChartType = SeriesChartType.Column;
			m_HistogramSeries.BorderColor = Color.Black;
			m_HistogramSeries.BorderWidth = 1;
			m_HistogramSeries.BorderDashStyle = ChartDashStyle.Solid;
			m_HistogramSeries["PointWidth"] = "1.0";
			m_HistogramSeries["BarLabelStyle"] = "Center";

			// This series is solely used for anchoring the annotation that indicates the current heading change
			m_CurrentHeadingChangeSeries = m_AnglesChart.Series.Add(c_CurrentHeadingChangeSeriesName);
			m_CurrentHeadingChangeSeries.ChartType = SeriesChartType.Point;
			m_CurrentHeadingChangeSeries.ChartArea = m_HistogramSeries.ChartArea;
			m_CurrentHeadingChangeSeries.MarkerSize = 0;

			// Adjust chart area
			ChartArea chartArea = m_AnglesChart.ChartAreas[m_HistogramSeries.ChartArea];
			chartArea.AxisY.Title = "Frequency";
			chartArea.AxisX.Minimum = m_Histogram.Min;
			chartArea.AxisX.Maximum = m_Histogram.Max;

			chartArea.AxisX.Interval = 0.5;
			chartArea.AxisX.MajorGrid.Interval = 0.5;
			chartArea.AxisX.MajorTickMark.Interval = 0.1;

			m_CurrentHeadingChangeAnnotation = new VerticalLineAnnotation();

			m_CurrentHeadingChangeAnnotation.Height = -100;
			m_CurrentHeadingChangeAnnotation.LineWidth = 2;
			m_CurrentHeadingChangeAnnotation.LineColor = Color.Red;

			m_AnglesChart.Annotations.Add(m_CurrentHeadingChangeAnnotation);
		}
        public Evaluation(OpenNIImageDisplay videoControl)
        {
            InitializeComponent();

            // Initialize Statistics
            statistics = new Statistics();
            statistics.ClearCumulativeConfidencePoints += clearCumulativeConfidencePoints;
            statistics.AddCumulativeConfidencePoint += addConfidencePoint;
            statistics.ClearErrorPoints += clearErrorPoints;
            statistics.AddErrorPoint += addErrorPoint;
            statistics.FinalizeErrorUpdate += finalizeMainPointUpdate;
            statistics.FinalizeConfidenceUpdate += finalizeCumulativeConfidenceUpdate;
            statistics.FrameUpdated += statistics_FrameUpdated;
            videoControl.NewRecordingFrameDisplayed += UpdateFrame;

            // Add data Bindings
            textBoxGlobalMean.DataBindings.Add("Text", statistics, "GlobalMean",
                true, DataSourceUpdateMode.Never, 0, "0.000",
                NUMBER_CULTURE);

            textBoxFrameMean.DataBindings.Add("Text", statistics, "FrameMean",
                true, DataSourceUpdateMode.Never, 0, "0.000",
                NUMBER_CULTURE);

            textBoxFrameValue.DataBindings.Add("Text", statistics, "FrameValue",
                true, DataSourceUpdateMode.Never, 0, "0.000",
                NUMBER_CULTURE);

            textBoxNumberOfPoints.DataBindings.Add("Text", statistics, "NumberOfPoints",
                true, DataSourceUpdateMode.Never, 0, "0",
                NUMBER_CULTURE);

            // Initialize list box and error chart area
            foreach (JointTranslationTuple translation in JointDictionary.JointTranslationList)
            {
                checkedListBoxBodyParts.Items.Add(translation.name);
                chartErrors.Series.Add(translation.name);
                chartErrors.Series[translation.name].Enabled = false;
                chartErrors.Series[translation.name].ChartType = SeriesChartType.StackedArea;
                chartErrors.Series[translation.name].ToolTip = translation.name;
                annotations[translation.joint_type] = new List<Annotation>();
            }

            // Add always present legend items
            LegendItem legendItemMarkerFalsePositive = new LegendItem();
            legendItemMarkerFalsePositive.Name = "False Positive";
            legendItemMarkerFalsePositive.MarkerStyle = MarkerStyle.Square;
            legendItemMarkerFalsePositive.MarkerSize = 7;
            legendItemMarkerFalsePositive.ImageStyle = LegendImageStyle.Marker;
            legendItemMarkerFalsePositive.MarkerColor = markerColorFalseNegative;
            chartErrors.Legends[0].CustomItems.Add(legendItemMarkerFalsePositive);

            LegendItem legendItemMarkerFalseNegative = new LegendItem();
            legendItemMarkerFalseNegative.Name = "False Negative";
            legendItemMarkerFalseNegative.MarkerStyle = MarkerStyle.Circle;
            legendItemMarkerFalseNegative.ImageStyle = LegendImageStyle.Marker;
            legendItemMarkerFalseNegative.MarkerColor = markerColorFalsePositive;
            legendItemMarkerFalseNegative.MarkerSize = 7;
            chartErrors.Legends[0].CustomItems.Add(legendItemMarkerFalseNegative);

            LegendItem legendItemMarkerNA = new LegendItem();
            legendItemMarkerNA.Name = "No data available";
            legendItemMarkerNA.MarkerStyle = MarkerStyle.Circle;
            legendItemMarkerNA.ImageStyle = LegendImageStyle.Marker;
            legendItemMarkerNA.MarkerColor = markerColorNA;
            legendItemMarkerNA.MarkerSize = 7;
            chartErrors.Legends[0].CustomItems.Add(legendItemMarkerNA);

            // Add the line annotation marking the displayed frame.
            frame_indicator = new VerticalLineAnnotation();
            frame_indicator.AxisX = chartErrors.ChartAreas[0].AxisX;
            frame_indicator.AxisY = chartErrors.ChartAreas[0].AxisY;
            frame_indicator.X = 0;
            frame_indicator.Height = chartErrors.Height;
            frame_indicator.LineColor = Color.Red;
            frame_indicator.LineWidth = 1;
            frame_indicator.LineDashStyle = ChartDashStyle.Solid;
            frame_indicator.Y = frame_indicator.AxisY.Minimum;
            chartErrors.Annotations.Add(frame_indicator);

            // Initialize the video source the line indicator is synced with.
            videoDataSource = videoControl;
            videoDataSource.SourceChanged += new EventHandler(videoDataSource_SourceChanged);
        }
Esempio n. 34
0
        private void SetAnnotationStyle1()
        {
            if (AnnotationStyle1 == null || AnnotationStyle1.SelectedIndex == -1)
            {
                return;
            }

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

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

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

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

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

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

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

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

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

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

                annotation.LineColor = Color.FromName(AnnotationStyle1.SelectedItem.Value);
            }
        }
        /// <summary>
        /// Displays the history for the current statistics.
        /// </summary>
        /// <param name="history">The views history.</param>
        /// <param name="axisX">The X axis.</param>
        /// <param name="axisY">The Y axis.</param>
        private void DisplayHistory(AjaxViewsHistory history, string axisX, string axisY)
        {
            if (null == history) return;

            this.chart.Series.Clear();
            this.chart.Annotations.Clear();
            this.listViewDiscovery.Items.Clear();

            // Update the chart.
            Series series = new Series("Video {0}".FormatWith(this.textBox));
            series.ChartType = SeriesChartType.Line;
            series.XValueType = ChartValueType.DateTime;
            series.YValueType = ChartValueType.Int32;
            series.Font = new Font(this.Font.FontFamily, this.Font.Size, this.Font.Style);
            series.MarkerStyle = MarkerStyle.Circle;

            foreach (AjaxHistoryPoint point in history.Series)
                series.Points.AddXY(point.Time, point.Value);

            this.chart.Series.Add(series);
            this.chart.ChartAreas[0].AxisX.Title = axisX;
            this.chart.ChartAreas[0].AxisY.Title = axisY;

            AjaxHistoryMarker? lastMarker = null;
            RectangleAnnotation lastAnnotation = null;

            // For all markers.
            foreach (AjaxHistoryMarker marker in history.Markers)
            {
                // Get the history point closest to the marker.
                AjaxHistoryPoint? point = history.GetPointAt(marker);

                // If the point does not exist, continue.
                if (null == point) continue;

                // If the last marker and last annotation exist.
                if ((lastMarker != null) && (lastAnnotation != null))
                {
                    // If the last marker has the same date with the current one, only update the annotation text.
                    if (lastMarker.Value.Time == marker.Time)
                    {
                        lastAnnotation.Text += " " + marker.Name;
                        continue;
                    }
                }

                RectangleAnnotation rect = new RectangleAnnotation();
                rect.Text = marker.Name;
                rect.ForeColor = Color.Black;
                rect.AxisX = this.chart.ChartAreas[0].AxisX;
                rect.AxisY = this.chart.ChartAreas[0].AxisY;
                rect.AnchorX = marker.Time.ToOADate();
                rect.AnchorY = point.Value.Value;
                rect.AnchorOffsetX = 0;
                rect.AnchorOffsetY = 5;
                rect.ShadowColor = Color.Gray;
                rect.ShadowOffset = 5;

                VerticalLineAnnotation line = new VerticalLineAnnotation();
                line.AxisX = this.chart.ChartAreas[0].AxisX;
                line.AxisY = this.chart.ChartAreas[0].AxisY;
                line.AnchorX = marker.Time.ToOADate();
                line.AnchorY = point.Value.Value;
                line.Height = -5;

                this.chart.Annotations.Add(line);
                this.chart.Annotations.Add(rect);
                this.chart.ResetAutoValues();

                lastAnnotation = rect;
                lastMarker = marker;
            }

            // Add discovery events.
            foreach (KeyValuePair<string, AjaxViewsHistoryDiscoveryEvent> evt in history.DiscoveryEvents)
            {
                ListViewItem item = new ListViewItem(new string[] {
                        evt.Value.Name,
                        evt.Value.Marker != null ? evt.Value.Marker.Value.Time.ToString() : "Unknown",
                        AjaxViewsHistoryDiscoveryEvent.GetTypeDescription(evt.Value.Type),
                        evt.Value.Extra != null ? evt.Value.Extra : string.Empty }, 0);
                item.Tag = evt.Value;

                this.listViewDiscovery.Items.Add(item);
            }
        }
        public override View GetSampleContent(Context context)
        {
            chart = new SfChart(context);
            chart.SetBackgroundColor(Color.White);
            chart.AreaBackgroundColor = Color.Rgb(245, 245, 245);

            NumericalAxis categoryaxis = new NumericalAxis();

            categoryaxis.ShowMajorGridLines    = false;
            categoryaxis.Minimum               = 0;
            categoryaxis.Maximum               = 4;
            categoryaxis.LineStyle.StrokeColor = Color.White;
            chart.PrimaryAxis = categoryaxis;

            NumericalAxis numericalaxis = new NumericalAxis();

            numericalaxis.ShowMajorGridLines    = false;
            numericalaxis.Minimum               = 20;
            numericalaxis.Maximum               = 70;
            numericalaxis.LineStyle.StrokeColor = Color.White;
            chart.SecondaryAxis = numericalaxis;

            LineAnnotation lineAnnotation = new LineAnnotation();

            lineAnnotation.Text = "Line";
            lineAnnotation.X1   = 2.5;
            lineAnnotation.X2   = 3.5;
            lineAnnotation.Y1   = 52;
            lineAnnotation.Y2   = 63;
            lineAnnotation.LabelStyle.MarginTop    = 5;
            lineAnnotation.LabelStyle.MarginRight  = 5;
            lineAnnotation.LabelStyle.MarginLeft   = 5;
            lineAnnotation.LabelStyle.MarginBottom = 5;
            lineAnnotation.LineCap = ChartLineCap.Arrow;

            HorizontalLineAnnotation horizontalAnnotation = new HorizontalLineAnnotation();

            horizontalAnnotation.Y1            = 45;
            horizontalAnnotation.Text          = "Horizontal Line";
            horizontalAnnotation.LineCap       = ChartLineCap.Arrow;
            horizontalAnnotation.ShowAxisLabel = true;

            VerticalLineAnnotation verticalAnnotation = new VerticalLineAnnotation();

            verticalAnnotation.X1            = 2;
            verticalAnnotation.Text          = "Vertical Line";
            verticalAnnotation.LineCap       = ChartLineCap.Arrow;
            verticalAnnotation.ShowAxisLabel = true;

            RectangleAnnotation RectAnnotation = new RectangleAnnotation();

            RectAnnotation.X1   = 0.5;
            RectAnnotation.X2   = 1.5;
            RectAnnotation.Y1   = 25;
            RectAnnotation.Y2   = 35;
            RectAnnotation.Text = "Rectangle";

            EllipseAnnotation eleAnnotation = new EllipseAnnotation();

            eleAnnotation.X1   = 2.5;
            eleAnnotation.X2   = 3.5;
            eleAnnotation.Y1   = 25;
            eleAnnotation.Y2   = 35;
            eleAnnotation.Text = "Ellipse";

            TextAnnotation textAnnotation = new TextAnnotation();

            textAnnotation.X1   = 1;
            textAnnotation.Y1   = 57.5;
            textAnnotation.Text = "Text Annotation";

            chart.Annotations.Add(textAnnotation);
            chart.Annotations.Add(eleAnnotation);
            chart.Annotations.Add(RectAnnotation);
            chart.Annotations.Add(verticalAnnotation);
            chart.Annotations.Add(horizontalAnnotation);
            chart.Annotations.Add(lineAnnotation);
            return(chart);
        }
        public ChartAnnotation()
        {
            SFChart chart = new SFChart();

            chart.AreaBackgroundColor = UIColor.FromRGB(245, 245, 245);
            chart.PrimaryAxis         = new SFNumericalAxis()
            {
                Minimum            = new NSNumber(0),
                Maximum            = new NSNumber(4),
                ShowMajorGridLines = false
            };
            chart.SecondaryAxis = new SFNumericalAxis()
            {
                Minimum            = new NSNumber(20),
                Maximum            = new NSNumber(70),
                ShowMajorGridLines = false,
            };

            VerticalLineAnnotation VerticalLineAnnotation = new VerticalLineAnnotation();

            VerticalLineAnnotation.X1            = 2;
            VerticalLineAnnotation.LineCap       = ChartLineCap.Arrow;
            VerticalLineAnnotation.Text          = "Vertical Line";
            VerticalLineAnnotation.ShowAxisLabel = true;

            HorizontalLineAnnotation horizontalLineAnnotation = new HorizontalLineAnnotation();

            horizontalLineAnnotation.Y1            = 45;
            horizontalLineAnnotation.LineCap       = ChartLineCap.Arrow;
            horizontalLineAnnotation.Text          = "Horizontal Line";
            horizontalLineAnnotation.ShowAxisLabel = true;

            LineAnnotation lineAnnotation = new LineAnnotation();

            lineAnnotation.X1      = 2.5;
            lineAnnotation.X2      = 3.5;
            lineAnnotation.Y1      = 52;
            lineAnnotation.Y2      = 63;
            lineAnnotation.LineCap = ChartLineCap.Arrow;
            lineAnnotation.Text    = "Line";

            RectangleAnnotation rectangleAnnotation = new RectangleAnnotation();

            rectangleAnnotation.Text = "Rectangle";
            rectangleAnnotation.X1   = 0.5;
            rectangleAnnotation.X2   = 1.5;
            rectangleAnnotation.Y1   = 25;
            rectangleAnnotation.Y2   = 35;

            EllipseAnnotation ellipseAnnotation = new EllipseAnnotation();

            ellipseAnnotation.Text = "Ellipse";
            ellipseAnnotation.X1   = 2.5;
            ellipseAnnotation.X2   = 3.5;
            ellipseAnnotation.Y1   = 25;
            ellipseAnnotation.Y2   = 35;

            TextAnnotation textAnnotation = new TextAnnotation();

            textAnnotation.X1   = 1;
            textAnnotation.Y1   = 57.5;
            textAnnotation.Text = "Text Annotation";

            chart.Annotations.Add(VerticalLineAnnotation);
            chart.Annotations.Add(horizontalLineAnnotation);
            chart.Annotations.Add(lineAnnotation);
            chart.Annotations.Add(rectangleAnnotation);
            chart.Annotations.Add(ellipseAnnotation);
            chart.Annotations.Add(textAnnotation);
            this.AddSubview(chart);
        }
Esempio n. 38
0
        protected void chartAdvGraph_Click(object sender, ImageMapEventArgs e)
        {
            string[] postBackValues;
            DateTime xDate;
            double   lineWidth;
            double   lineHeight;
            string   seriesName;

            try
            {
                if (chartAdvGraph.Annotations.Count > 0)
                {
                    chartAdvGraph.Annotations.Clear();
                }

                postBackValues = e.PostBackValue.Split(',');

                if (postBackValues[0].Equals("AnnotationClicked"))
                {
                    return;
                }

                seriesName = postBackValues[0];

                xDate      = System.Convert.ToDateTime(postBackValues[2]);
                lineWidth  = xDate.ToOADate();
                lineHeight = System.Convert.ToDouble(postBackValues[3]);

                HorizontalLineAnnotation HA = new HorizontalLineAnnotation();
                VerticalLineAnnotation   VA = new VerticalLineAnnotation();
                RectangleAnnotation      ra = new RectangleAnnotation();

                if (seriesName.Equals("Volume"))
                {
                    HA.AxisY = chartAdvGraph.ChartAreas[2].AxisY;
                    VA.AxisY = chartAdvGraph.ChartAreas[2].AxisY;
                    ra.AxisY = chartAdvGraph.ChartAreas[2].AxisY;

                    HA.AxisX = chartAdvGraph.ChartAreas[2].AxisX;
                    VA.AxisX = chartAdvGraph.ChartAreas[2].AxisX;
                    ra.AxisX = chartAdvGraph.ChartAreas[2].AxisX;

                    HA.ClipToChartArea = chartAdvGraph.ChartAreas[2].Name;
                }
                else if (seriesName.Equals("PctChange"))
                {
                    HA.AxisY = chartAdvGraph.ChartAreas[0].AxisY;
                    VA.AxisY = chartAdvGraph.ChartAreas[0].AxisY;
                    ra.AxisY = chartAdvGraph.ChartAreas[0].AxisY;

                    HA.AxisX = chartAdvGraph.ChartAreas[0].AxisX2;
                    VA.AxisX = chartAdvGraph.ChartAreas[0].AxisX2;
                    ra.AxisX = chartAdvGraph.ChartAreas[0].AxisX2;

                    HA.ClipToChartArea = chartAdvGraph.ChartAreas[0].Name;
                }
                else
                {
                    HA.AxisY = chartAdvGraph.ChartAreas[1].AxisY;
                    VA.AxisY = chartAdvGraph.ChartAreas[1].AxisY;
                    ra.AxisY = chartAdvGraph.ChartAreas[1].AxisY;

                    HA.AxisX           = chartAdvGraph.ChartAreas[1].AxisX2;
                    VA.AxisX           = chartAdvGraph.ChartAreas[1].AxisX2;
                    ra.AxisX           = chartAdvGraph.ChartAreas[1].AxisX2;
                    HA.ClipToChartArea = chartAdvGraph.ChartAreas[1].Name;
                }

                HA.IsSizeAlwaysRelative = false;
                HA.AnchorY       = lineHeight;
                HA.IsInfinitive  = true;
                HA.LineDashStyle = ChartDashStyle.Dash;
                HA.LineColor     = Color.Red;
                HA.LineWidth     = 1;
                HA.ToolTip       = postBackValues[3];
                chartAdvGraph.Annotations.Add(HA);

                VA.IsSizeAlwaysRelative = false;
                VA.AnchorX       = lineWidth;
                VA.IsInfinitive  = true;
                VA.LineDashStyle = ChartDashStyle.Dash;
                VA.LineColor     = Color.Red;
                VA.LineWidth     = 1;
                VA.ToolTip       = postBackValues[2];
                chartAdvGraph.Annotations.Add(VA);

                ra.Name = seriesName;
                ra.IsSizeAlwaysRelative = true;
                ra.AnchorX       = lineWidth;
                ra.AnchorY       = lineHeight;
                ra.IsMultiline   = true;
                ra.LineDashStyle = ChartDashStyle.Solid;
                ra.LineColor     = Color.Blue;
                ra.LineWidth     = 1;
                ra.PostBackValue = "AnnotationClicked";

                if (seriesName.Equals("OHLC"))
                {   //high,low,open,close
                    //"OHLC," + symbol + "," + "#VALX,#VALY1,#VALY2,#VALY3,#VALY4";
                    ra.Text = postBackValues[1] + "\n" + "Date:" + postBackValues[2] + "\n" + "High:" + postBackValues[3] + "\n" +
                              "Low:" + postBackValues[4] + "\n" + "Open:" + postBackValues[5] + "\n" + "Close:" + postBackValues[6];
                }
                else if (seriesName.Equals("PctChange"))
                {
                    ra.Text = postBackValues[1] + "\n" + "Date:" + postBackValues[2] + "\n" + "Prev Close:" + postBackValues[5] + "\n" + "Change %:" + postBackValues[3] + "\n" +
                              "Change:" + postBackValues[4];
                }
                else if (seriesName.Equals("Portfolio"))
                {
                    ra.Text = postBackValues[1] + "\nPurchase Date:" + postBackValues[4] + "\nPurchase Price:" + postBackValues[5] + "\nPurchased Units: " + postBackValues[6] +
                              "\nPurchase Cost: " + postBackValues[7] + "\nCumulative Units: " + postBackValues[8] + "\nCumulative Cost: " + postBackValues[9] +
                              "\nValue as of date: " + postBackValues[10];
                    HA.ToolTip = "Close Price: " + postBackValues[3];
                    VA.ToolTip = postBackValues[2];
                }
                else
                {
                    //0-Volume, 1-Date, 2-Volume/Open/High/Low/Close
                    ra.Text = postBackValues[1] + "\n" + "Date:" + postBackValues[2] + "\n" + seriesName + ":" + postBackValues[3];
                }

                chartAdvGraph.Annotations.Add(ra);
            }
            catch (Exception ex)
            {
                Page.ClientScript.RegisterStartupScript(GetType(), "myScript", "alert('Exception while plotting lines:" + ex.Message + "');", true);
            }
        }