SSPC-Tester/SSPCTester.UI/Views/CurvePopupWindow.xaml.cs
2026-07-03 14:16:15 +08:00

52 lines
1.9 KiB
C#
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

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();
}