This commit is contained in:
44
Views/ConfigWindow.xaml
Normal file
44
Views/ConfigWindow.xaml
Normal file
@@ -0,0 +1,44 @@
|
||||
<Window x:Class="ASTM_D7896_Tester.Views.ConfigWindow"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
Title="高级参数配置" Height="300" Width="400"
|
||||
WindowStartupLocation="CenterOwner">
|
||||
<Grid Margin="20">
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="Auto"/>
|
||||
<RowDefinition Height="Auto"/>
|
||||
<RowDefinition Height="Auto"/>
|
||||
<RowDefinition Height="Auto"/>
|
||||
<RowDefinition Height="Auto"/>
|
||||
<RowDefinition Height="*"/>
|
||||
</Grid.RowDefinitions>
|
||||
|
||||
<TextBlock Text="校准系数配置" FontWeight="Bold" FontSize="16" Grid.Row="0" Margin="0,0,0,15"/>
|
||||
|
||||
<StackPanel Grid.Row="1" Orientation="Horizontal" Margin="0,5">
|
||||
<TextBlock Text="压力系数 (D1328):" Width="150" VerticalAlignment="Center"/>
|
||||
<TextBox Text="{Binding PressureCoefficient ,UpdateSourceTrigger=LostFocus}" Width="100"/>
|
||||
</StackPanel>
|
||||
|
||||
<StackPanel Grid.Row="2" Orientation="Horizontal" Margin="0,5">
|
||||
<TextBlock Text="压力保护 (kPa) (D1332):" Width="150" VerticalAlignment="Center"/>
|
||||
<TextBox Text="{Binding PressureProtection,UpdateSourceTrigger=LostFocus}" Width="100"/>
|
||||
<TextBlock Text="(超此值停止测试)" Margin="10,0,0,0" Foreground="Gray" FontSize="11"/>
|
||||
</StackPanel>
|
||||
|
||||
<StackPanel Grid.Row="3" Orientation="Horizontal" Margin="0,5">
|
||||
<TextBlock Text="温度系数 (D1378):" Width="150" VerticalAlignment="Center"/>
|
||||
<TextBox Text="{Binding TemperatureCoefficient ,UpdateSourceTrigger=LostFocus}" Width="100"/>
|
||||
</StackPanel>
|
||||
|
||||
<StackPanel Grid.Row="4" Orientation="Horizontal" Margin="0,5">
|
||||
<TextBlock Text="电阻系数 (D1428):" Width="150" VerticalAlignment="Center"/>
|
||||
<TextBox Text="{Binding ResistanceCoefficient,UpdateSourceTrigger=LostFocus}" Width="100"/>
|
||||
</StackPanel>
|
||||
|
||||
<StackPanel Grid.Row="5" Orientation="Horizontal" HorizontalAlignment="Right" Margin="0,20,0,0">
|
||||
<Button Content="保存并关闭" Command="{Binding SaveAndCloseCommand}" CommandParameter="{Binding RelativeSource={RelativeSource AncestorType=Window}}" Width="100" Margin="5"/>
|
||||
<Button Content="取消" Click="CancelButton_Click" Width="100" Margin="5"/>
|
||||
</StackPanel>
|
||||
</Grid>
|
||||
</Window>
|
||||
18
Views/ConfigWindow.xaml.cs
Normal file
18
Views/ConfigWindow.xaml.cs
Normal file
@@ -0,0 +1,18 @@
|
||||
using System.Windows;
|
||||
using ASTM_D7896_Tester.ViewModels;
|
||||
|
||||
namespace ASTM_D7896_Tester.Views;
|
||||
|
||||
public partial class ConfigWindow : Window
|
||||
{
|
||||
public ConfigWindow()
|
||||
{
|
||||
InitializeComponent();
|
||||
DataContext = new ConfigViewModel();
|
||||
}
|
||||
|
||||
private void CancelButton_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
Close();
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,6 @@
|
||||
using ASTM_D7896_Tester.ViewModels;
|
||||
using ASTM_D7896_Tester.Models;
|
||||
using ASTM_D7896_Tester.Services;
|
||||
using ASTM_D7896_Tester.ViewModels;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
@@ -21,10 +23,11 @@ namespace ASTM_D7896_Tester.Views
|
||||
/// </summary>
|
||||
public partial class D7896View : UserControl
|
||||
{
|
||||
|
||||
public D7896View()
|
||||
{
|
||||
InitializeComponent();
|
||||
DataContext = new D7896ViewModel(); // 或者从外部注入
|
||||
DataContext = new D7896ViewModel();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,24 +1,28 @@
|
||||
using System.Text;
|
||||
using ASTM_D7896_Tester.Views;
|
||||
using CommunityToolkit.Mvvm.Input;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Data;
|
||||
using System.Windows.Documents;
|
||||
using System.Windows.Input;
|
||||
using System.Windows.Media;
|
||||
using System.Windows.Media.Imaging;
|
||||
using System.Windows.Navigation;
|
||||
using System.Windows.Shapes;
|
||||
|
||||
namespace ASTM_D7896_Tester.Views
|
||||
namespace ASTM_D7896_Tester.Views;
|
||||
|
||||
public partial class MainWindow : Window
|
||||
{
|
||||
/// <summary>
|
||||
/// Interaction logic for MainWindow.xaml
|
||||
/// </summary>
|
||||
public partial class MainWindow : Window
|
||||
public MainWindow()
|
||||
{
|
||||
public MainWindow()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
InitializeComponent();
|
||||
// 注册快捷键
|
||||
KeyGesture keyGesture = new KeyGesture(Key.P, ModifierKeys.Control);
|
||||
var inputBinding = new InputBinding(OpenConfigCommand, keyGesture);
|
||||
this.InputBindings.Add(inputBinding);
|
||||
}
|
||||
|
||||
private ICommand _openConfigCommand;
|
||||
public ICommand OpenConfigCommand => _openConfigCommand ??= new RelayCommand(OpenConfig);
|
||||
|
||||
private void OpenConfig()
|
||||
{
|
||||
var configWindow = new ConfigWindow();
|
||||
configWindow.Owner = this;
|
||||
configWindow.ShowDialog();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user