Example #1
0
        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            spark = (SparkWindow)this.Owner;
            if (graphSetting == null)
            {
                graphSetting = spark.settingCommon.graphSetting;
            }
            DirectoryInfo folder = new DirectoryInfo(Core.Work.EnvPath);

            FileInfo[] files     = folder.GetFiles("*.sqlite");
            string[]   filesName = new string[files.Length];
            for (int i = 0; i < files.Length; i++)
            {
                filesName[i] = Path.GetFileNameWithoutExtension(files[i].FullName);
            }
            lbDataBases.ItemsSource = filesName;
            timerEmul.Elapsed      += TimerEmul_Elapsed;

            var controller = new PlotController();

            controller.UnbindAll();
            controller.BindMouseDown(OxyMouseButton.Left, PlotCommands.PanAt);
            controller.BindMouseDown(OxyMouseButton.Left, OxyModifierKeys.Control, PlotCommands.ZoomRectangle);
            controller.BindMouseDown(OxyMouseButton.Left, OxyModifierKeys.Alt, PlotCommands.PointsOnlyTrack);
            controller.BindMouseWheel(PlotCommands.ZoomWheel);
            controller.BindKeyDown(OxyKey.R, PlotCommands.Reset);
            plotter.Controller = controller;
        }
Example #2
0
        public PlotViewCustomZoom() : base()
        {
            Controller = new PlotController();

            var zoomWheel = new DelegatePlotCommand <OxyMouseWheelEventArgs>((view, controller, args) => HandleZoomByWheel(view, args));

            Controller.BindMouseWheel(OxyModifierKeys.None, zoomWheel);

            var zoomWheelCtrl = new DelegatePlotCommand <OxyMouseWheelEventArgs>((view, controller, args) => HandleZoomByWheelAndCtrl(view, args));

            Controller.BindMouseWheel(OxyModifierKeys.Control, zoomWheelCtrl);

            var zoomWheelShift = new DelegatePlotCommand <OxyMouseWheelEventArgs>((view, controller, args) => HandleZoomByWheelAndShift(view, args));

            Controller.BindMouseWheel(OxyModifierKeys.Shift, zoomWheelShift);

            var customPanAt = new DelegatePlotCommand <OxyMouseDownEventArgs>((view, controller, args) => controller.AddMouseManipulator(view, new CustomPanManipulator(view, EAxisDescription.XY), args));

            Controller.BindMouseDown(OxyMouseButton.Right, OxyModifierKeys.None, customPanAt);

            var customPanAtCtrl = new DelegatePlotCommand <OxyMouseDownEventArgs>((view, controller, args) => controller.AddMouseManipulator(view, new CustomPanManipulator(view, EAxisDescription.Y), args));

            Controller.BindMouseDown(OxyMouseButton.Right, OxyModifierKeys.Control, customPanAtCtrl);

            var customPanAtShift = new DelegatePlotCommand <OxyMouseDownEventArgs>((view, controller, args) => controller.AddMouseManipulator(view, new CustomPanManipulator(view, EAxisDescription.X), args));

            Controller.BindMouseDown(OxyMouseButton.Right, OxyModifierKeys.Shift, customPanAtShift);

            MouseDoubleClick += new MouseButtonEventHandler(OnMouseDoubleClick);
        }
Example #3
0
        public MainWindow() : base(Gtk.WindowType.Toplevel)
        {
            Build();

            DateStartEntry.Text   = Fetcher.StartAt.ToString(DateStringFormat);
            DateStartEntry.Xalign = 0.5F;
            DateEndEntry.Text     = Fetcher.EndAt.ToString(DateStringFormat);
            DateEndEntry.Xalign   = 0.5F;

            foreach (Currencies currency in Enum.GetValues(typeof(Currencies)))
            {
                CurrencyBaseSelection.AppendText(currency.ToString() + " - " + currency.GetStringValue());
            }
            CurrencyBaseSelection.Active = (int)Fetcher.Base;

            MainPlotController.UnbindKeyDown(OxyKey.A);
            MainPlotController.BindMouseDown(OxyMouseButton.Left, PlotCommands.PanAt);
            MainPlotController.BindMouseDown(OxyMouseButton.Right, PlotCommands.PointsOnlyTrack);
            MainPlotController.BindKeyDown(OxyKey.Add, PlotCommands.ZoomInFine);
            MainPlotController.BindKeyDown(OxyKey.Subtract, PlotCommands.ZoomOutFine);
            MainPlotController.BindKeyDown(OxyKey.Up, PlotCommands.PanDownFine);
            MainPlotController.BindKeyDown(OxyKey.W, PlotCommands.PanDown);
            MainPlotController.BindKeyDown(OxyKey.Down, PlotCommands.PanUpFine);
            MainPlotController.BindKeyDown(OxyKey.S, PlotCommands.PanUp);
            MainPlotController.BindKeyDown(OxyKey.Left, PlotCommands.PanRightFine);
            MainPlotController.BindKeyDown(OxyKey.A, PlotCommands.PanRight);
            MainPlotController.BindKeyDown(OxyKey.Right, PlotCommands.PanLeftFine);
            MainPlotController.BindKeyDown(OxyKey.D, PlotCommands.PanLeft);

            MainPlotModel = new PlotModel();
            MainPlotModel.Axes.Add(new DateTimeAxis
            {
                Position           = AxisPosition.Bottom,
                IntervalType       = DateTimeIntervalType.Days,
                StringFormat       = "dd-MM\nyyyy",
                MajorGridlineStyle = LineStyle.Solid,
                MinimumMajorStep   = 1
            });
            MainPlotModel.Axes.Add(new LinearAxis
            {
                Position           = AxisPosition.Left,
                MajorGridlineStyle = LineStyle.Solid,
                MinorGridlineStyle = LineStyle.Dot,
                TickStyle          = TickStyle.Outside
            });

            MainPlotView = new PlotView {
                Model = MainPlotModel, Controller = MainPlotController
            };
            MainPlotAlignment.Add(MainPlotView);
            MainPlotView.Show();

            ChangeStatus(ReadyStatusText);
        }
Example #4
0
        private void InitGraph()
        {
            Model = new PlotModel();
            DateTimeAxis axisX = new DateTimeAxis()
            {
                Title        = "Время",
                Position     = AxisPosition.Bottom,
                StringFormat = "HH:mm:ss",
            };

            axisX.MajorGridlineStyle     = LineStyle.Solid;
            axisX.MajorGridlineThickness = 1;
            Model.Axes.Add(axisX);

            int pos = 0;

            foreach (DataParam param in DataParams)
            {
                LinearAxis axisY = new LinearAxis()
                {
                    Title        = param.Title + ", " + param.ParamUnit.Title,
                    Key          = param.Title,
                    Position     = AxisPosition.Left,
                    PositionTier = pos++
                };
                if (pos == 1)
                {
                    axisY.AxisChanged           += AxeY_AxisChanged;
                    axisY.MajorGridlineStyle     = LineStyle.Solid;
                    axisY.MajorGridlineThickness = 1;
                }
                Model.Axes.Add(axisY);
                LineSeries series = new LineSeries()
                {
                    Title    = param.Title,
                    YAxisKey = param.Title
                };
                Model.Series.Add(series);
            }

            var controller = new PlotController();

            controller.UnbindAll();
            controller.BindMouseDown(OxyMouseButton.Left, PlotCommands.PanAt);
            controller.BindMouseDown(OxyMouseButton.Left, OxyModifierKeys.Control, PlotCommands.ZoomRectangle);
            controller.BindMouseDown(OxyMouseButton.Left, OxyModifierKeys.Alt, PlotCommands.PointsOnlyTrack);
            controller.BindMouseWheel(PlotCommands.ZoomWheel);
            controller.BindKeyDown(OxyKey.R, PlotCommands.Reset);
            plotter.Controller = controller;

            plotter.Model = Model;
        }
Example #5
0
        /// <summary>
        /// グラフのマウス操作、キー操作を初期化します。
        /// </summary>
        /// <param name="gestureController">マウス操作のバインド。</param>
        public static void InitializeBind(this PlotController gestureController)
        {
            // グラフのマウス操作およびキー操作の初期化
            gestureController.UnbindKeyDown(OxyKey.A);
            gestureController.UnbindKeyDown(OxyKey.C, OxyModifierKeys.Control);
            gestureController.UnbindKeyDown(OxyKey.C, OxyModifierKeys.Control | OxyModifierKeys.Alt);
            gestureController.UnbindKeyDown(OxyKey.R, OxyModifierKeys.Control | OxyModifierKeys.Alt);
            gestureController.UnbindTouchDown();
            gestureController.UnbindMouseDown(OxyMouseButton.Left);
            gestureController.UnbindMouseDown(OxyMouseButton.Middle);
            gestureController.UnbindMouseDown(OxyMouseButton.Right);

            gestureController.BindMouseDown(OxyMouseButton.Left, PlotCommands.PanAt);
            gestureController.BindMouseDown(OxyMouseButton.Middle, PlotCommands.PointsOnlyTrack);
            gestureController.BindMouseDown(OxyMouseButton.Right, PlotCommands.ZoomRectangle);
        }
        public static Example MouseHandlingExample()
        {
            var model = new PlotModel {
                Title = "Mouse handling example"
            };
            var series = new ScatterSeries();

            model.Series.Add(series);

            // Create a command that adds points to the scatter series
            var command = new DelegatePlotCommand <OxyMouseDownEventArgs>(
                (v, c, a) =>
            {
                a.Handled = true;
                var point = series.InverseTransform(a.Position);
                series.Points.Add(new ScatterPoint(point.X, point.Y));
                model.InvalidatePlot(true);
            });

            var controller = new PlotController();

            controller.BindMouseDown(OxyMouseButton.Left, command);

            return(new Example(model, controller));
        }
Example #7
0
        public SubsequenceViewModel(ObservableCollection <Event> primaryEvents)
        {
            Plot = new PlotModel
            {
                Axes =
                {
                    new DateTimeAxis
                    {
                        Position     = AxisPosition.Top,
                        StringFormat = "HH:mm:ss.FFFFF"
                    },
                    (categoryAxis = new CategoryAxis
                    {
                        Position = AxisPosition.Left
                    })
                },
                Series =
                {
                    (series = new IntervalBarSeries())
                }
            };

            Controller = new PlotController();
            Controller.UnbindMouseDown(OxyMouseButton.Left);
            Controller.BindMouseDown(OxyMouseButton.Left,
                                     new DelegateViewCommand <OxyMouseDownEventArgs>(OnPlotEdit));

            Events = primaryEvents;
            Events.CollectionChanged += (o, e) =>
            {
                RebuildPlotData();
            };

            RebuildPlotData();
        }
Example #8
0
        public static PlotController CreateController()
        {
            var controller = new PlotController();

            controller.UnbindAll();
            controller.BindMouseDown(OxyMouseButton.Left, PlotCommands.PanAt);
            return(controller);
        }
Example #9
0
        private PlotController CreateDefaultController()
        {
            var c = new PlotController();

            c.UnbindMouseDown(OxyMouseButton.Left);
            c.BindMouseDown(OxyMouseButton.Left, PlotCommands.PanAt);
            return(c);
        }
Example #10
0
        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            GS_SPA = (GS_SPAvWindow)this.Owner;
            WorkInfo[] listWork = GS_SPA.Core.Archive.GetListWorks();
            lvArchives.ItemsSource = listWork;

            controller.UnbindAll();
            controller.BindMouseDown(OxyMouseButton.Right, PlotCommands.PanAt);
            controller.BindMouseWheel(PlotCommands.ZoomWheel);
            controller.BindKeyDown(OxyKey.R, PlotCommands.Reset);

            controller.BindMouseDown(OxyMouseButton.Left, new DelegatePlotCommand <OxyMouseDownEventArgs>(
                                         (view, controller, args) =>
                                         controller.AddMouseManipulator(view, new WpbTrackerManipulator(view), args)));

            plotter.Controller = controller;
        }
Example #11
0
        private void BindCommandToPlotViews()
        {
            controller.UnbindAll();
            controller.BindMouseDown(OxyMouseButton.Left, PlotCommands.Track);

            foreCastPlotView.Controller = controller;
            reviewPlotView.Controller   = controller;
            cardTypePlotView.Controller = controller;
        }
Example #12
0
        public static Example LargeDataSetNarrow()
        {
            var pm = new PlotModel {
                Title = "Large Data Set (narrow window)"
            };

            var timeSpanAxis1 = new DateTimeAxis {
                Position = AxisPosition.Bottom
            };

            pm.Axes.Add(timeSpanAxis1);
            var linearAxis1 = new LinearAxis {
                Position = AxisPosition.Left
            };

            pm.Axes.Add(linearAxis1);
            var series = new CandleStickSeries
            {
                Color               = OxyColors.Black,
                IncreasingColor     = OxyColors.DarkGreen,
                DecreasingColor     = OxyColors.Red,
                DataFieldX          = "Time",
                DataFieldHigh       = "H",
                DataFieldLow        = "L",
                DataFieldOpen       = "O",
                DataFieldClose      = "C",
                TrackerFormatString = "High: {2:0.00}\nLow: {3:0.00}\nOpen: {4:0.00}\nClose: {5:0.00}",
            };

            var n = 1000000;

            foreach (var bar in HighLowItemGenerator.MRProcess(n))
            {
                series.Append(bar);
            }

            timeSpanAxis1.Minimum = series.Items[0].X;
            timeSpanAxis1.Maximum = series.Items[29].X;

            linearAxis1.Minimum = series.Items.Take(30).Select(x => x.Low).Min();
            linearAxis1.Maximum = series.Items.Take(30).Select(x => x.High).Max();

            pm.Series.Add(series);

            timeSpanAxis1.AxisChanged += (sender, e) => AdjustYExtent(series, timeSpanAxis1, linearAxis1);

            var controller = new PlotController();

            controller.UnbindAll();
            controller.BindMouseDown(OxyMouseButton.Left, PlotCommands.PanAt);
            return(new Example(pm, controller));
        }
Example #13
0
        private PlotController GetCustomController()
        {
            var myController = new PlotController();

            //  Customizing the bindings
            myController.UnbindMouseDown(OxyMouseButton.Right);
            //Mouse

            myController.BindMouseDown(OxyMouseButton.Left, OxyPlot.PlotCommands.ZoomRectangle);

            myController.BindMouseDown(OxyMouseButton.Right, OxyPlot.PlotCommands.Track);

            //Keyboard

            myController.BindKeyDown(OxyKey.R, OxyPlot.PlotCommands.Reset);

            myController.BindKeyDown(OxyKey.W, OxyPlot.PlotCommands.PanDown);
            myController.BindKeyDown(OxyKey.A, OxyPlot.PlotCommands.PanRight);
            myController.BindKeyDown(OxyKey.S, OxyPlot.PlotCommands.PanUp);
            myController.BindKeyDown(OxyKey.D, OxyPlot.PlotCommands.PanLeft);

            return(myController);
        }
Example #14
0
        public ShellViewModel()
        {
            var model = new PlotModel {
                Title = "Example Tracker"
            };
            var points = new List <DataPoint>
            {
                new DataPoint(0, 4),
                new DataPoint(10, 13),
                new DataPoint(20, 15),
                new DataPoint(30, 16),
                new DataPoint(40, 12),
                new DataPoint(50, 12)
            };
            var seriesVisible = new OxyPlot.Series.LineSeries
            {
                Color               = OxyColors.Blue,
                MarkerFill          = OxyColors.Red,
                ItemsSource         = points,
                TrackerFormatString = "X={2},\nY={4}",
                MarkerType          = MarkerType.Circle,
                MarkerSize          = 5
            };

            model.Axes.Add(new OxyPlot.Axes.LinearAxis
            {
                Position = OxyPlot.Axes.AxisPosition.Bottom
            });

            model.Axes.Add(new OxyPlot.Axes.LinearAxis
            {
                Position = OxyPlot.Axes.AxisPosition.Left
            });
            model.Series.Add(seriesVisible);
            MyModel = model;


            var customController = new PlotController();

            customController.UnbindAll();
            customController.BindMouseDown(OxyMouseButton.Left, new DelegatePlotCommand <OxyMouseDownEventArgs>((view, controller, args) =>
                                                                                                                controller.AddMouseManipulator(view, new StaysOpenTrackerManipulator(view), args)));
            CustomPlotController = customController;
            MyModel.InvalidatePlot(true);
        }
        public static Example BasicExample()
        {
            var model = new PlotModel {
                Title = "Basic Controller example", Subtitle = "Panning with left mouse button"
            };

            model.Axes.Add(new LinearAxis {
                Position = AxisPosition.Bottom
            });
            model.Axes.Add(new LinearAxis {
                Position = AxisPosition.Left
            });
            var controller = new PlotController();

            controller.UnbindAll();
            controller.BindMouseDown(OxyMouseButton.Left, PlotCommands.PanAt);
            return(new Example(model, controller));
        }
Example #16
0
        public static Example SmallDataSet()
        {
            var pm = new PlotModel {
                Title = "Small Data Set"
            };

            var timeSpanAxis1 = new DateTimeAxis {
                Position = AxisPosition.Bottom
            };

            pm.Axes.Add(timeSpanAxis1);
            var linearAxis1 = new LinearAxis {
                Position = AxisPosition.Left
            };

            pm.Axes.Add(linearAxis1);
            var n      = 100;
            var items  = HighLowItemGenerator.MRProcess(n).ToArray();
            var series = new CandleStickSeries
            {
                Color               = OxyColors.Black,
                IncreasingColor     = OxyColors.DarkGreen,
                DecreasingColor     = OxyColors.Red,
                DataFieldX          = "X",
                DataFieldHigh       = "High",
                DataFieldLow        = "Low",
                DataFieldOpen       = "Open",
                DataFieldClose      = "Close",
                TrackerFormatString =
                    "High: {2:0.00}\nLow: {3:0.00}\nOpen: {4:0.00}\nClose: {5:0.00}",
                ItemsSource = items
            };

            pm.Series.Add(series);

            timeSpanAxis1.AxisChanged += (sender, e) => AdjustYExtent(series, timeSpanAxis1, linearAxis1);

            var controller = new PlotController();

            controller.UnbindAll();
            controller.BindMouseDown(OxyMouseButton.Left, PlotCommands.PanAt);
            return(new Example(pm, controller));
        }
Example #17
0
        public static Example TrackerFiresDistance()
        {
            var model = new PlotModel
            {
                Title    = "Specified distance of the tracker fires",
                Subtitle = "Press the left mouse button to test the tracker.",
            };

            model.Series.Add(new FunctionSeries(Math.Sin, 0, 10, 100));

            // create a new plot controller with default bindings
            var plotController = new PlotController();

            // remove a tracker command to the mouse-left/touch down event by default
            plotController.Unbind(PlotCommands.SnapTrack);
            plotController.Unbind(PlotCommands.SnapTrackTouch);

            // add a tracker command to the mouse-left/touch down event with specified distance
            plotController.BindMouseDown(
                OxyMouseButton.Left,
                new DelegatePlotCommand <OxyMouseDownEventArgs>((view, controller, args) =>
                                                                controller.AddMouseManipulator(
                                                                    view,
                                                                    new TrackerManipulator(view)
            {
                Snap       = true,
                PointsOnly = false
            },
                                                                    args)));
            plotController.BindTouchDown(
                new DelegatePlotCommand <OxyTouchEventArgs>((view, controller, args) =>
                                                            controller.AddTouchManipulator(
                                                                view,
                                                                new TouchTrackerManipulator(view)
            {
                Snap       = true,
                PointsOnly = false
            },
                                                                args)));

            return(new Example(model, plotController));
        }
        public DebugParametersTrendViewModel()
        {
            PlotVm = new PlotModel {
                IsLegendVisible = false
            };
            PlotVm.Axes.Add(new DateTimeAxis());
            PlotVm.Axes.Add(new LinearAxis());
            //_plotVm.Series.Add(new FunctionSeries(Math.Cos, 0, 10, 0.1, "cos(x)"));

            PlotCr = new PlotController();
            PlotCr.UnbindAll();
            PlotCr.BindMouseDown(OxyMouseButton.Left, PlotCommands.Track);
            PlotCr.Bind(new OxyMouseDownGesture(OxyMouseButton.Right), PlotCommands.PanAt);
            PlotCr.Bind(new OxyMouseDownGesture(OxyMouseButton.Left), PlotCommands.ZoomRectangle);
            PlotCr.Bind(new OxyMouseEnterGesture(), PlotCommands.HoverPointsOnlyTrack);
            PlotCr.BindMouseWheel(PlotCommands.ZoomWheel);
            PlotCr.BindMouseDown(OxyMouseButton.Left, OxyModifierKeys.None, 2, PlotCommands.ResetAt);

            _points1 = new LineSeries {
                Color = OxyColor.FromRgb(255, 0, 0)
            };
            _points2 = new LineSeries {
                Color = OxyColor.FromRgb(0, 128, 0)
            };
            _points3 = new LineSeries {
                Color = OxyColor.FromRgb(0, 0, 128)
            };
            _points4 = new LineSeries {
                Color = OxyColor.FromRgb(128, 0, 128)
            };

            PlotVm.Series.Add(_points1);
            PlotVm.Series.Add(_points2);
            PlotVm.Series.Add(_points3);
            PlotVm.Series.Add(_points4);

            TrendControlVm1 = new TrendControlViewModel("Параметр 1", this);
            TrendControlVm2 = new TrendControlViewModel("Параметр 2", this);
            TrendControlVm3 = new TrendControlViewModel("Параметр 3", this);
            TrendControlVm4 = new TrendControlViewModel("Параметр 4", this);

            CommandPanLeftFast = new RelayCommand(() =>
            {
                PlotVm.PanAllAxes(PlotVm.PlotArea.Width / 4.0, 0);
                PlotVm.InvalidatePlot(false);
            });

            CommandPanLeft = new RelayCommand(() =>
            {
                PlotVm.PanAllAxes(PlotVm.PlotArea.Width / 20.0, 0);
                PlotVm.InvalidatePlot(false);
            });

            CommandPanRight = new RelayCommand(() =>
            {
                PlotVm.PanAllAxes(PlotVm.PlotArea.Width / -20.0, 0);
                PlotVm.InvalidatePlot(false);
            });

            CommandPanRightFast = new RelayCommand(() =>
            {
                PlotVm.PanAllAxes(PlotVm.PlotArea.Width / -4.0, 0);
                PlotVm.InvalidatePlot(false);
            });

            CommandZoomOut = new RelayCommand(() =>
            {
                PlotVm.ZoomAllAxes(0.8);
                PlotVm.InvalidatePlot(false);
            });

            CommandZoomIn = new RelayCommand(() =>
            {
                PlotVm.ZoomAllAxes(1.25);
                PlotVm.InvalidatePlot(false);
            });

            CommandZoomAll = new RelayCommand(() =>
            {
                PlotVm.ResetAllAxes();
                PlotVm.InvalidatePlot(false);
            });


            CommandPanUpFast = new RelayCommand(() =>
            {
                PlotVm.PanAllAxes(0, PlotVm.PlotArea.Height / 4.0);
                PlotVm.InvalidatePlot(false);
            });

            CommandPanUp = new RelayCommand(() =>
            {
                PlotVm.PanAllAxes(0, PlotVm.PlotArea.Height / 20.0);
                PlotVm.InvalidatePlot(false);
            });

            CommandPanDown = new RelayCommand(() =>
            {
                PlotVm.PanAllAxes(0, PlotVm.PlotArea.Height / -20.0);
                PlotVm.InvalidatePlot(false);
            });

            CommandPanDownFast = new RelayCommand(() =>
            {
                PlotVm.PanAllAxes(0, PlotVm.PlotArea.Height / -4.0);
                PlotVm.InvalidatePlot(false);
            });
        }
Example #19
0
 private PlotController CreateDefaultController()
 {
     var c = new PlotController ();
     c.UnbindMouseDown (OxyMouseButton.Left);
     c.BindMouseDown (OxyMouseButton.Left, PlotCommands.PanAt);
     return c;
 }
Example #20
0
        /// <summary>
        /// Creates the candle stick and volume series example.
        /// </summary>
        /// <returns>The candle stick and volume series example.</returns>
        /// <param name="title">Title.</param>
        /// <param name="style">Style.</param>
        /// <param name="n">N.</param>
        /// <param name="naturalY">If set to <c>true</c> natural y.</param>
        /// <param name="naturalV">If set to <c>true</c> natural v.</param>
        private static Example CreateCandleStickAndVolumeSeriesExample(
            string title,
            VolumeStyle style,
            int n         = 10000,
            bool naturalY = false,
            bool naturalV = false)
        {
            var pm = new PlotModel {
                Title = title
            };

            var series = new CandleStickAndVolumeSeries
            {
                PositiveColor      = OxyColors.DarkGreen,
                NegativeColor      = OxyColors.Red,
                PositiveHollow     = false,
                NegativeHollow     = false,
                SeparatorColor     = OxyColors.Gray,
                SeparatorLineStyle = LineStyle.Dash,
                VolumeStyle        = style
            };

            // create bars
            foreach (var bar in OhlcvItemGenerator.MRProcess(n))
            {
                series.Append(bar);
            }

            // create visible window
            var Istart = n - 200;
            var Iend   = n - 120;
            var Ymin   = series.Items.Skip(Istart).Take(Iend - Istart + 1).Select(x => x.Low).Min();
            var Ymax   = series.Items.Skip(Istart).Take(Iend - Istart + 1).Select(x => x.High).Max();
            var Xmin   = series.Items[Istart].X;
            var Xmax   = series.Items[Iend].X;

            // setup axes
            var timeAxis = new DateTimeAxis
            {
                Position = AxisPosition.Bottom,
                Minimum  = Xmin,
                Maximum  = Xmax
            };
            var barAxis = new LinearAxis
            {
                Position      = AxisPosition.Left,
                Key           = series.BarAxisKey,
                StartPosition = 0.25,
                EndPosition   = 1.0,
                Minimum       = naturalY ? double.NaN : Ymin,
                Maximum       = naturalY ? double.NaN : Ymax
            };
            var volAxis = new LinearAxis
            {
                Position      = AxisPosition.Left,
                Key           = series.VolumeAxisKey,
                StartPosition = 0.0,
                EndPosition   = 0.22,
                Minimum       = naturalV ? double.NaN : 0,
                Maximum       = naturalV ? double.NaN : 5000
            };

            switch (style)
            {
            case VolumeStyle.None:
                barAxis.Key           = null;
                barAxis.StartPosition = 0.0;
                pm.Axes.Add(timeAxis);
                pm.Axes.Add(barAxis);
                break;

            case VolumeStyle.Combined:
            case VolumeStyle.Stacked:
                pm.Axes.Add(timeAxis);
                pm.Axes.Add(barAxis);
                pm.Axes.Add(volAxis);
                break;

            case VolumeStyle.PositiveNegative:
                volAxis.Minimum = naturalV ? double.NaN : -5000;
                pm.Axes.Add(timeAxis);
                pm.Axes.Add(barAxis);
                pm.Axes.Add(volAxis);
                break;
            }

            pm.Series.Add(series);

            if (naturalY == false)
            {
                timeAxis.AxisChanged += (sender, e) => AdjustYExtent(series, timeAxis, barAxis);
            }

            var controller = new PlotController();

            controller.UnbindAll();
            controller.BindMouseDown(OxyMouseButton.Left, PlotCommands.PanAt);
            return(new Example(pm, controller));
        }
Example #21
0
        /// <summary>
        /// Creates the volume series.
        /// </summary>
        /// <returns>The volume series.</returns>
        /// <param name="title">Title.</param>
        /// <param name="style">Style.</param>
        /// <param name="n">N.</param>
        /// <param name="natural">If set to <c>true</c> natural.</param>
        /// <param name="transposed">If set to <c>true</c> transposed.</param>
        private static Example CreateVolumeSeries(
            string title,
            VolumeStyle style,
            int n        = 10000,
            bool natural = false)
        {
            var pm = new PlotModel {
                Title = title
            };

            var series = new VolumeSeries
            {
                PositiveColor  = OxyColors.DarkGreen,
                NegativeColor  = OxyColors.Red,
                PositiveHollow = false,
                NegativeHollow = false,
                VolumeStyle    = style,
                Title          = "VolumeSeries",
            };

            // create bars
            foreach (var bar in OhlcvItemGenerator.MRProcess(n))
            {
                series.Append(bar);
            }

            // create visible window
            var Istart = n - 200;
            var Iend   = n - 120;
            var Xmin   = series.Items[Istart].X;
            var Xmax   = series.Items[Iend].X;

            // setup axes
            var timeAxis = new DateTimeAxis
            {
                Position = AxisPosition.Bottom,
                Minimum  = Xmin,
                Maximum  = Xmax
            };

            var volAxis = new LinearAxis
            {
                Position      = AxisPosition.Left,
                StartPosition = 0.0,
                EndPosition   = 1.0,
                Minimum       = natural ? double.NaN : 0,
                Maximum       = natural ? double.NaN : 10000
            };

            switch (style)
            {
            case VolumeStyle.Combined:
            case VolumeStyle.Stacked:
                pm.Axes.Add(timeAxis);
                pm.Axes.Add(volAxis);
                break;

            case VolumeStyle.PositiveNegative:
                volAxis.Minimum = natural ? double.NaN : -10000;
                pm.Axes.Add(timeAxis);
                pm.Axes.Add(volAxis);
                break;
            }

            pm.Series.Add(series);

            var controller = new PlotController();

            controller.UnbindAll();
            controller.BindMouseDown(OxyMouseButton.Left, PlotCommands.PanAt);
            return(new Example(pm, controller));
        }
Example #22
0
        public MainWindow()
        {
            DataPoints[0] = new DataPoint(-1.41, 0);
            DataPoints[1] = new DataPoint(0, -2);
            DataPoints[2] = new DataPoint(1.41, 0);
            DataPoints[3] = new DataPoint(4, 14);

            LineSeries startSeries = new LineSeries();

            startSeries.Color = OxyColors.Gray;
            startSeries.Points.AddRange(DataPoints);


            ab_Line       = new LineSeries();
            ab_Line.Color = OxyColors.Orange;
            ab_Line.Points.Add(DataPoints[0]);
            ab_Line.Points.Add(DataPoints[1]);

            bc_Line       = new LineSeries();
            bc_Line.Color = OxyColors.Orange;
            bc_Line.Points.Add(DataPoints[1]);
            bc_Line.Points.Add(DataPoints[2]);

            de_Line.Color = OxyColors.Red;

            end_Line.Color      = OxyColors.Purple;
            end_Line.MarkerSize = 5;

            pointSeries_abcdef = CreateLineseries(OxyColors.Green);
            abcdefPoints       = new DataPoint[] { DataPoints[0], DataPoints[1], DataPoints[2], DataPoints[0], DataPoints[1], DataPoints[0] };
            pointSeries_abcdef.Points.AddRange(abcdefPoints);

            plt_model.Series.Add(startSeries);
            plt_model.Series.Add(pointSeries_abcdef);
            plt_model.Series.Add(ab_Line);
            plt_model.Series.Add(bc_Line);
            plt_model.Series.Add(de_Line);
            plt_model.Series.Add(end_Line);

            InitializeComponent();

            var myController = new PlotController();

            plt_end.Controller = myController;

            //  Customizing the bindings
            myController.UnbindMouseDown(OxyMouseButton.Right);
            //Mouse

            myController.BindMouseDown(OxyMouseButton.Left, OxyPlot.PlotCommands.ZoomRectangle);

            myController.BindMouseDown(OxyMouseButton.Right, OxyPlot.PlotCommands.Track);

            //Keyboard

            myController.BindKeyDown(OxyKey.R, OxyPlot.PlotCommands.Reset);

            myController.BindKeyDown(OxyKey.W, OxyPlot.PlotCommands.PanDown);
            myController.BindKeyDown(OxyKey.A, OxyPlot.PlotCommands.PanRight);
            myController.BindKeyDown(OxyKey.S, OxyPlot.PlotCommands.PanUp);
            myController.BindKeyDown(OxyKey.D, OxyPlot.PlotCommands.PanLeft);

            plt_end.Model = plt_model;
        }