123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106 |
- using Avalonia.Collections;
- using Avalonia.Controls;
- using Shaker.Model;
- using Shaker.Models;
- using ShakerApp.Models;
- using ShakerApp.Tools;
- using ShakerApp.Views;
- using System;
- using System.Collections.Generic;
- using System.ComponentModel.DataAnnotations;
- using System.Diagnostics.CodeAnalysis;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace ShakerApp.ViewModels
- {
- internal class OutSignalMainPageViewModel:ViewModelBase<IModel>,IMainPageViewModel
- {
- public MainPageType PageType => MainPageType.OutSignal;
- [AllowNull]
- private TimeDomainMenuViewModel selectedType;
- private OutSignalMainPageViewModel()
- {
- Enum.GetValues<TimeDomainType>().ToList()
- .ForEach(x =>
- {
- Menu.Add(new TimeDomainMenuViewModel()
- {
- TimeDomainType = x,
- IsEnabled = true,
- Unit = x.GetUnit(),
- });
- });
- if(Menu.Count>0)
- {
- SelectedType = Menu.First();
- }
- PlotModel.Axes.Add(new OxyPlot.Axes.TimeSpanAxis()
- {
- Title = App.Current?.FindResource("Time") + "",
- Unit = "s",
- Position = OxyPlot.Axes.AxisPosition.Bottom,
- MaximumPadding =0,
- MinimumPadding =0,
- MajorGridlineStyle = OxyPlot.LineStyle.Solid,
- });
- PlotModel.Axes.Add(new OxyPlot.Axes.LinearAxis()
- {
- Title=App.Current?.FindResource("Ampt")+ "",
- Unit=SelectedType.Unit,
- Position = OxyPlot.Axes.AxisPosition.Left,
- MajorGridlineStyle = OxyPlot.LineStyle.Solid,
- });
- PlotModel.Title = $"{App.Current?.FindResource(MainPageType.OutSignal.Description())}-{App.Current?.FindResource(SelectedType.Key)}";
- GetEvent(ShakerSettingViewModel.LANGUAGECHANGEDEVENT).Subscrip((_, _) =>
- {
- PlotModel.InvalidatePlot(false);
- PlotModel.Title = $"{App.Current?.FindResource(MainPageType.OutSignal.Description())}-{App.Current?.FindResource(SelectedType.Key)}";
- PlotModel.Axes[0].Title = App.Current?.FindResource("Time") + "";
- PlotModel.Axes[1].Title = Title = App.Current?.FindResource("Ampt") + "";
- PlotModel.InvalidatePlot(true);
- });
-
- }
- static OutSignalMainPageViewModel()
- {
- }
- public void Start()
- {
- }
- public void Stop()
- {
- }
- public void UpdateData(IResultDataModel model)
- {
- }
- public AvaloniaList<TimeDomainMenuViewModel> Menu { get; } = new AvaloniaList<TimeDomainMenuViewModel>();
- public TimeDomainMenuViewModel SelectedType
- {
- get => selectedType;
- set
- {
- SetProperty(ref selectedType, value);
- foreach(var val in Menu)
- {
- val.IsChecked = val.TimeDomainType == value.TimeDomainType;
- }
- PlotModel.Title = $"{App.Current?.FindResource(MainPageType.OutSignal.Description())}-{App.Current?.FindResource(value.Key)}";
- if (PlotModel.Axes.Count < 2) return;
- PlotModel.InvalidatePlot(false);
- PlotModel.Axes[1].Unit = value.Unit;
- PlotModel.InvalidatePlot(true);
- }
- }
- public OxyPlot.PlotController Controller { get; private set; } = new OxyPlot.PlotController();
- public OxyPlot.PlotModel PlotModel { get; private set; } = new OxyPlot.PlotModel();
- public static OutSignalMainPageViewModel Instance { get; } = new OutSignalMainPageViewModel();
- }
- }
|