Example #1
0
 public HeatMapWindow()
 {
     InitializeComponent();
     AngleDegrees          = 0;
     RHeight               = 4;
     RWidth                = 4;
     Eps                   = 0.001;
     arrow                 = new ArrowAnnotation();
     arrow.StartPoint      = new DataPoint(ArrowR * Math.Cos(ArrowAngleRadians), ArrowR * Math.Sin(ArrowAngleRadians));
     arrow.EndPoint        = new DataPoint(ArrowCloserR * Math.Cos(ArrowAngleRadians), ArrowCloserR * Math.Sin(ArrowAngleRadians));
     arrow.StrokeThickness = 4;
     arrow.Color           = Colors.DarkRed;
     plot.Annotations.Add(arrow);
     rectangle.Points = new List <DataPoint>()
     {
         new DataPoint(RWidth / 2.0, RHeight / 2.0),
         new DataPoint(-RWidth / 2.0, RHeight / 2.0),
         new DataPoint(-RWidth / 2.0, -RHeight / 2.0),
         new DataPoint(RWidth / 2.0, -RHeight / 2.0)
     };
     SetGradientStopsForReload();
     DataContext = this;
     AngleSlider.ValueChanged  += AngleSlider_ValueChanged;
     EpsSlider.ValueChanged    += EpsSlider_ValueChanged;
     HeightSlider.ValueChanged += HWSlider_ValueChanged;
     WidthSlider.ValueChanged  += HWSlider_ValueChanged;
     plot.Controller            = new PlotController();
     plot.Controller.UnbindMouseDown(OxyMouseButton.Left);
 }
Example #2
0
            public void ArrowAnnotation()
            {
                var s1 = new ArrowAnnotation();
                var s2 = new Annotations.ArrowAnnotation();

                OxyAssert.PropertiesAreEqual(s2, s1);
            }
Example #3
0
        private double add_arrow(double mass1, double mass2, int index0, int index, double mass_error, string aa_name, OxyColor color)
        {
            double score = 0.0;

            if (index0 != -1)
            {
                score = get_Edge_score(Psm_help.Spec.Peaks[index0].Intensity, Psm_help.Spec.Peaks[index].Intensity, Math.Abs(mass_error));
            }
            else
            {
                score = get_Edge_score(1, Psm_help.Spec.Peaks[index].Intensity, Math.Abs(mass_error));
            }

            this.all_dot_ls[index].Color = OxyColors.Black;
            ArrowAnnotation arrowAnnotation = new ArrowAnnotation();

            arrowAnnotation.StartPoint = new DataPoint(mass1, 0);
            arrowAnnotation.EndPoint   = new DataPoint(mass2, 0);
            arrowAnnotation.HeadWidth  = 2;
            arrowAnnotation.HeadLength = 5;
            arrowAnnotation.LineStyle  = LineStyle.Dot;
            arrowAnnotation.Color      = color;
            TextAnnotation txtAnn = new TextAnnotation();

            txtAnn.Text      = aa_name + " (" + score.ToString("F0") + ")";
            txtAnn.Position  = new DataPoint((mass1 + mass2) / 2, 0);
            txtAnn.Stroke    = OxyColors.Transparent;
            txtAnn.TextColor = color;

            this.MS2_help_denovol.arrow_annotation.Add(arrowAnnotation);
            this.MS2_help_denovol.arrow_annotation.Add(txtAnn);
            return(score);
        }
Example #4
0
        public void Constructor()
        {
            ArrowAnnotation aa = new ArrowAnnotation();

            Assert.AreEqual(5, aa.ArrowSize, "A1");
            Assert.AreEqual(ArrowStyle.Simple, aa.ArrowStyle, "A2");
        }
Example #5
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];
        }
Example #6
0
 public ArrowAnnotator(AnnotationDataEntity annotationData, PageInfo pageInfo)
     : base(annotationData, pageInfo)
 {
     this.arrowAnnotation = new ArrowAnnotation
     {
         Box = GetBox()
     };
 }
Example #7
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");
        }
Example #8
0
        public void ArrowSizeProperty()
        {
            ArrowAnnotation aa = new ArrowAnnotation();

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

            aa.ArrowSize = 3;
            Assert.AreEqual(3, aa.ArrowSize, "A2");
        }
Example #9
0
        // returns arrow end point x1,y1
        List <double> addLoad(MainWindow window, Load l, OxyColor color, double circleSize = 0, double maxLoadMagnitude = 1, double arrowUnitLength = 1)
        {
            if (l.alpha == null)   // moment
            {
                string s = "Node " + l.node.number + "\n";
                if (this.BC_list_nodes.Contains(l.node))
                {
                    s += this.BC_list_type[this.BC_list_nodes.IndexOf(l.node)] + "\n";
                }
                s += "Moment (z axis)=" + l.magnitude;
                addNode(window, l.node.x, l.node.y, s, circleSize * 0.7, color);
                List <double> r = new List <double>();
                r.Add(l.node.x);
                r.Add(l.node.y);
                return(r);
            }
            else
            {
                ArrowAnnotation arrow = new ArrowAnnotation()
                {
                };
                arrow.HeadLength = 2;
                arrow.StartPoint = new DataPoint(l.node.x, l.node.y);

                arrow.EndPoint = new DataPoint(l.node.x + Math.Cos(Convert.ToDouble(l.alpha)) * l.magnitude / maxLoadMagnitude * arrowUnitLength,
                                               l.node.y + Math.Sin(Convert.ToDouble(l.alpha)) * l.magnitude / maxLoadMagnitude * arrowUnitLength);
                arrow.Text = "fx: " + l.x.ToString("0.##") + "\nfy: " + l.y.ToString("0.##");

                arrow.Color = color;

                double xOffset = 0, yOffset = 0;

                if (l.alpha < 0)
                {
                    l.alpha = misc.toRadians(360) + l.alpha;
                }

                double a = Convert.ToDouble(l.alpha);
                if (misc.toRadians(90) < a && a < misc.toRadians(270))
                {
                    xOffset = -2 * 0.01 * window.l;
                }
                if (misc.toRadians(180) < a && a <= misc.toRadians(360))
                {
                    yOffset = -2 * 0.01 * window.l;
                }

                arrow.TextPosition = new DataPoint(l.node.x + xOffset, l.node.y + yOffset);

                window.plotModel.Annotations.Add(arrow);

                List <double> r = new List <double>();
                r.Add(arrow.EndPoint.X);
                r.Add(arrow.EndPoint.Y);
                return(r);
            }
        }
Example #10
0
        public static PlotModel AddAnnotations()
        {
            var model = new PlotModel {
                Title = "Add arrow annotations", Subtitle = "Press and drag the left mouse button"
            };
            var xaxis = new LinearAxis {
                Position = AxisPosition.Bottom
            };
            var yaxis = new LinearAxis {
                Position = AxisPosition.Left
            };

            model.Axes.Add(xaxis);
            model.Axes.Add(yaxis);
            model.Series.Add(new FunctionSeries(x => Math.Sin(x / 4) * Math.Acos(Math.Sin(x)), 0, Math.PI * 8, 2000, "sin(x/4)*acos(sin(x))"));

            ArrowAnnotation tmp = null;

            // Add handlers to the PlotModel's mouse events
            model.MouseDown += (s, e) =>
            {
                if (e.ChangedButton == OxyMouseButton.Left)
                {
                    // Create a new arrow annotation
                    tmp            = new ArrowAnnotation();
                    tmp.StartPoint = tmp.EndPoint = xaxis.InverseTransform(e.Position.X, e.Position.Y, yaxis);
                    model.Annotations.Add(tmp);
                    e.Handled = true;
                }
            };

            // Handle mouse movements (note: this is only called when the mousedown event was handled)
            model.MouseMove += (s, e) =>
            {
                if (tmp != null)
                {
                    // Modify the end point
                    tmp.EndPoint = xaxis.InverseTransform(e.Position.X, e.Position.Y, yaxis);
                    tmp.Text     = string.Format("Y = {0:0.###}", tmp.EndPoint.Y);

                    // Redraw the plot
                    model.InvalidatePlot(false);
                    e.Handled = true;
                }
            };

            model.MouseUp += (s, e) =>
            {
                if (tmp != null)
                {
                    tmp       = null;
                    e.Handled = true;
                }
            };

            return(model);
        }
Example #11
0
        /// <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";
        }
Example #12
0
        public void HacerAnotacion2(double x, string mensaje)
        {
            var arrowAnnotation2 = new ArrowAnnotation();

            arrowAnnotation2.Color      = OxyColors.Green;
            arrowAnnotation2.TextColor  = OxyColors.White;
            arrowAnnotation2.StartPoint = new DataPoint(x + 1, 0.5);
            arrowAnnotation2.EndPoint   = new DataPoint(x, 0);
            arrowAnnotation2.Text       = mensaje;
            this.MyModel.Annotations.Add(arrowAnnotation2);
        }
Example #13
0
        public MainWindowViewModel()
        {
            this.Controller = new PlotController();
            myPlotModel = new PlotModel { Title = "Example 1" };
            myPlotModel.Series.Add(new FunctionSeries(Math.Cos, 0, 10, 0.1, "cos(x)"));

            var arrowAnnotation = new ArrowAnnotation
            {
                StartPoint = new DataPoint(0, 0),
                EndPoint = new DataPoint(3, 1)
            };
            myPlotModel.Annotations.Add(arrowAnnotation);
        }
Example #14
0
        private void update_arrowY(List <double> scores) //根据打分排个序
        {
            this.arrow_Y_add   = 50;
            this.arrow_Y_minus = 50;
            List <int>   all_sort_index = new List <int>();
            const double max_score      = double.MaxValue;

            while (true)
            {
                double min_score = double.MaxValue;
                int    min_index = -1;
                for (int i = 0; i < scores.Count; ++i)
                {
                    if (scores[i] < min_score)
                    {
                        min_score = scores[i];
                        min_index = i;
                    }
                }
                if (min_index == -1)
                {
                    break;
                }
                all_sort_index.Add(min_index);
                scores[min_index] = max_score;
            }
            List <Annotation> arrow_annotation_tmp = new List <Annotation>(this.MS2_help_denovol.arrow_annotation);

            this.MS2_help_denovol.arrow_annotation.Clear();
            for (int i = 0; i < all_sort_index.Count; ++i)
            {
                ArrowAnnotation aa = arrow_annotation_tmp[all_sort_index[i] * 2] as ArrowAnnotation;
                TextAnnotation  ta = arrow_annotation_tmp[all_sort_index[i] * 2 + 1] as TextAnnotation;
                if (aa.StartPoint.X < aa.EndPoint.X) //向右
                {
                    aa.StartPoint     = new DataPoint(aa.StartPoint.X, this.arrow_Y_add);
                    aa.EndPoint       = new DataPoint(aa.EndPoint.X, this.arrow_Y_add);
                    ta.Position       = new DataPoint(ta.Position.X, this.arrow_Y_add);
                    this.arrow_Y_add += arrow_Y_Delta;
                }
                else //向左
                {
                    aa.StartPoint       = new DataPoint(aa.StartPoint.X, this.arrow_Y_minus);
                    aa.EndPoint         = new DataPoint(aa.EndPoint.X, this.arrow_Y_minus);
                    ta.Position         = new DataPoint(ta.Position.X, this.arrow_Y_minus);
                    this.arrow_Y_minus += arrow_Y_Delta;
                }
                this.MS2_help_denovol.arrow_annotation.Add(aa);
                this.MS2_help_denovol.arrow_annotation.Add(ta);
            }
        }
        public static PlotModel AddAnnotations()
        {
            var model = new PlotModel { Title = "Add arrow annotations", Subtitle = "Press and drag the left mouse button" };
            var xaxis = new LinearAxis { Position = AxisPosition.Bottom };
            var yaxis = new LinearAxis { Position = AxisPosition.Left };
            model.Axes.Add(xaxis);
            model.Axes.Add(yaxis);
            model.Series.Add(new FunctionSeries(x => Math.Sin(x / 4) * Math.Acos(Math.Sin(x)), 0, Math.PI * 8, 2000, "sin(x/4)*acos(sin(x))"));

            ArrowAnnotation tmp = null;

            // Add handlers to the PlotModel's mouse events
            model.MouseDown += (s, e) =>
            {
                if (e.ChangedButton == OxyMouseButton.Left)
                {
                    // Create a new arrow annotation
                    tmp = new ArrowAnnotation();
                    tmp.StartPoint = tmp.EndPoint = xaxis.InverseTransform(e.Position.X, e.Position.Y, yaxis);
                    model.Annotations.Add(tmp);
                    e.Handled = true;
                }
            };

            // Handle mouse movements (note: this is only called when the mousedown event was handled)
            model.MouseMove += (s, e) =>
            {
                if (tmp != null)
                {
                    // Modify the end point
                    tmp.EndPoint = xaxis.InverseTransform(e.Position.X, e.Position.Y, yaxis);
                    tmp.Text = string.Format("Y = {0:0.###}", tmp.EndPoint.Y);

                    // Redraw the plot
                    model.InvalidatePlot(false);
                    e.Handled = true;
                }
            };

            model.MouseUp += (s, e) =>
                {
                    if (tmp != null)
                    {
                        tmp = null;
                        e.Handled = true;
                    }
                };

            return model;
        }
Example #16
0
        public MainWindowViewModel()
        {
            this.Controller = new PlotController();
            myPlotModel     = new PlotModel {
                Title = "Example 1"
            };
            myPlotModel.Series.Add(new FunctionSeries(Math.Cos, 0, 10, 0.1, "cos(x)"));

            var arrowAnnotation = new ArrowAnnotation
            {
                StartPoint = new DataPoint(0, 0),
                EndPoint   = new DataPoint(3, 1)
            };

            myPlotModel.Annotations.Add(arrowAnnotation);
        }
Example #17
0
        public void InitAscan()
        {
            plotModel = new PlotModel
            {
                Title = "Ascan Plotting",
            };

            LinearAxis xAxis = new LinearAxis
            {
                Position           = AxisPosition.Bottom,
                MajorGridlineStyle = LineStyle.Solid,
            };

            plotModel.Axes.Add(xAxis);

            LinearAxis yAxis = new LinearAxis
            {
                Position           = AxisPosition.Left,
                MajorGridlineStyle = LineStyle.Solid,
            };

            plotModel.Axes.Add(yAxis);

            lineSeries = new LineSeries
            {
                Title           = "Ascan Data",
                Color           = OxyColors.Blue,
                StrokeThickness = 1.5,
            };
            plotModel.Series.Add(lineSeries);

            // Add gate into Ascan Plot
            annotation = new ArrowAnnotation
            {
                HeadLength      = 0,
                HeadWidth       = 0,
                Text            = "Gate",
                TextColor       = OxyColors.Red,
                StrokeThickness = 5,
                Color           = OxyColors.Red,
            };
            plotModel.Annotations.Add(annotation);
        }
Example #18
0
 void CreateArrow()
 {
     arrow = new ArrowAnnotation()
     {
         Color           = OxyColors.Black,
         StrokeThickness = 2,
         StartPoint      = new DataPoint(0, 0),
         EndPoint        = new DataPoint(0, 0),
     };
     arrowText = new TextAnnotation()
     {
         FontSize        = 25,
         Background      = OxyColors.White,
         Font            = "Times New Roman",
         StrokeThickness = 2,
         Stroke          = OxyColors.Black,
     };
     PlotModel.Annotations.Add(arrow);
     PlotModel.Annotations.Add(arrowText);
 }
Example #19
0
        public void pm_MouseMove(object sender, OxyMouseEventArgs e)
        {
            if (this.coupling_isEnabled && this.coupling_isMeasure)
            {
                EPRPlotView pw = this.getActivePlotView();
                pw.HideTracker();

                ArrowAnnotation Line = new ArrowAnnotation()
                {
                    StrokeThickness = 1,
                    Color           = OxyColors.Black,
                    HeadWidth       = 1,
                    StartPoint      = coupling_start,
                    EndPoint        = new DataPoint(pw.Model.Axes[0].InverseTransform(e.Position.X), coupling_start.Y)
                };
                pw.Model.Annotations.Add(Line);
                pw.Model.InvalidatePlot(false);
                mousePosition = new DataPoint(pw.Model.Axes[0].InverseTransform(e.Position.X), pw.Model.Axes[1].InverseTransform(e.Position.Y));
            }
        }
Example #20
0
        private ArrowAnnotation ArrowAdd(int index, Chart chart_, Color color_)   // 그래프 화살표 주석

        /*       for( index = 0; index< 값; index++ ){
         *              chart.Annotations.Add( ArrowAdd(index, chart)  );  <- 사용법
         *
         *      }
         */
        {
            ArrowAnnotation myAnno = new ArrowAnnotation();

            myAnno.AllowMoving     = false;
            myAnno.BackColor       = color_;
            myAnno.Height          = -5;
            myAnno.Width           = 0;
            myAnno.LineWidth       = 1;
            myAnno.ArrowSize       = 1;
            myAnno.AnchorOffsetY   = -5;
            myAnno.AnchorDataPoint = chart_.Series[0].Points[index];
            //kospi_chart.Annotations.Add(myAnno);

            return(myAnno);
        }
Example #21
0
        /// <summary>
        /// Creates an annotation with an arrow pointing at the trade.
        /// </summary>
        /// <param name="date">The date of the trade</param>
        /// <param name="price">The price</param>
        /// <param name="quantity">The quantity</param>
        /// <param name="showSize">Should the annotation text include the quantity traded or not?</param>
        /// <returns></returns>
        private static ArrowAnnotation CreateAnnotation(DateTime date, decimal price, decimal quantity, bool showSize)
        {
            string annotationFormat = showSize ? "{0:+#;-#}\n{1:0.00}" : "{1:0.00}";
            bool   buying           = quantity > 0;

            var annotation = new ArrowAnnotation
            {
                Text                    = string.Format(annotationFormat, quantity, price),
                TextPosition            = new DataPoint(DateTimeAxis.ToDouble(date), (double)price * (buying ? 0.985 : 1.015)),
                TextHorizontalAlignment = OxyPlot.HorizontalAlignment.Center,
                TextVerticalAlignment   = buying ? OxyPlot.VerticalAlignment.Top : OxyPlot.VerticalAlignment.Bottom,
                Font                    = "Segoe UI",
                TextColor               = OxyColor.FromRgb(227, 227, 227),
                Color                   = buying ? OxyColors.DodgerBlue : OxyColor.FromRgb(222, 222, 222),
                EndPoint                = new DataPoint(DateTimeAxis.ToDouble(date.Date), (double)price),
                StartPoint              = new DataPoint(DateTimeAxis.ToDouble(date.Date), (double)price * (buying ? 0.99 : 1.01)),
                HeadLength              = 3,
                HeadWidth               = 3
            };

            return(annotation);
        }
Example #22
0
 public override AnnotationBase AnnotateSlides()
 {
     withGuid        = true;
     arrowAnnotation = InitAnnotationBase(arrowAnnotation) as ArrowAnnotation;
     return(arrowAnnotation);
 }
Example #23
0
 public override AnnotationBase AnnotateWord()
 {
     withGuid        = false;
     arrowAnnotation = InitAnnotationBase(arrowAnnotation) as ArrowAnnotation;
     return(arrowAnnotation);
 }
        private PlotModel PlotRotation()
        {
            var pm = new PlotModel() { Title = "Projection Model" };
            ArrowAnnotation arrow = null;
            var xAxis = X();
            var yAxis = Y();
            pm.Axes.Add(xAxis);
            pm.Axes.Add(yAxis);

            var shape = new LineSeries();
            foreach(var d in _model.Projection.OriginalPoints())
            {
                shape.Points.Add(d);
            }
            pm.Series.Add(shape);

            pm.MouseDown += (s, e) =>
            {
                arrow = new ArrowAnnotation();
                arrow.StartPoint = arrow.EndPoint = Axis.InverseTransform(e.Position, xAxis, yAxis);
                DX = arrow.StartPoint.X;
                DY = arrow.StartPoint.Y;
                shape.Points.Clear();
                foreach (var d in _model.Projection.TransformedPoints())
                {
                    shape.Points.Add(d);
                }
                pm.Annotations.Add(arrow);
                pm.InvalidatePlot(true);
                e.Handled = true;
            };

            pm.MouseMove += (s, e) =>
            {
                if(arrow != null)
                {
                    arrow.EndPoint = Axis.InverseTransform(e.Position, xAxis, yAxis);
                    var dy = arrow.EndPoint.Y - arrow.StartPoint.Y;
                    var dx = arrow.EndPoint.X - arrow.StartPoint.X;
                    Theta = Math.Atan2(-dy, dx);
                    shape.Points.Clear();
                    foreach (var d in _model.Projection.TransformedPoints())
                    {
                        shape.Points.Add(d);
                    }
                    pm.InvalidatePlot(true);
                    e.Handled = true;
                }

            };

            pm.MouseUp += (s, e) =>
            {
                pm.Annotations.Clear();
                arrow = null;
            };

            return pm;
        }
        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);
            }
        }
Example #26
0
        /// <summary>
        /// Creates an annotation with an arrow pointing at the trade.
        /// </summary>
        /// <param name="date">The date of the trade</param>
        /// <param name="price">The price</param>
        /// <param name="quantity">The quantity</param>
        /// <param name="showSize">Should the annotation text include the quantity traded or not?</param>
        /// <returns></returns>
        private static ArrowAnnotation CreateAnnotation(DateTime date, decimal price, decimal quantity, bool showSize)
        {
            string annotationFormat = showSize ? "{0:+#;-#}\n{1:0.00}" : "{1:0.00}";
            bool buying = quantity > 0;

            var annotation = new ArrowAnnotation
            {
                Text = string.Format(annotationFormat, quantity, price),
                TextPosition = new DataPoint(DateTimeAxis.ToDouble(date), (double)price * (buying ? 0.985 : 1.015)),
                TextHorizontalAlignment = OxyPlot.HorizontalAlignment.Center,
                TextVerticalAlignment = buying ? OxyPlot.VerticalAlignment.Top : OxyPlot.VerticalAlignment.Bottom,
                Font = "Segoe UI",
                TextColor = OxyColor.FromRgb(227, 227, 227),
                Color = buying ? OxyColors.DodgerBlue : OxyColor.FromRgb(222, 222, 222),
                EndPoint = new DataPoint(DateTimeAxis.ToDouble(date.Date), (double)price),
                StartPoint = new DataPoint(DateTimeAxis.ToDouble(date.Date), (double)price * (buying ? 0.99 : 1.01)),
                HeadLength = 3,
                HeadWidth = 3
            };
            return annotation;
        }
Example #27
0
        private void SetAnnotationType()
        {
            Chart1.Annotations.Clear();

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

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

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

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

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

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

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

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

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

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

                annotation.GraphicsPath.AddPolygon(points);

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                annotation.GraphicsPath.AddPolygon(points);

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

                    g.Dispose();

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

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

                Chart1.Annotations.Add(annotation);
            }
        }
Example #28
0
        public static PlotModel ArrowAnnotation()
        {
            var model = new PlotModel { Title = "ArrowAnnotation", Subtitle = "Click and drag the arrow." };
            model.Axes.Add(new LinearAxis { Position = AxisPosition.Bottom, Minimum = -40, Maximum = 60 });
            model.Axes.Add(new LinearAxis { Position = AxisPosition.Left, Minimum = -10, Maximum = 10 });

            var arrow = new ArrowAnnotation { StartPoint = new DataPoint(8, 4), EndPoint = new DataPoint(0, 0), Text = "Move me!" };

            var lastPoint = DataPoint.Undefined;
            bool moveStartPoint = false;
            bool moveEndPoint = false;
            var originalColor = OxyColors.White;

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

                lastPoint = arrow.InverseTransform(e.Position);
                moveStartPoint = e.HitTestResult.Index != 2;
                moveEndPoint = e.HitTestResult.Index != 1;
                originalColor = arrow.Color;
                arrow.Color = OxyColors.Red;
                model.InvalidatePlot(false);
                e.Handled = true;
            };

            // Handle mouse movements (note: this is only called when the mousedown event was handled)
            arrow.MouseMove += (s, e) =>
                {
                    var thisPoint = arrow.InverseTransform(e.Position);
                    double dx = thisPoint.X - lastPoint.X;
                    double dy = thisPoint.Y - lastPoint.Y;
                    if (moveStartPoint)
                    {
                        arrow.StartPoint = new DataPoint(arrow.StartPoint.X + dx, arrow.StartPoint.Y + dy);
                    }

                    if (moveEndPoint)
                    {
                        arrow.EndPoint = new DataPoint(arrow.EndPoint.X + dx, arrow.EndPoint.Y + dy);
                    }

                    lastPoint = thisPoint;
                    model.InvalidatePlot(false);
                    e.Handled = true;
                };

            // Handle mouse up (note: this is only called when the mousedown event was handled)
            arrow.MouseUp += (s, e) =>
            {
                arrow.Color = originalColor;
            };
            model.Annotations.Add(arrow);
            return model;
        }
Example #29
0
        public IDDPlotBiasMeasHistory()
        {
            InitializeComponent();
            Integ.GetCurrentAcquireDetectorPair(ref ap, ref det);
            Text    += " for detector " + det.Id.DetectorName;
            norm     = N.App.DB.NormParameters.Get(det);
            normlist = new NormList();
            if ((norm.biasMode == NormTest.AmLiSingles) || (norm.biasMode == NormTest.Collar))
            {
                normlist.RefDoubles[0]         = normlist.RefDoubles[1] = norm.amliRefSinglesRate;
                normlist.RefDoublesPlusErr[0]  = normlist.RefDoublesPlusErr[1] = norm.amliRefSinglesRate;
                normlist.RefDoublesMinusErr[0] = normlist.RefDoublesMinusErr[1] = norm.amliRefSinglesRate;
            }
            else
            {
                normlist.RefDoubles[0]         = normlist.RefDoubles[1] = norm.cf252RefDoublesRate.v;
                normlist.RefDoublesPlusErr[0]  = normlist.RefDoublesPlusErr[1] = norm.cf252RefDoublesRate.v + norm.cf252RefDoublesRate.err;
                normlist.RefDoublesMinusErr[0] = normlist.RefDoublesMinusErr[1] = norm.cf252RefDoublesRate.v - norm.cf252RefDoublesRate.err;
            }
            irlist = N.App.DB.IndexedResultsFor(det.Id.DetectorId, "normalization", "All");
            if (irlist.Count < 1)
            {
                return;
            }
            irlist.Sort((r1, r2) => // sort chronologically
            {
                return(DateTimeOffset.Compare(r1.DateTime, r2.DateTime));
            });

            if (norm.biasMode != NormTest.Cf252Doubles)
            {
                chart1.Titles[1].Text = "Singles Rate";
            }

            // get the mult results with the singles/doubles
            normlist.RefNumber = irlist.Count;
            List <INCCResults.results_rec> mlist = new List <INCCResults.results_rec>();

            foreach (INCCDB.IndexedResults ir in irlist)
            {
                mlist.Add(N.App.DB.ResultsRecFor(ir.Mid));
            }

            // now create the list of norm points
            int num = 0;

            foreach (INCCResults.results_rec res in mlist)
            {
                NormValues nv = new NormValues(res.acq.MeasDateTime);
                nv.test = norm.biasMode;
                if (norm.biasMode == NormTest.Cf252Doubles)
                {
                    nv.Doubles         = res.mcr.DeadtimeCorrectedDoublesRate.v;
                    nv.DoublesPlusErr  = res.mcr.DeadtimeCorrectedDoublesRate.v + res.mcr.DeadtimeCorrectedDoublesRate.err;
                    nv.DoublesMinusErr = res.mcr.DeadtimeCorrectedDoublesRate.v - res.mcr.DeadtimeCorrectedDoublesRate.err;
                    normlist.Add(nv);
                }
                else
                {
                    nv.Doubles         = res.mcr.DeadtimeCorrectedSinglesRate.v;
                    nv.DoublesPlusErr  = res.mcr.DeadtimeCorrectedSinglesRate.v + res.mcr.DeadtimeCorrectedSinglesRate.err;
                    nv.DoublesMinusErr = res.mcr.DeadtimeCorrectedSinglesRate.v - res.mcr.DeadtimeCorrectedSinglesRate.err;
                    normlist.Add(nv);
                }
                if (nv.DoublesPlusErr > normlist.MaxDoubles)
                {
                    normlist.MaxDoubles = nv.DoublesPlusErr;
                }
                if (nv.DoublesMinusErr < normlist.MinDoubles)
                {
                    normlist.MinDoubles = nv.DoublesMinusErr;
                }
                nv.number = ++num;
            }
            normlist.CalcLowerUpper();

            Series s = chart1.Series["Vals"];

            // Set error bar upper & lower error style
            s["ErrorBarStyle"]             = "Both";
            s["ErrorBarCenterMarkerStyle"] = "Circle";

            // Set error bar center marker style
            s.MarkerStyle = MarkerStyle.None;
            s.MarkerColor = System.Drawing.Color.DarkViolet;

            int             imax  = 0;
            ArrowAnnotation maxpt = new ArrowAnnotation();

            maxpt.Name          = "max";
            maxpt.Height        = -5;
            maxpt.Width         = 0;
            maxpt.AnchorOffsetY = -2.5;
            foreach (NormValues n in normlist)
            {
                int i = s.Points.AddXY(n.number, n.Doubles, n.DoublesMinusErr, n.DoublesPlusErr);
                if (n.DoublesPlusErr == normlist.MaxDoubles)
                {
                    imax          = i;
                    maxpt.ToolTip = "Max " + n.ToString();
                }
                s.Points[i].ToolTip = n.ToString();
            }
            chart1.Annotations.Add(maxpt);
            if (s.Points.Count > 0)
            {
                maxpt.AnchorDataPoint = s.Points[imax];
            }
        }
Example #30
0
        public Ball(OxyColor color, LineStyle ls, string name = "ball")
        {
            Name     = name;
            AnnotPos = new EllipseAnnotation()
            {
                ToolTip = name,
                Width   = 1,
                Height  = 1,
                Fill    = color
            };
            AnnotVel = new ArrowAnnotation()
            {
                Color = color,
                Text  = "V = 0"
            };
            SerPos = new LineSeries()
            {
                Color           = color,
                StrokeThickness = 1,
                Title           = $"[{name}]X, m",
                LineStyle       = LineStyle.Dash
            };

            SerX = new LineSeries()
            {
                Color           = OxyColors.Green,
                StrokeThickness = 2,
                Title           = $"[{name}]X, m"
            };
            SerY = new LineSeries()
            {
                Color           = OxyColors.Blue,
                StrokeThickness = 2,
                Title           = $"[{name}]Y, m",
                LineStyle       = ls
            };
            SerV = new LineSeries()
            {
                Color           = OxyColors.DarkOrange,
                StrokeThickness = 2,
                Title           = $"[{name}]V, m/s",
                LineStyle       = ls
            };
            SerP = new LineSeries()
            {
                Color           = OxyColors.DarkViolet,
                StrokeThickness = 2,
                Title           = $"[{name}]p, m*s",
                LineStyle       = ls
            };
            SerE = new LineSeries()
            {
                Color           = OxyColors.Green,
                StrokeThickness = 2,
                Title           = $"[{name}]E, Дж",
                LineStyle       = ls
            };
            SerAll = new List <LineSeries>();
            SerAll.Add(SerX);
            SerAll.Add(SerY);
            SerAll.Add(SerV);
            //SerAll.Add(SerP);
            //SerAll.Add(SerE);
        }
        /// <summary>
        /// Function that draws or clears the annotation for the element surface channel position.
        /// </summary>
        public void UpdateElementPositions()
        {
            if (ShowElementPositions == true)
            {
                var yAxis = MeasurementsPlotModel.Axes.FirstOrDefault(x => x.Position == AxisPosition.Left);
                var xAxis = MeasurementsPlotModel.Axes.FirstOrDefault(x => x.Position == AxisPosition.Bottom);

                double currentPixelPerXAxisUnit = MeasurementsPlotModel.PlotArea.Width / (xAxis.ActualMaximum - xAxis.ActualMinimum);
                double currentPixelPerYAxisUnit = MeasurementsPlotModel.PlotArea.Height / (yAxis.ActualMaximum - yAxis.ActualMinimum);

                double currentMax = yAxis.ActualMaximum;

                using (DatabaseDataContext Database = MyGlobals.Database)
                {
                    Measurement measurement = Database.Measurements.FirstOrDefault(x => MeasurementIDList.Contains(x.MeasurementID));
                    double lastXPosition = 0;

                    var elements = Database.Isotopes
                        .Where(x => x.MassNumber == 0)
                        .ToList()
                        .Select(x => new { ElementName = x.Element.ShortName, ElementEnergy = measurement.IncomingIonEnergy * MyGlobals.KineFak(measurement.Isotope.Mass, x.Mass, measurement.OutcomingIonAngle) })
                        .OrderBy(x => x.ElementEnergy);

                    foreach (var element in elements)
                    {
                        ArrowAnnotation arrowAnnotation = new ArrowAnnotation
                        {
                            StartPoint = new DataPoint(element.ElementEnergy, currentMax - 20 / currentPixelPerYAxisUnit),
                            EndPoint = new DataPoint(element.ElementEnergy, currentMax - 40 / currentPixelPerYAxisUnit),
                            HeadLength = 5,
                            HeadWidth = 2,
                            Color = OxyColor.FromHsv(0.7, 0.3, 1),
                            Layer = AnnotationLayer.BelowSeries,
                        };

                        if (element.ElementEnergy * currentPixelPerXAxisUnit > lastXPosition + 20)
                        {
                            arrowAnnotation.Text = element.ElementName;
                            arrowAnnotation.Color = OxyColor.FromHsv(0.7, 1, 1);
                            arrowAnnotation.Layer = AnnotationLayer.AboveSeries;
                            lastXPosition = element.ElementEnergy * currentPixelPerXAxisUnit;
                        }
                        MeasurementsPlotModel.Annotations.Add(arrowAnnotation);
                    }
                }
                MeasurementsPlotModel.IsLegendVisible = false;
            }
            else
            {
                MeasurementsPlotModel.Annotations.Clear();
                MeasurementsPlotModel.IsLegendVisible = true;
            }
            MeasurementsPlotModel.InvalidatePlot(true);
        }
Example #32
0
        private bool update_arrow(double mass) //更新箭头
        {
            if (this.MS2_help_denovol.arrow_mass.Count == 0)
            {
                return(true);
            }
            const double mass_error = 0.01;
            bool         isIn       = false;

            for (int i = 0; i < this.MS2_help_denovol.arrow_mass.Count; ++i)
            {
                if (Math.Abs(this.MS2_help_denovol.arrow_mass[i] - mass) <= mass_error)
                {
                    isIn = true;
                    break;
                }
            }
            if (!isIn)
            {
                return(false);
            }
            for (int i = 0; i < this.MS2_help_denovol.arrow_mass.Count; ++i)
            {
                if (Math.Abs(this.MS2_help_denovol.arrow_mass[i] - mass) <= mass_error)
                {
                    continue;
                }
                ((LineSeries)this.MS2_help_denovol.all_series[(int)this.double_to_index[(int)(this.MS2_help_denovol.arrow_mass[i] * 100)]]).Color = OxyColors.Transparent;
            }
            for (int i = 0; i < this.MS2_help_denovol.arrow_annotation_last.Count; i += 2)
            {
                ArrowAnnotation arrowAnn     = this.MS2_help_denovol.arrow_annotation_last[i] as ArrowAnnotation;
                TextAnnotation  txtAnn       = this.MS2_help_denovol.arrow_annotation_last[i + 1] as TextAnnotation;
                ArrowAnnotation new_arrowAnn = new ArrowAnnotation();
                TextAnnotation  new_txtAnn   = new TextAnnotation();
                new_arrowAnn.HeadLength = arrowAnn.HeadLength;
                new_arrowAnn.HeadWidth  = arrowAnn.HeadWidth;
                new_arrowAnn.Color      = arrowAnn.Color;
                new_txtAnn.Text         = txtAnn.Text;
                new_txtAnn.Stroke       = txtAnn.Stroke;
                new_txtAnn.TextColor    = txtAnn.TextColor;
                if (Math.Abs(arrowAnn.EndPoint.X - mass) <= mass_error) //K==Q,出现两个字母重叠
                {
                    new_arrowAnn.StartPoint = new DataPoint(arrowAnn.StartPoint.X, arrow_Y);
                    new_arrowAnn.EndPoint   = new DataPoint(arrowAnn.EndPoint.X, arrow_Y);
                    new_arrowAnn.LineStyle  = LineStyle.Solid;
                    new_txtAnn.Position     = new DataPoint(txtAnn.Position.X, arrow_Y);
                    if (this.MS2_help_denovol.arrowMass_to_index[(int)(arrowAnn.EndPoint.X * 100)] == null)
                    {
                        this.MS2_help_denovol.all_annotation.Add(new_arrowAnn);
                        this.MS2_help_denovol.all_annotation.Add(new_txtAnn);
                        this.MS2_help_denovol.arrowMass_to_index[(int)(arrowAnn.EndPoint.X * 100)] = this.MS2_help_denovol.all_annotation.Count - 1;
                    }
                    else
                    {
                        int index = (int)this.MS2_help_denovol.arrowMass_to_index[(int)(arrowAnn.EndPoint.X * 100)];
                        ((TextAnnotation)this.MS2_help_denovol.all_annotation[index]).Text += "/" + txtAnn.Text;
                    }
                }
            }
            return(true);
        }
Example #33
0
        public static PlotModel ArrowAnnotation()
        {
            var model = new PlotModel {
                Title = "ArrowAnnotation", Subtitle = "Click and drag the arrow."
            };

            model.Axes.Add(new LinearAxis {
                Position = AxisPosition.Bottom, Minimum = -40, Maximum = 60
            });
            model.Axes.Add(new LinearAxis {
                Position = AxisPosition.Left, Minimum = -10, Maximum = 10
            });

            var arrow = new ArrowAnnotation {
                StartPoint = new DataPoint(8, 4), EndPoint = new DataPoint(0, 0), Text = "Move me!"
            };

            var  lastPoint      = DataPoint.Undefined;
            bool moveStartPoint = false;
            bool moveEndPoint   = false;
            var  originalColor  = OxyColors.White;

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

                lastPoint      = arrow.InverseTransform(e.Position);
                moveStartPoint = e.HitTestResult.Index != 2;
                moveEndPoint   = e.HitTestResult.Index != 1;
                originalColor  = arrow.Color;
                arrow.Color    = OxyColors.Red;
                model.InvalidatePlot(false);
                e.Handled = true;
            };

            // Handle mouse movements (note: this is only called when the mousedown event was handled)
            arrow.MouseMove += (s, e) =>
            {
                var    thisPoint = arrow.InverseTransform(e.Position);
                double dx        = thisPoint.X - lastPoint.X;
                double dy        = thisPoint.Y - lastPoint.Y;
                if (moveStartPoint)
                {
                    arrow.StartPoint = new DataPoint(arrow.StartPoint.X + dx, arrow.StartPoint.Y + dy);
                }

                if (moveEndPoint)
                {
                    arrow.EndPoint = new DataPoint(arrow.EndPoint.X + dx, arrow.EndPoint.Y + dy);
                }

                lastPoint = thisPoint;
                model.InvalidatePlot(false);
                e.Handled = true;
            };

            // Handle mouse up (note: this is only called when the mousedown event was handled)
            arrow.MouseUp += (s, e) =>
            {
                arrow.Color = originalColor;
            };
            model.Annotations.Add(arrow);
            return(model);
        }
Example #34
0
        /// <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();
            }
        }
Example #35
0
        private void Annotation_SelectedIndexChanged(object sender, System.EventArgs e)
        {
            Chart1.Annotations.Clear();

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

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

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

                Chart1.Annotations.Add(annotation);

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

                Chart1.Annotations.Add(annotation);

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

                Chart1.Annotations.Add(annotation);

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

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

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

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

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

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

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

                annotation.GraphicsPath.AddPolygon(points);

                Chart1.Annotations.Add(annotation);

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

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

                Chart1.Annotations.Add(annotation);

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

                Chart1.Annotations.Add(annotation);

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

                Chart1.Annotations.Add(annotation);

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

                Chart1.Annotations.Add(annotation);

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

                Chart1.Annotations.Add(annotation);

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

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

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

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

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

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

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

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

                annotation.GraphicsPath.AddPolygon(points);

                Chart1.Annotations.Add(annotation);

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

                    g.Dispose();

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

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

                Chart1.Annotations.Add(annotation);
                StyleLabel1.Text = "";
                StyleLabel2.Text = "";
            }
        }
        /// <summary>
        /// 根据模型显示箭头
        /// </summary>
        private void makeAnnotation()
        {
            while (this._listOperateArrow.Count > 0)
            {
                OrderItem pOperation = this._listOperateArrow[0];
                int       idx        = this.chart1.Series[0].Points.IndexOf(this.chart1.Series[0].Points.FindByValue(pOperation.Date.ToOADate(), "X"));
                if (idx < 0)
                {
                    break;
                }

                ArrowAnnotation arrow = new ArrowAnnotation();
                //arrow.Tag = pOperation.owner;		//标记策略

                arrow.AxisX = this.chart1.ChartAreas[0].AxisX;
                arrow.AxisY = this.chart1.ChartAreas[0].AxisY;
                //arrow.AnchorDataPoint = this.chart1.Series[0].Points.FindByValue(operation.D.ToOADate(), "X");
                arrow.ClipToChartArea      = this.chart1.ChartAreas[0].Name;                                                                                                                                             //防止线出界
                arrow.ArrowSize            = 2;                                                                                                                                                                          // (int)Math.Ceiling(this.chart1.Width / (this.chart1.ChartAreas[0].AxisX.ScaleView.ViewMaximum - this.chart1.ChartAreas[0].AxisX.ScaleView.ViewMinimum));							//在prepost中进行更改
                arrow.ArrowStyle           = ArrowStyle.Simple;                                                                                                                                                          //.Tailed;			//双尾箭头
                arrow.LineWidth            = 0;                                                                                                                                                                          //不显示边线
                arrow.BackColor            = ((pOperation.Dir == Direction.Buy && pOperation.Offset == Offset.Open) || (pOperation.Dir == Direction.Sell && pOperation.Offset != Offset.Open)) ? Color.Red : Color.Blue; //填充颜色
                arrow.IsSizeAlwaysRelative = true;                                                                                                                                                                       //使用绝对值控制下面的高/宽
                arrow.Width   = 0;
                arrow.X       = idx + 1;                                                                                                                                                                                 //坐标是从1开始的
                arrow.ToolTip = _stra.Name + ":" +
                                (pOperation.Dir == Direction.Buy ? "买" : "卖") + (pOperation.Offset == Offset.Open ? "开" : "平") + pOperation.Lots + "@" + pOperation.Price.ToString("F2");

                arrow.Y = (double)pOperation.Price;
                if (pOperation.Dir == Direction.Sell)
                {
                    arrow.Height = -3;// 6 * priceTick;									//在prepost中进行更改:但要保持符号一致
                }
                else
                {
                    arrow.Height = 3;// -6 * priceTick;									//在prepost中进行更改:但要保持符号一致
                }
                this._listOperateArrow.RemoveAt(0);

                _listAnnotation.Add(arrow);

                _listOperationLine.Add(pOperation);
            }

            for (int i = 0; i < this._listOperationLine.Count; i++)
            {
                OrderItem pOperation = this._listOperationLine[i];
                int       idx        = this.chart1.Series[0].Points.IndexOf(this.chart1.Series[0].Points.FindByValue(pOperation.Date.ToOADate(), "X"));
                if (idx < 0)
                {
                    break;
                }

                int lotsClosedClose = _dicLotsClosedOfOrder.GetOrAdd(pOperation, 0);
                if (pOperation.Offset != Offset.Open)
                {
                    for (int j = 0; j < i; j++)
                    {
                        var open           = _listOperationLine[j];
                        int lotsClosedOpen = _dicLotsClosedOfOrder.GetOrAdd(open, 0);
                        if (open.Offset == Offset.Open && open.Dir != pOperation.Dir && lotsClosedOpen < open.Lots)
                        {
                            //找对应的开仓K线
                            LineAnnotation line = new LineAnnotation();
                            //line.Tag = pOperation.owner;	//标识对应的策略

                            //修改已平手数
                            int volume = Math.Min(open.Lots - lotsClosedOpen, pOperation.Lots - lotsClosedClose);
                            lotsClosedOpen += volume;
                            _dicLotsClosedOfOrder[open]       = lotsClosedOpen;
                            lotsClosedClose                  += volume;
                            _dicLotsClosedOfOrder[pOperation] = lotsClosedClose;

                            int idxOpen = this.chart1.Series[0].Points.IndexOf(this.chart1.Series[0].Points.FindByValue(open.Date.ToOADate(), "X"));
                            line.IsSizeAlwaysRelative = false;
                            line.LineDashStyle        = ChartDashStyle.Dash;
                            line.AxisX           = this.chart1.ChartAreas[0].AxisX;
                            line.AxisY           = this.chart1.ChartAreas[0].AxisY;
                            line.ClipToChartArea = this.chart1.ChartAreas[0].Name;                                                                                   //防止线出界
                                                                                                                                                                     //line.AnchorDataPoint = this.seriesK.Points[order.BarIndex];
                            line.LineWidth = 1;
                            line.LineColor = (pOperation.Price - open.Price) * (pOperation.Dir == Direction.Sell ? 1 : -1) > 0 ? Color.IndianRed : Color.MediumBlue; //盈利:红,亏损:蓝
                                                                                                                                                                     //line.StartCap = LineAnchorCapStyle.None;//.Arrow;
                                                                                                                                                                     //line.EndCap = LineAnchorCapStyle.None;//.Arrow;
                            line.Width  = idx - idxOpen;
                            line.X      = idxOpen + 1;                                                                                                               //坐标是从1开始的
                            line.Y      = (double)open.Price;
                            line.Height = (double)(pOperation.Price - open.Price);
                            //this.chart1.Annotations.Add(line);
                            _listAnnotation.Add(line);

                            if (lotsClosedOpen == open.Lots) //开仓全部平掉
                            {
                                _listOperationLine.Remove(open);
                                j--;
                            }
                            if (lotsClosedClose == pOperation.Lots) //平仓全部处理
                            {
                                _listOperationLine.Remove(pOperation);
                                i--;
                                break;
                            }
                        }
                    }
                }
            }
        }
Example #37
0
        private void AnnotationStyle1_SelectedIndexChanged(object sender, System.EventArgs e)
        {
            if (Annotation.SelectedItem.ToString() == "Line")
            {
                LineAnnotation annotation = (LineAnnotation)Chart1.Annotations[0];

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

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

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

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

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

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

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

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

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

                annotation.LineColor = Color.FromName(AnnotationStyle1.SelectedItem.ToString());
            }
        }
 public void ArrowAnnotation()
 {
     var s1 = new ArrowAnnotation();
     var s2 = new Annotations.ArrowAnnotation();
     OxyAssert.PropertiesAreEqual(s1, s2);
 }