2026-03-27 21:35:32 +08:00
|
|
|
|
using MembranePoreTester.ViewModels;
|
2026-04-02 18:06:10 +08:00
|
|
|
|
using System.Windows;
|
2026-03-27 21:35:32 +08:00
|
|
|
|
using System.Windows.Controls;
|
2026-02-27 16:03:49 +08:00
|
|
|
|
|
|
|
|
|
|
namespace MembranePoreTester.Views
|
|
|
|
|
|
{
|
|
|
|
|
|
public partial class PoreDistributionView : UserControl
|
|
|
|
|
|
{
|
|
|
|
|
|
public PoreDistributionView()
|
|
|
|
|
|
{
|
|
|
|
|
|
InitializeComponent();
|
2026-03-02 18:50:30 +08:00
|
|
|
|
//DataContext = new ViewModels.PoreDistributionViewModel();
|
2026-03-27 21:35:32 +08:00
|
|
|
|
|
|
|
|
|
|
// 监听 IsVisible 变化
|
|
|
|
|
|
this.IsVisibleChanged += (s, e) =>
|
|
|
|
|
|
{
|
|
|
|
|
|
if (this.DataContext is ViewModels.PoreDistributionViewModel vm)
|
|
|
|
|
|
{
|
|
|
|
|
|
vm.IsActive = this.IsVisible;
|
|
|
|
|
|
if (!this.IsVisible)
|
|
|
|
|
|
{
|
|
|
|
|
|
// 离开孔分布界面时,停止自动采集
|
2026-04-02 17:26:42 +08:00
|
|
|
|
//vm.StopCollecting();
|
2026-03-27 21:35:32 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
};
|
2026-04-02 18:06:10 +08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
this.Loaded += OnLoaded;
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private void OnLoaded(object sender, RoutedEventArgs e)
|
|
|
|
|
|
{
|
|
|
|
|
|
var vm = this.DataContext as PoreDistributionViewModel;
|
|
|
|
|
|
if (vm != null)
|
|
|
|
|
|
{
|
|
|
|
|
|
vm.Record.DataPoints.CollectionChanged += DataPoints_CollectionChanged;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private void Button_Click(object sender, System.Windows.RoutedEventArgs e)
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private void DataPoints_CollectionChanged(object sender, System.Collections.Specialized.NotifyCollectionChangedEventArgs e)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (e.Action == System.Collections.Specialized.NotifyCollectionChangedAction.Add)
|
|
|
|
|
|
{
|
|
|
|
|
|
// 滚动湿膜表格到底部
|
|
|
|
|
|
ScrollDataGridToEnd(dgWetData);
|
|
|
|
|
|
// 滚动干膜表格到底部
|
|
|
|
|
|
ScrollDataGridToEnd(dgDryData);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private void ScrollDataGridToEnd(DataGrid dataGrid)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (dataGrid.Items.Count > 0)
|
|
|
|
|
|
{
|
|
|
|
|
|
dataGrid.ScrollIntoView(dataGrid.Items[dataGrid.Items.Count - 1]);
|
|
|
|
|
|
}
|
2026-02-27 16:03:49 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|