using Avalonia.Controls; using CommunityToolkit.Mvvm.Input; using OxyPlot; using OxyPlot.Legends; using OxyPlot.Series; using Shaker.Models; using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows.Input; namespace ShakerApp.ViewModels { internal class RandomTransferFunctionViewModel:DisplayViewModelBase { public void InitTransferFunctionData(double[] transferFunction) { int start = (int)(RandomConfigViewModel.Instance.MinFrequency / RandomConfigViewModel.Instance.FrequencyResolution); int len = (int)(((double)RandomConfigViewModel.Instance.MaxFrequency - RandomConfigViewModel.Instance.MinFrequency) / RandomConfigViewModel.Instance.FrequencyResolution); List dataPoints = new List(); for(int i=0;i { PlotModel.Axes[0].Title = App.Current?.FindResource("Frequency") + ""; PlotModel.Axes[1].Title = App.Current?.FindResource("Ampt") + ""; PlotModel.Series[0].Title = App.Current?.FindResource("TransferFunction") + ""; PlotModel.Title = App.Current?.FindResource("TransferFunction") + ""; }); } static RandomTransferFunctionViewModel() { } public ICommand StartCommand=>new RelayCommand(Start); private void Start() { if (RandomConfigViewModel.Instance.PlanItems.Count == 0) { ShowError(App.Current?.FindResource("RandomPlanCountIsZero") + ""); return; } if (RandomConfigViewModel.Instance.PlanItems.Sum(x => x.Value.Time) <= 0) { ShowError(App.Current?.FindResource("RandomPlanTimeIsZero") + ""); return; } CommunicationViewModel.Instance.LocalCommunication?.GetEvent(Topic.STARTRANDOMTEST)?.Publish(this, null); CloseWindowAction?.Invoke(); } protected override void Cancel() { CloseWindowAction?.Invoke(); } public PlotModel PlotModel { get; } = new PlotModel(); public static RandomTransferFunctionViewModel Instance { get; } = new RandomTransferFunctionViewModel(); } }