63 lines
2.4 KiB
C#
63 lines
2.4 KiB
C#
using System;
|
|
using System.Linq;
|
|
using System.Windows;
|
|
using TabletTester2025.Models;
|
|
|
|
namespace TabletTester2025
|
|
{
|
|
public partial class SettingsWindow : Window
|
|
{
|
|
public SettingsWindow()
|
|
{
|
|
InitializeComponent();
|
|
LoadSettings();
|
|
}
|
|
|
|
private void LoadSettings()
|
|
{
|
|
var p = App.CurrentPharmaParams;
|
|
HardnessMinBox.Text = p.HardnessMin_N.ToString();
|
|
HardnessMaxBox.Text = p.HardnessMax_N.ToString();
|
|
HardnessCountBox.Text = p.HardnessTestCount.ToString();
|
|
FriabilityMaxLossBox.Text = p.FriabilityMaxLossPercent.ToString();
|
|
DisintegrationMaxSecBox.Text = p.DisintegrationMaxSeconds.ToString();
|
|
DissolutionMinPercentBox.Text = p.DissolutionMinPercentAt30min.ToString();
|
|
SampleTimesBox.Text = string.Join(",", p.DissolutionSampleTimes);
|
|
}
|
|
|
|
private void SaveButton_Click(object sender, RoutedEventArgs e)
|
|
{
|
|
try
|
|
{
|
|
var p = App.CurrentPharmaParams;
|
|
p.HardnessMin_N = double.Parse(HardnessMinBox.Text);
|
|
p.HardnessMax_N = double.Parse(HardnessMaxBox.Text);
|
|
p.HardnessTestCount = int.Parse(HardnessCountBox.Text);
|
|
p.FriabilityMaxLossPercent = double.Parse(FriabilityMaxLossBox.Text);
|
|
p.DisintegrationMaxSeconds = int.Parse(DisintegrationMaxSecBox.Text);
|
|
p.DissolutionMinPercentAt30min = double.Parse(DissolutionMinPercentBox.Text);
|
|
p.DissolutionSampleTimes = SampleTimesBox.Text.Split(',').Select(s => int.Parse(s.Trim())).ToArray();
|
|
|
|
MessageBox.Show("参数已保存(重启后生效)", "提示", MessageBoxButton.OK, MessageBoxImage.Information);
|
|
// 可以进一步将参数写入配置文件 appsettings.json 以便持久化(可选,此处省略)
|
|
DialogResult = true;
|
|
Close();
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
MessageBox.Show($"输入格式错误: {ex.Message}", "错误", MessageBoxButton.OK, MessageBoxImage.Error);
|
|
}
|
|
}
|
|
|
|
private void CancelButton_Click(object sender, RoutedEventArgs e)
|
|
{
|
|
DialogResult = false;
|
|
Close();
|
|
}
|
|
|
|
private void HardnessMinBox_TextChanged(object sender, System.Windows.Controls.TextChangedEventArgs e)
|
|
{
|
|
|
|
}
|
|
}
|
|
} |