Пример #1
0
        private void refreshPlot()
        {
            try
            {
                if (this.DataContext != null && LineSeries != null && spectraPlotView.Axes != null)
                {
                    if (spectraPlotView.Axes.Count > 1)
                    {
                        OxyPlot.Wpf.Axis xAxis = spectraPlotView.Axes[1];
                        if (xAxis != null)
                        {
                            int multiplier = (int)((AxisXMax - AxisXMin) / 300);
                            if (multiplier < 1)
                            {
                                xAxis.MajorStep = double.NaN;
                                xAxis.MinorStep = double.NaN;
                            }
                            else
                            {
                                xAxis.MajorStep = 100 * multiplier;
                                xAxis.MinorStep = 100 * multiplier;
                            }
                        }
                    }
                }

                spectraPlotView.InvalidatePlot();
            }
            catch (Exception ex)
            {
                //Window parentWindow = Window.GetWindow(this);
                //ViewMSOTSystem.NotifyUserOnError("Error refreshing plot: " + ex.Message, parentWindow.Title, true, false, parentWindow);
            }
        }
Пример #2
0
        private bool constructAxes()
        {
            // Setup Axes defined in XAML
            if (LineSeries != null && LineSeries.Count() > 0 && OxyPlotViewAxes.Count > 1)
            {
                IEnumerator <OxyPlot.Wpf.Axis> it = OxyPlotViewAxes.GetEnumerator();
                while (it.MoveNext())
                {
                    OxyPlotView.Axes.Add(it.Current);
                }
            }
            // Setup Axes defined in the ViewModel
            else if (ChartData != null && ChartData.LinesData.Count > 0 && ChartData.AxesConfigurations.Count > 1)
            {
                int i = 0;

                foreach (ChartAxisConf axisConf in ChartData.AxesConfigurations)
                {
                    OxyPlot.Wpf.Axis _axis = (OxyPlot.Wpf.Axis)Activator.CreateInstance(Type.GetType("OxyPlot.Wpf." + axisConf.AxisTypeName + ",OxyPlot.Wpf"));
                    _axis.SetCurrentValue(OxyPlot.Wpf.Axis.PositionProperty, MultifunctionalChartData.AxesPositions[i]);
                    // Set axis style
                    Style _axis_style = null;
                    switch (MultifunctionalChartData.AxesPositions[i])
                    {
                    case AxisPosition.Left:
                        _axis.Title = (ChartData.TitleY == null ? "" : ChartData.TitleY);
                        _axis_style = YAxisStyle;
                        break;

                    case AxisPosition.Bottom:
                        _axis.Title = (ChartData.TitleX == null ? "" : ChartData.TitleX);
                        _axis_style = XAxisStyle;
                        break;

                    // implement more cases if required
                    default:
                        DllEntryPoint.LogMessage(Xvue.MSOT.Services.Log.EnumLogType.Info, "Warning", $"{Name}.constructAxes: Axis # {(i + 1)}: Unhandled AxisPosition: {Convert.ToString(MultifunctionalChartData.AxesPositions[i])}");
                        break;
                    }
                    OxyPlotView.Axes.Add(_axis);
                    // Style DependencyProperty has to be defined always after adding the axis to the view
                    if (_axis_style == null)
                    {
                        _axis_style = TryFindResource("OxyPlotDefaultAxisStyle") as Style;
                    }
                    if (_axis_style != null)
                    {
                        _axis.SetCurrentValue(StyleProperty, _axis_style);
                    }

                    i++;
                }
            }

            return(OxyPlotView.Axes.Count() > 1);
        }