|
@@ -17,9 +17,18 @@ namespace ShakerApp.ViewModels
|
|
{
|
|
{
|
|
public class AnalogSignalPreviewViewModel:ViewModelBase<IModel>,IDataPreview
|
|
public class AnalogSignalPreviewViewModel:ViewModelBase<IModel>,IDataPreview
|
|
{
|
|
{
|
|
|
|
+ public string AttachTitle
|
|
|
|
+ {
|
|
|
|
+ get => attachTitle;
|
|
|
|
+ set
|
|
|
|
+ {
|
|
|
|
+ if (attachTitle == value) return;
|
|
|
|
+ attachTitle = value;
|
|
|
|
+ UpdatePlotTitle(SelectedAnalog);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
List<OxyPlot.Series.LineSeries> lineSeries = new List<OxyPlot.Series.LineSeries>();
|
|
List<OxyPlot.Series.LineSeries> lineSeries = new List<OxyPlot.Series.LineSeries>();
|
|
private object locker = new object();
|
|
private object locker = new object();
|
|
- public AvaloniaList<KeyValuePair<string, AnalogType>> AllAnalogTypes { get; } = new AvaloniaList<KeyValuePair<string, AnalogType>>();
|
|
|
|
public AvaloniaList<ViewModels.StatisticsViewModel> Statistics { get; } = new AvaloniaList<StatisticsViewModel>();
|
|
public AvaloniaList<ViewModels.StatisticsViewModel> Statistics { get; } = new AvaloniaList<StatisticsViewModel>();
|
|
private AnalogType selectedAnalog;
|
|
private AnalogType selectedAnalog;
|
|
private bool canChangedAnalog = true;
|
|
private bool canChangedAnalog = true;
|
|
@@ -49,7 +58,7 @@ namespace ShakerApp.ViewModels
|
|
MajorGridlineStyle = OxyPlot.LineStyle.Solid,
|
|
MajorGridlineStyle = OxyPlot.LineStyle.Solid,
|
|
Position = OxyPlot.Axes.AxisPosition.Left,
|
|
Position = OxyPlot.Axes.AxisPosition.Left,
|
|
});
|
|
});
|
|
- PlotModel.Title = App.Current?.FindResource("ValveDriveSignal") + "";
|
|
|
|
|
|
+ UpdatePlotTitle(lasttype);
|
|
PlotModel.Legends.Add(new OxyPlot.Legends.Legend()
|
|
PlotModel.Legends.Add(new OxyPlot.Legends.Legend()
|
|
{
|
|
{
|
|
ShowInvisibleSeries = true,
|
|
ShowInvisibleSeries = true,
|
|
@@ -78,21 +87,26 @@ namespace ShakerApp.ViewModels
|
|
{
|
|
{
|
|
lock(locker)
|
|
lock(locker)
|
|
{
|
|
{
|
|
- AllAnalogTypes.Clear();
|
|
|
|
|
|
+ Menu.Clear();
|
|
ShakerConfigViewModel.Instance.AnalogSignals
|
|
ShakerConfigViewModel.Instance.AnalogSignals
|
|
.DistinctBy(x=>x.Value.AnalogType)
|
|
.DistinctBy(x=>x.Value.AnalogType)
|
|
- //.Where(x=>x.Value.AnalogType != AnalogType.DivideAcceleration)
|
|
|
|
.ToList()
|
|
.ToList()
|
|
.ForEach(x =>
|
|
.ForEach(x =>
|
|
{
|
|
{
|
|
- AllAnalogTypes.Add(new KeyValuePair<string, AnalogType>(x.Value.AnalogType.Description(), x.Value.AnalogType));
|
|
|
|
|
|
+ Menu.Add(new TimeDomainMenuViewModel()
|
|
|
|
+ {
|
|
|
|
+ IsChecked = false,
|
|
|
|
+ IsEnabled = true,
|
|
|
|
+ AnalogType = x.Value.AnalogType,
|
|
|
|
+ Unit = x.Value.Unit,
|
|
|
|
+ });
|
|
});
|
|
});
|
|
if (CanChangedAnalog)
|
|
if (CanChangedAnalog)
|
|
{
|
|
{
|
|
- int index = AllAnalogTypes.ToList().FindIndex(x => x.Value == lasttype);
|
|
|
|
|
|
+ int index = Menu.ToList().FindIndex(x => x.AnalogType == lasttype);
|
|
if (index == -1)
|
|
if (index == -1)
|
|
{
|
|
{
|
|
- SelectedAnalog = AllAnalogTypes.First().Value;
|
|
|
|
|
|
+ SelectedAnalog = Menu.First().AnalogType;
|
|
}
|
|
}
|
|
else
|
|
else
|
|
{
|
|
{
|
|
@@ -105,12 +119,32 @@ namespace ShakerApp.ViewModels
|
|
}
|
|
}
|
|
}
|
|
}
|
|
});
|
|
});
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ GetEvent(ViewModels.ShakerSettingViewModel.LANGUAGECHANGEDEVENT).Subscrip((_, _) =>
|
|
|
|
+ {
|
|
|
|
+ PlotModel.InvalidatePlot(false);
|
|
|
|
+ PlotModel.Axes[0].Title = App.Current?.FindResource("Time") + "";
|
|
|
|
+ PlotModel.Axes[1].Title = App.Current?.FindResource("Ampt") + "";
|
|
|
|
+ UpdatePlotTitle(SelectedAnalog);
|
|
|
|
+ var config = ShakerConfigViewModel.Instance.Model.AnalogSignalConfigs.First(x => x.AnalogType == SelectedAnalog);
|
|
|
|
+ for(int i=0;i<PlotModel.Series.Count;i++)
|
|
|
|
+ {
|
|
|
|
+ PlotModel.Series[i].Title = App.Current?.FindResource(config.Name) + "";
|
|
|
|
+ }
|
|
|
|
+ });
|
|
}
|
|
}
|
|
[AllowNull]
|
|
[AllowNull]
|
|
public Control Control { get; }
|
|
public Control Control { get; }
|
|
private AnalogType lasttype = AnalogType.Displacement;
|
|
private AnalogType lasttype = AnalogType.Displacement;
|
|
private bool statisticsVisibily = true;
|
|
private bool statisticsVisibily = true;
|
|
|
|
+ private string attachTitle = string.Empty;
|
|
|
|
|
|
|
|
+ private void UpdatePlotTitle(AnalogType analogType)
|
|
|
|
+ {
|
|
|
|
+ PlotModel.Title = string.IsNullOrEmpty(AttachTitle) ? App.Current?.FindResource(analogType.Description()) + "" : $"{App.Current?.FindResource(AttachTitle)}-{App.Current?.FindResource(analogType.Description())}";
|
|
|
|
+ }
|
|
|
|
+ public AvaloniaList<TimeDomainMenuViewModel> Menu { get; } = new AvaloniaList<TimeDomainMenuViewModel>();
|
|
public AnalogSignalPreviewViewModel(Shaker.Models.AnalogType analogType,bool createcontrol = false):this(createcontrol)
|
|
public AnalogSignalPreviewViewModel(Shaker.Models.AnalogType analogType,bool createcontrol = false):this(createcontrol)
|
|
{
|
|
{
|
|
lasttype = analogType;
|
|
lasttype = analogType;
|
|
@@ -132,6 +166,10 @@ namespace ShakerApp.ViewModels
|
|
lineSeries.Clear();
|
|
lineSeries.Clear();
|
|
PlotModel.Series.Clear();
|
|
PlotModel.Series.Clear();
|
|
Statistics.Clear();
|
|
Statistics.Clear();
|
|
|
|
+ for(int i=0;i<Menu.Count;i++)
|
|
|
|
+ {
|
|
|
|
+ Menu[i].IsChecked = Menu[i].AnalogType == type;
|
|
|
|
+ }
|
|
var config = ShakerConfigViewModel.Instance.Model.AnalogSignalConfigs.First(x => x.AnalogType == type);
|
|
var config = ShakerConfigViewModel.Instance.Model.AnalogSignalConfigs.First(x => x.AnalogType == type);
|
|
PlotModel.Axes[1].Unit = config.Unit;
|
|
PlotModel.Axes[1].Unit = config.Unit;
|
|
var allconfig = ShakerConfigViewModel.Instance.Model.AnalogSignalConfigs.Where(x => x.AnalogType == type).ToList();
|
|
var allconfig = ShakerConfigViewModel.Instance.Model.AnalogSignalConfigs.Where(x => x.AnalogType == type).ToList();
|
|
@@ -150,7 +188,7 @@ namespace ShakerApp.ViewModels
|
|
lineSeries.Add(series);
|
|
lineSeries.Add(series);
|
|
}
|
|
}
|
|
PlotModel.InvalidatePlot(false);
|
|
PlotModel.InvalidatePlot(false);
|
|
- PlotModel.Title = App.Current?.FindResource(type.Description()) + "";
|
|
|
|
|
|
+ UpdatePlotTitle(type);
|
|
lineSeries.ForEach(x => PlotModel.Series.Add(x));
|
|
lineSeries.ForEach(x => PlotModel.Series.Add(x));
|
|
PlotModel.InvalidatePlot(true);
|
|
PlotModel.InvalidatePlot(true);
|
|
}
|
|
}
|