You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
122 lines
3.5 KiB
122 lines
3.5 KiB
using System; |
|
using System.Collections.Generic; |
|
using System.ComponentModel; |
|
using System.Linq; |
|
|
|
namespace Kingo.Plugin.YJJK.ModelEntity |
|
{ |
|
public class XZQTreeNode : INotifyPropertyChanged |
|
{ |
|
/// <summary> |
|
/// |
|
/// </summary> |
|
///<remarks>create 王欢 2018-09-29</remarks> |
|
public event PropertyChangedEventHandler PropertyChanged; |
|
private void NotifyPropertyChanged(String info) |
|
{ |
|
if (PropertyChanged != null) |
|
{ |
|
PropertyChanged(this, new PropertyChangedEventArgs(info)); |
|
} |
|
} |
|
|
|
/// <summary> |
|
/// IsChecked |
|
/// </summary> |
|
///<remarks>Update 王欢 2018-09-28</remarks> |
|
private bool _isChecked; |
|
public bool IsChecked |
|
{ |
|
set |
|
{ |
|
_isChecked = value; |
|
if (PropertyChanged != null) PropertyChanged.Invoke(this, new PropertyChangedEventArgs("IsChecked")); |
|
SetIsCheckedByParent(value); |
|
if (Parent != null) Parent.SetIsCheckedByChild(value); |
|
} |
|
get { return this._isChecked; } |
|
} |
|
|
|
|
|
public string XZQMC { get; set; } |
|
public string XZQDM { get; set; } |
|
|
|
|
|
public decimal XH |
|
{ |
|
get |
|
{ |
|
decimal xh; |
|
decimal.TryParse(XZQDM, out xh); |
|
return xh; |
|
} |
|
} |
|
|
|
|
|
public string ShowName |
|
{ |
|
get |
|
{ |
|
if (string.IsNullOrEmpty(XZQMC)) |
|
{ |
|
XZQMC = XZQDM; |
|
} |
|
return string.Format("{0}[{1}]", XZQMC, XZQDM); |
|
} |
|
} |
|
|
|
|
|
public object Tag { get; set; } |
|
|
|
public string GroupName { get; set; } |
|
|
|
public bool IsExpanded { get; set; } |
|
public XZQTreeNode Parent { get; set; } |
|
/// <summary> |
|
/// 子节点,默认null |
|
/// </summary> |
|
///<remarks>Update 王欢 2018-09-29</remarks> |
|
private List<XZQTreeNode> _nodes = new List<XZQTreeNode>(); |
|
public IList<XZQTreeNode> Nodes { get { return _nodes; } set { _nodes = (List<XZQTreeNode>)value; } } |
|
|
|
#region 王欢 2018-09-28 |
|
|
|
/// <summary> |
|
/// 子节点的isChecked改变了, 通知父节点是否要跟着改变 isChecked |
|
/// </summary> |
|
/// <param name="value"></param> |
|
public virtual void SetIsCheckedByChild(bool value) |
|
{ |
|
if (this._isChecked == value) |
|
{ |
|
return; |
|
} |
|
|
|
bool isAllChildrenChecked = this.Nodes.All(c => c.IsChecked == true); |
|
this._isChecked = isAllChildrenChecked; |
|
if (PropertyChanged != null) PropertyChanged.Invoke(this, new PropertyChangedEventArgs("IsChecked")); |
|
if (Parent != null) Parent.SetIsCheckedByChild(value); |
|
} |
|
|
|
/// <summary> |
|
/// 父节点isChecked改变了, 所有子节点跟着改变 |
|
/// </summary> |
|
/// <param name="value"></param> |
|
public virtual void SetIsCheckedByParent(bool value) |
|
{ |
|
this._isChecked = value; |
|
if (PropertyChanged != null) PropertyChanged.Invoke(this, new PropertyChangedEventArgs("IsChecked")); |
|
if (Nodes == null) |
|
{ |
|
return; |
|
} |
|
foreach (var child in Nodes) |
|
{ |
|
child.SetIsCheckedByParent(value); |
|
} |
|
} |
|
#endregion |
|
|
|
|
|
} |
|
}
|
|
|