251029
This commit is contained in:
59
FATrace.WPLApp/Models/PasswordBoxBehavior.cs
Normal file
59
FATrace.WPLApp/Models/PasswordBoxBehavior.cs
Normal file
@@ -0,0 +1,59 @@
|
||||
using Microsoft.Xaml.Behaviors;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
|
||||
namespace FATrace.WPLApp.Models
|
||||
{
|
||||
public class PasswordBoxBehavior : Behavior<PasswordBox>
|
||||
{
|
||||
public static readonly DependencyProperty PasswordProperty =
|
||||
DependencyProperty.Register("Password", typeof(string), typeof(PasswordBoxBehavior),
|
||||
new FrameworkPropertyMetadata(string.Empty, FrameworkPropertyMetadataOptions.BindsTwoWayByDefault,
|
||||
OnPasswordPropertyChanged));
|
||||
|
||||
private bool _isUpdating;
|
||||
|
||||
public string Password
|
||||
{
|
||||
get { return (string)GetValue(PasswordProperty); }
|
||||
set { SetValue(PasswordProperty, value); }
|
||||
}
|
||||
|
||||
private static void OnPasswordPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
|
||||
{
|
||||
var behavior = d as PasswordBoxBehavior;
|
||||
if (behavior._isUpdating) return;
|
||||
|
||||
if (behavior.AssociatedObject != null)
|
||||
{
|
||||
behavior._isUpdating = true;
|
||||
behavior.AssociatedObject.Password = e.NewValue?.ToString() ?? string.Empty;
|
||||
behavior._isUpdating = false;
|
||||
}
|
||||
}
|
||||
|
||||
protected override void OnAttached()
|
||||
{
|
||||
base.OnAttached();
|
||||
AssociatedObject.PasswordChanged += OnPasswordBoxValueChanged;
|
||||
}
|
||||
|
||||
protected override void OnDetaching()
|
||||
{
|
||||
AssociatedObject.PasswordChanged -= OnPasswordBoxValueChanged;
|
||||
base.OnDetaching();
|
||||
}
|
||||
|
||||
private void OnPasswordBoxValueChanged(object sender, RoutedEventArgs e)
|
||||
{
|
||||
_isUpdating = true;
|
||||
Password = AssociatedObject.Password;
|
||||
_isUpdating = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
95
FATrace.WPLApp/Models/SysRunState.cs
Normal file
95
FATrace.WPLApp/Models/SysRunState.cs
Normal file
@@ -0,0 +1,95 @@
|
||||
using Prism.Mvvm;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace FATrace.WPLApp.Models
|
||||
{
|
||||
/// <summary>
|
||||
/// 系统运行状态模型
|
||||
/// </summary>
|
||||
public class SysRunState : BindableBase
|
||||
{
|
||||
private int _RunState = 1;
|
||||
/// <summary>
|
||||
/// 运行状态
|
||||
/// </summary>
|
||||
public int RunState
|
||||
{
|
||||
get { return _RunState; }
|
||||
set
|
||||
{
|
||||
if (_RunState != value)
|
||||
{
|
||||
_RunState = value;
|
||||
switch (value)
|
||||
{
|
||||
case 1:
|
||||
RunStateMsg = "正常";
|
||||
break;
|
||||
case 2:
|
||||
RunStateMsg = "异常";
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
RaisePropertyChanged();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private string? _RunStateMsg = "正常";
|
||||
/// <summary>
|
||||
/// 运行状态消息
|
||||
/// </summary>
|
||||
public string? RunStateMsg
|
||||
{
|
||||
get { return _RunStateMsg; }
|
||||
set { _RunStateMsg = value; RaisePropertyChanged(); }
|
||||
}
|
||||
|
||||
private int _ComState = 0;
|
||||
/// <summary>
|
||||
/// 通讯状态
|
||||
/// </summary>
|
||||
public int ComState
|
||||
{
|
||||
get { return _ComState; }
|
||||
set
|
||||
{
|
||||
if (_ComState != value)
|
||||
{
|
||||
_ComState = value;
|
||||
switch (value)
|
||||
{
|
||||
case 1:
|
||||
ComMsg = "正常";
|
||||
break;
|
||||
case 2:
|
||||
ComMsg = "异常";
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
RaisePropertyChanged();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private string? _ComMsg;
|
||||
/// <summary>
|
||||
/// 通讯状态消息
|
||||
/// </summary>
|
||||
public string? ComMsg
|
||||
{
|
||||
get { return _ComMsg; }
|
||||
set { _ComMsg = value; RaisePropertyChanged(); }
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user