using System.ComponentModel;
using System.Runtime.CompilerServices;
using System.Windows;
using System.Windows.Controls;
namespace Util.ManualDebug
{
// 状态枚举
public enum DebugStatus
{
Idle = 0, // 空闲
Testing = 1, // 测试中
OK = 2, // 通过
NG = 3 // 失败
}
///
/// StatusBtn.xaml 的交互逻辑
///
public partial class StatusBtn : UserControl, INotifyPropertyChanged
{
#region ...
public event PropertyChangedEventHandler PropertyChanged;
protected void Set([CallerMemberName] string name = null)
{
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(name));
}
protected void Set(ref T old, T @new, [CallerMemberName] string propertyName = null)
{
old = @new;
if (propertyName != null)
{
Set(propertyName);
}
}
#endregion
public event RoutedEventHandler BtnClick;
public StatusBtn()
{
DataContext = this;
InitializeComponent();
}
private string title = string.Empty;
public string Title
{
get => title;
set
{
Set(ref title, value);
}
}
private DebugStatus status = DebugStatus.Idle;
public DebugStatus Status
{
get => status;
set
{
Set(ref status, value);
}
}
private void Button_Click(object sender, RoutedEventArgs e)
{
BtnClick?.Invoke(this, e);
}
}
}