Esempio n. 1
0
        private void OnModelOnMouseDown(object s, OxyMouseDownEventArgs e)
        {
            if (e.ChangedButton == OxyMouseButton.Left)
            {
                DisplaySelection();

                _startx         = _range.InverseTransform(e.Position).X;
                _range.MinimumX = _startx;
                _range.MaximumX = _startx;
                _model.InvalidatePlot(true);
                e.Handled = true;
            }
        }
Esempio n. 2
0
        public static PlotModel SelectRange()
        {
            var model = new PlotModel {
                Title = "Select range", Subtitle = "Left click and drag to select a range."
            };

            model.Series.Add(new FunctionSeries(Math.Cos, 0, 40, 0.1));

            var range = new RectangleAnnotation {
                Fill = OxyColor.FromAColor(120, OxyColors.SkyBlue), MinimumX = 0, MaximumX = 0
            };

            model.Annotations.Add(range);

            double startx = double.NaN;

            model.MouseDown += (s, e) =>
            {
                if (e.ChangedButton == OxyMouseButton.Left)
                {
                    startx         = range.InverseTransform(e.Position).X;
                    range.MinimumX = startx;
                    range.MaximumX = startx;
                    model.InvalidatePlot(true);
                    e.Handled = true;
                }
            };
            model.MouseMove += (s, e) =>
            {
                if (!double.IsNaN(startx))
                {
                    var x = range.InverseTransform(e.Position).X;
                    range.MinimumX = Math.Min(x, startx);
                    range.MaximumX = Math.Max(x, startx);
                    range.Text     = string.Format("∫ cos(x) dx =  {0:0.00}", Math.Sin(range.MaximumX) - Math.Sin(range.MinimumX));
                    model.Subtitle = string.Format("Integrating from {0:0.00} to {1:0.00}", range.MinimumX, range.MaximumX);
                    model.InvalidatePlot(true);
                    e.Handled = true;
                }
            };

            model.MouseUp += (s, e) =>
            {
                startx = double.NaN;
            };

            return(model);
        }
Esempio n. 3
0
        public static PlotModel SelectRange()
        {
            var model = new PlotModel { Title = "Select range", Subtitle = "Left click and drag to select a range." };
            model.Series.Add(new FunctionSeries(Math.Cos, 0, 40, 0.1));

            var range = new RectangleAnnotation { Fill = OxyColor.FromAColor(120, OxyColors.SkyBlue), MinimumX = 0, MaximumX = 0 };
            model.Annotations.Add(range);

            double startx = double.NaN;

            model.MouseDown += (s, e) =>
            {
                if (e.ChangedButton == OxyMouseButton.Left)
                {
                    startx = range.InverseTransform(e.Position).X;
                    range.MinimumX = startx;
                    range.MaximumX = startx;
                    model.InvalidatePlot(true);
                    e.Handled = true;
                }
            };
            model.MouseMove += (s, e) =>
                {
                    if (!double.IsNaN(startx))
                    {
                        var x = range.InverseTransform(e.Position).X;
                        range.MinimumX = Math.Min(x, startx);
                        range.MaximumX = Math.Max(x, startx);
                        range.Text = string.Format("∫ cos(x) dx =  {0:0.00}", Math.Sin(range.MaximumX) - Math.Sin(range.MinimumX));
                        model.Subtitle = string.Format("Integrating from {0:0.00} to {1:0.00}", range.MinimumX, range.MaximumX);
                        model.InvalidatePlot(true);
                        e.Handled = true;
                    }
                };

            model.MouseUp += (s, e) =>
            {
                startx = double.NaN;
            };

            return model;
        }