You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
71 lines
2.1 KiB
71 lines
2.1 KiB
using ReactiveUI.Avalonia;
|
|
using Avalonia.Markup.Xaml;
|
|
using AuroraDesk.Presentation.ViewModels.Pages;
|
|
using ReactiveUI;
|
|
using System;
|
|
using System.Reactive.Disposables;
|
|
using ScottPlot.Avalonia;
|
|
using Avalonia.Controls;
|
|
|
|
namespace AuroraDesk.Presentation.Views.Pages;
|
|
|
|
public partial class ScottPlotPageView : ReactiveUserControl<ScottPlotPageViewModel>
|
|
{
|
|
private AvaPlot? _plotControl1;
|
|
private AvaPlot? _plotControl2;
|
|
private AvaPlot? _plotControl3;
|
|
private AvaPlot? _plotControl4;
|
|
|
|
public ScottPlotPageView()
|
|
{
|
|
InitializeComponent();
|
|
|
|
this.WhenActivated(disposables =>
|
|
{
|
|
// 查找所有图表控件
|
|
_plotControl1 ??= this.FindControl<AvaPlot>("PlotControl1");
|
|
_plotControl2 ??= this.FindControl<AvaPlot>("PlotControl2");
|
|
_plotControl3 ??= this.FindControl<AvaPlot>("PlotControl3");
|
|
_plotControl4 ??= this.FindControl<AvaPlot>("PlotControl4");
|
|
|
|
// 当 ViewModel 加载时,设置所有 PlotControl 引用
|
|
if (ViewModel != null)
|
|
{
|
|
if (_plotControl1 != null)
|
|
{
|
|
ViewModel.PlotControl1 = _plotControl1;
|
|
}
|
|
if (_plotControl2 != null)
|
|
{
|
|
ViewModel.PlotControl2 = _plotControl2;
|
|
}
|
|
if (_plotControl3 != null)
|
|
{
|
|
ViewModel.PlotControl3 = _plotControl3;
|
|
}
|
|
if (_plotControl4 != null)
|
|
{
|
|
ViewModel.PlotControl4 = _plotControl4;
|
|
}
|
|
}
|
|
|
|
// 清理
|
|
disposables.Add(Disposable.Create(() =>
|
|
{
|
|
if (ViewModel != null)
|
|
{
|
|
ViewModel.PlotControl1 = null;
|
|
ViewModel.PlotControl2 = null;
|
|
ViewModel.PlotControl3 = null;
|
|
ViewModel.PlotControl4 = null;
|
|
}
|
|
}));
|
|
});
|
|
}
|
|
|
|
private void InitializeComponent()
|
|
{
|
|
AvaloniaXamlLoader.Load(this);
|
|
}
|
|
}
|
|
|
|
|