52 lines
1.9 KiB
C#
52 lines
1.9 KiB
C#
using System.Windows;
|
||
using System.Windows.Controls;
|
||
using System.Windows.Data;
|
||
using SSPCTester.UI.Controls;
|
||
using SSPCTester.UI.ViewModels;
|
||
|
||
namespace SSPCTester.UI.Views;
|
||
|
||
public partial class CurvePopupWindow : Window
|
||
{
|
||
public CurvePopupWindow()
|
||
{
|
||
InitializeComponent();
|
||
}
|
||
|
||
public CurvePopupWindow(CurveTestViewModel vm, string? curveKind)
|
||
: this()
|
||
{
|
||
DataContext = vm;
|
||
ConfigureCurve(curveKind);
|
||
}
|
||
|
||
private void ConfigureCurve(string? curveKind)
|
||
{
|
||
bool isFalling = string.Equals(curveKind, "Falling", StringComparison.OrdinalIgnoreCase);
|
||
string title = isFalling ? "关断曲线(电压下降,10% 阈值)" : "开启曲线(电压上升,90% 阈值)";
|
||
|
||
Title = title;
|
||
TitleRun.Text = $"{title} ";
|
||
CurveTitleText.Text = title;
|
||
CurvePlot.IsRising = !isFalling;
|
||
|
||
CurvePlot.SetBinding(CurvePlotControl.CurveProperty, new Binding(isFalling ? "FallingCurve" : "RisingCurve"));
|
||
CurvePlot.SetBinding(CurvePlotControl.ViewStartMsProperty, new Binding(isFalling ? "FallingViewStartMs" : "RisingViewStartMs"));
|
||
CurvePlot.SetBinding(CurvePlotControl.ViewEndMsProperty, new Binding(isFalling ? "FallingViewEndMs" : "RisingViewEndMs"));
|
||
|
||
StartTextBox.SetBinding(TextBox.TextProperty, new Binding(isFalling ? "FallingViewStartMs" : "RisingViewStartMs")
|
||
{
|
||
UpdateSourceTrigger = UpdateSourceTrigger.PropertyChanged,
|
||
TargetNullValue = ""
|
||
});
|
||
EndTextBox.SetBinding(TextBox.TextProperty, new Binding(isFalling ? "FallingViewEndMs" : "RisingViewEndMs")
|
||
{
|
||
UpdateSourceTrigger = UpdateSourceTrigger.PropertyChanged,
|
||
TargetNullValue = ""
|
||
});
|
||
ResetButton.SetBinding(Button.CommandProperty, new Binding(isFalling ? "ResetFallingCurveViewCommand" : "ResetRisingCurveViewCommand"));
|
||
}
|
||
|
||
private void Close_Click(object sender, RoutedEventArgs e) => Close();
|
||
}
|