Esempio n. 1
1
        private void Annotation_SelectedIndexChanged(object sender, System.EventArgs e)
        {
            Chart1.Annotations.Clear();

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

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

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

                Chart1.Annotations.Add(annotation);

                SetLineControls(true);

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

                Chart1.Annotations.Add(annotation);

                SetLineControls(true);

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

                Chart1.Annotations.Add(annotation);

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

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

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

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

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

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

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

                annotation.GraphicsPath.AddPolygon(points);

                Chart1.Annotations.Add(annotation);

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

                Chart1.Annotations.Add(annotation);
                SetTextControls();

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

                Chart1.Annotations.Add(annotation);

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

                Chart1.Annotations.Add(annotation);

                SetTextControls();
                SetColorLineControls();
                AnnotationStyle1.SelectedIndex = 2;

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

                Chart1.Annotations.Add(annotation);

                SetArrowControls();

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

                Chart1.Annotations.Add(annotation);

                SetBorder3DControls();

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

                Chart1.Annotations.Add(annotation);

                SetCalloutControls();

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

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

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

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

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

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

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

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

                annotation.GraphicsPath.AddPolygon(points);

                Chart1.Annotations.Add(annotation);

                SetColorControl();
                SetColorLineControls();

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

                    g.Dispose();

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

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

                Chart1.Annotations.Add(annotation);
                StyleLabel1.Text = "";
                StyleLabel2.Text = "";
            }
        }
Esempio n. 2
0
		public void Constructor ()
		{
			ArrowAnnotation aa = new ArrowAnnotation ();

			Assert.AreEqual (5, aa.ArrowSize, "A1");
			Assert.AreEqual (ArrowStyle.Simple, aa.ArrowStyle, "A2");
		}
Esempio n. 3
0
		public void ArrowStyleProperty ()
		{
			ArrowAnnotation aa = new ArrowAnnotation ();

			Assert.AreEqual (ArrowStyle.Simple, aa.ArrowStyle, "A1");

			aa.ArrowStyle = ArrowStyle.DoubleArrow;
			Assert.AreEqual (ArrowStyle.DoubleArrow, aa.ArrowStyle, "A2");
		}
Esempio n. 4
0
		public void ArrowSizeProperty ()
		{
			ArrowAnnotation aa = new ArrowAnnotation ();

			Assert.AreEqual (5, aa.ArrowSize, "A1");

			aa.ArrowSize = 3;
			Assert.AreEqual (3, aa.ArrowSize, "A2");
		}
        /// <summary>
        /// </summary>
        private void ReformatGraphInternal()
        {
            if (m_askData.Count > 0)
            {
                m_chart.Series[kAskSeriesName].Points.DataBindXY(m_times, m_askData);
                m_chart.Series[kBidSeriesName].Points.DataBindXY(m_times, m_bidData);
                m_chart.Series[kPriceSeriesName].Points.DataBindXY(m_times, m_lastPrice);

                m_chart.Annotations.Clear();

                decimal markerMin = decimal.MaxValue;
                decimal markerMax = 0;
                lock (m_markers)
                {
                    foreach (var kvp in m_markers)
                    {
                        int index = FindClosestDate(kvp.Key);

                        foreach (MarkerContainer c in kvp.Value)
                        {
                            if (index != -1)
                            {
                                var annotation = new ArrowAnnotation {ArrowSize = 3, ArrowStyle = ArrowStyle.Simple};

                                annotation.AnchorDataPoint = m_chart.Series[kAskSeriesName].Points[index];
                                if (c.m_actioned)
                                {
                                    annotation.BackColor = c.m_up ? Color.Green : Color.Red;
                                }
                                annotation.ForeColor = c.m_actioned ? Color.Green : Color.Red;
                                annotation.Width = 0;
                                annotation.Height = c.m_up ? 5 : -5;
                                annotation.SmartLabelStyle.IsOverlappedHidden = false;
                                annotation.AnchorY = (double) c.m_price;

                                markerMin = Math.Min(c.m_price, markerMin);
                                markerMax = Math.Max(c.m_price, markerMax);

                                // only keep unaction markers which are less than 10 mins old
                                bool allow = (!c.m_actioned && (DateTime.UtcNow - kvp.Key) < new TimeSpan(0, 10, 0)) ||
                                             c.m_actioned;
                                if (allow)
                                {
                                    m_chart.Annotations.Add(annotation);
                                }
                            }
                        }
                    }
                }


                decimal ymin = Math.Min(Math.Min(Math.Min(m_askData.Min(), m_bidData.Min()), m_lastPrice.Min()),
                    markerMin);
                decimal ymax = Math.Max(Math.Max(Math.Max(m_askData.Max(), m_bidData.Max()), m_lastPrice.Max()),
                    markerMax);
                decimal range = ymax - ymin;

                m_area.AxisY.Minimum = (double) (ymin - range/2);
                m_area.AxisY.Maximum = (double) (ymax + range/2);

                m_chart.Invalidate();
            }
        }
Esempio n. 6
0
 void PlotVerificationPoints(MeasPointList MeasPoints)
 {
     Series s = chart1.Series["Verif"];
     s.MarkerStyle = MarkerStyle.Square;
     // Set error bar center marker style
     s.MarkerStyle = MarkerStyle.None;
     s.MarkerColor = System.Drawing.Color.Fuchsia;
     chart1.ChartAreas[0].AxisX.Minimum = MeasPoints.LowerMass * 0.9;
     chart1.ChartAreas[0].AxisX.Maximum = MeasPoints.UpperMass * 1.1;
     int imax = 0;
     ArrowAnnotation maxpt = new ArrowAnnotation();
     maxpt.Name = "max";
     maxpt.Height = -4;
     maxpt.Width = 0;
     maxpt.AnchorOffsetY = -2.5;
     maxpt.ResizeToContent();
     foreach (MeasPointData p in MeasPoints)
     {
         int i = s.Points.AddXY(p.Mass, p.Doubles);
         if (p.Mass == MeasPoints.UpperMass)
         {
             imax = i;
             maxpt.ToolTip = "Max " + p.ToString();
         }
         s.Points[i].ToolTip = p.ToString();
     }
     chart1.Annotations.Add(maxpt);
     maxpt.AnchorDataPoint = s.Points[imax];
 }
        /// <summary>
        /// Initialises the chart
        /// </summary>
        private void InitChart()
        {
            _mainChartArea.AxisX.ScaleView.Zoomable = true;
            _mainChartArea.AxisY.ScaleView.Zoomable = true;
            _mainChartArea.CursorX.AutoScroll = true;
            _mainChartArea.CursorY.AutoScroll = true;
            //_mainChartArea.AxisY2.Enabled = AxisEnabled.True;

            _priceAnnotation = new RectangleAnnotation();
            _priceAnnotation.ForeColor = Color.Black;
            _priceAnnotation.Font = new Font("Arial", 9); ;
            _priceAnnotation.LineWidth = 1;
            _priceAnnotation.BackColor = Color.LemonChiffon;

            chartCtrl.Annotations.Add(_priceAnnotation);

            _maxPriceAnnotation = new CalloutAnnotation();
            _maxPriceAnnotation.ForeColor = Color.Black;
            _maxPriceAnnotation.Font = new Font("Arial", 9); ;
            _maxPriceAnnotation.LineWidth = 1;
            _maxPriceAnnotation.CalloutStyle = CalloutStyle.SimpleLine;
            _maxPriceAnnotation.AnchorAlignment = ContentAlignment.BottomRight;
            chartCtrl.Annotations.Add(_maxPriceAnnotation);

            _minPriceAnnotation = new CalloutAnnotation();
            _minPriceAnnotation.ForeColor = Color.Black;
            _minPriceAnnotation.Font = new Font("Arial", 9); ;
            _minPriceAnnotation.LineWidth = 1;
            _minPriceAnnotation.CalloutStyle = CalloutStyle.SimpleLine;
            _minPriceAnnotation.AnchorAlignment = ContentAlignment.MiddleRight;
            _minPriceAnnotation.AxisX = _mainChartArea.AxisX;
            _minPriceAnnotation.AxisY = _mainChartArea.AxisY;

            chartCtrl.Annotations.Add(_minPriceAnnotation);

            _currentPriceAnnotation = new ArrowAnnotation();
            _currentPriceAnnotation.ForeColor = Color.Black;
            _currentPriceAnnotation.Font = new Font("Arial", 9);
            _currentPriceAnnotation.LineWidth = 1;
            _currentPriceAnnotation.Width = 1;
            _currentPriceAnnotation.Height = 1;
            _currentPriceAnnotation.ArrowSize = 1;
            _currentPriceAnnotation.AxisX = _mainChartArea.AxisX;
            _currentPriceAnnotation.AxisY = _mainChartArea.AxisY;
            _currentPriceAnnotation.ArrowSize = 3;
            _currentPriceAnnotation.Height = 0;
            _currentPriceAnnotation.AnchorAlignment = ContentAlignment.MiddleLeft;
            //_currentPriceAnnotation.AnchorAlignment = ContentAlignment.MiddleRight;

            chartCtrl.Annotations.Add(_currentPriceAnnotation);

            // _mainChartArea.BackSecondaryColor = _mainChartArea.BackColor = Color.Black;
            chartCtrl.Series[Constants.PriceSerieName]["PriceUpColorUp"] = "Green";
        }
Esempio n. 8
0
		public void ArrowSizePropertyAOORE ()
		{
			ArrowAnnotation aa = new ArrowAnnotation ();
			
			aa.ArrowSize = 0;
		}