57 lines
1.9 KiB
C#
57 lines
1.9 KiB
C#
using MembranePoreTester.ViewModels;
|
||
using System.Windows;
|
||
using System.Windows.Input;
|
||
|
||
namespace MembranePoreTester.Views
|
||
{
|
||
public partial class MainWindow : Window
|
||
{
|
||
public MainWindow()
|
||
{
|
||
InitializeComponent();
|
||
HistoryWindow.LoadRecordEvent += OnLoadRecord;
|
||
}
|
||
|
||
private void OnLoadRecord(object sender, LoadRecordEventArgs e)
|
||
{
|
||
var mainVM = DataContext as MainViewModel;
|
||
if (mainVM == null) return;
|
||
|
||
// 根据工位和类型找到对应的 ViewModel
|
||
if (e.Type == "泡点法")
|
||
{
|
||
var targetVM = mainVM.Stations[e.TargetStation - 1].BubblePointVM;
|
||
targetVM.LoadFromDatabase(e.RecordId);
|
||
}
|
||
else
|
||
{
|
||
var targetVM = mainVM.Stations[e.TargetStation - 1].PoreDistributionVM;
|
||
targetVM.LoadFromDatabase(e.RecordId);
|
||
}
|
||
}
|
||
|
||
|
||
private void OpenHistory_Click(object sender, RoutedEventArgs e)
|
||
{
|
||
var mainVM = DataContext as MainViewModel;
|
||
if (mainVM == null) return;
|
||
|
||
// 获取当前选中的工位索引(假设选项卡控件是 TabControl,名称为 stationTabControl)
|
||
// 需要在 XAML 中为 TabControl 设置 x:Name="stationTabControl"
|
||
int currentStation = stationTabControl.SelectedIndex + 1; // 假设索引从0开始
|
||
var historyWin = new HistoryWindow { SelectedStation = currentStation };
|
||
historyWin.ShowDialog();
|
||
}
|
||
|
||
|
||
private void Window_KeyDown(object sender, KeyEventArgs e)
|
||
{
|
||
if (Keyboard.Modifiers == ModifierKeys.Control && e.Key == Key.P)
|
||
{
|
||
var win = new ParameterWindow();
|
||
win.Owner = this;
|
||
win.ShowDialog();
|
||
}
|
||
}
|
||
}
|
||
} |