public static Example ClickingOnAnAnnotation() { var plotModel = new PlotModel { Title = "Clicking on an annotation", Subtitle = "Click on the rectangles" }; plotModel.Axes.Add(new LinearAxis { Position = AxisPosition.Bottom }); plotModel.Axes.Add(new LinearAxis { Position = AxisPosition.Left }); var annotation1 = new RectangleAnnotation { Fill = OxyColors.Green, Text = "RectangleAnnotation 1", MinimumX = 25, MaximumX = 75, MinimumY = 20, MaximumY = 40 }; plotModel.Annotations.Add(annotation1); var annotation2 = new RectangleAnnotation { Fill = OxyColors.SkyBlue, Text = "RectangleAnnotation 2", MinimumX = 25, MaximumX = 75, MinimumY = 60, MaximumY = 80 }; plotModel.Annotations.Add(annotation2); EventHandler <OxyMouseDownEventArgs> handleMouseClick = (s, e) => { plotModel.Subtitle = "You clicked " + ((RectangleAnnotation)s).Text; plotModel.InvalidatePlot(false); }; annotation1.MouseDown += handleMouseClick; annotation2.MouseDown += handleMouseClick; var controller = new PlotController(); var handleClick = new DelegatePlotCommand <OxyMouseDownEventArgs>( (v, c, e) => { var args = new HitTestArguments(e.Position, 10); var firstHit = v.ActualModel.HitTest(args).FirstOrDefault(x => x.Element is RectangleAnnotation); if (firstHit != null) { e.Handled = true; plotModel.Subtitle = "You clicked " + ((RectangleAnnotation)firstHit.Element).Text; plotModel.InvalidatePlot(false); } }); controller.Bind(new OxyMouseDownGesture(OxyMouseButton.Left), handleClick); return(new Example(plotModel, controller)); }
internal OutputsViewModel( IAppState appState, IAppService appService, IAppSettings appSettings, ModuleState moduleState, SamplingDesigns samplingDesigns ) { _appState = appState; _appSettings = appSettings; _moduleState = moduleState; _simulation = appState.Target.AssertSome(); _outputsSelectedSampleViewModel = new OutputsSelectedSampleViewModel(appState, appService, moduleState); _outputsFilteredSamplesViewModel = new OutputsFilteredSamplesViewModel(appState, appService, moduleState, samplingDesigns); _outputsEvidenceViewModel = new OutputsEvidenceViewModel(appState, appService, moduleState); var output = _simulation.SimConfig.SimOutput; _outputNames = output.DependentVariables .Map(e => e.Name) .OrderBy(n => n.ToUpperInvariant()) .ToArr(); _moduleState.OutputsState.SelectedOutputName ??= _outputNames.Head(); _selectedOutputName = _outputNames.IndexOf( _moduleState.OutputsState.SelectedOutputName ); PlotController = new(); PlotController.Bind( new OxyMouseDownGesture(OxyMouseButton.Left), new DelegatePlotCommand <OxyMouseDownEventArgs>(HandleOutputsMouseDown) ); PlotController.Bind( new OxyMouseDownGesture(OxyMouseButton.Left, OxyModifierKeys.Control), new DelegatePlotCommand <OxyMouseDownEventArgs>(HandleOutputsMouseDown) ); Outputs = new(); var horizontalAxis = new LinearAxis { Position = AxisPosition.Bottom, Title = output.IndependentVariable.Name, Unit = output.IndependentVariable.Unit }; Outputs.Axes.Add(horizontalAxis); var verticalAxis = new LinearAxis { Position = AxisPosition.Left }; Outputs.Axes.Add(verticalAxis); Outputs.ApplyThemeToPlotModelAndAxes(); PopulateAll(); ToggleSeriesType = ReactiveCommand.Create(HandleToggleSeriesType); ResetAxes = ReactiveCommand.Create(HandleResetAxes); _reactiveSafeInvoke = appService.GetReactiveSafeInvoke(); _subscriptions = new CompositeDisposable( appSettings .GetWhenPropertyChanged() .Subscribe( _reactiveSafeInvoke.SuspendAndInvoke <string?>( ObserveAppSettingsPropertyChange ) ), moduleState.OutputsState .ObservableForProperty(os => os.SelectedOutputName) .Subscribe( _reactiveSafeInvoke.SuspendAndInvoke <object>( ObserveOutputsStateSelectedOutputName ) ), moduleState.OutputsState .ObservableForProperty(os => os.ObservationsReferences) .Subscribe( _reactiveSafeInvoke.SuspendAndInvoke <object>( ObserveOutputsStateObservationsReferences ) ), moduleState .ObservableForProperty(ms => ms.FilterConfig) .Subscribe( _reactiveSafeInvoke.SuspendAndInvoke <object>( ObserveModuleStateFilterConfig ) ), moduleState .ObservableForProperty(ms => ms.Outputs) .Subscribe( _reactiveSafeInvoke.SuspendAndInvoke <object>( ObserveModuleStateOutputs ) ), moduleState .ObservableForProperty(ms => ms.OutputFilters) .Subscribe( _reactiveSafeInvoke.SuspendAndInvoke <object>( ObserveModuleStateOutputFilters ) ), this .ObservableForProperty(vm => vm.SelectedOutputName) .Subscribe( _reactiveSafeInvoke.SuspendAndInvoke <object>( ObserveSelectedOutputName ) ) ); }
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); }); }