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.
97 lines
3.1 KiB
97 lines
3.1 KiB
using System; |
|
using System.Collections.Generic; |
|
using System.ComponentModel; |
|
using System.Linq; |
|
|
|
namespace Kingo.Plugin.YJJK.ModelEntity |
|
{ |
|
public class ResultsCatalog : INotifyPropertyChanged |
|
{ |
|
public string Name { get; set; } |
|
public string Path { get; set; } |
|
public string Desc { get; set; } |
|
/// <summary> |
|
/// 拷贝文件原始路径 |
|
/// </summary> |
|
public string CopyFile { get; set; } |
|
/// <summary> |
|
/// IsChecked |
|
/// </summary> |
|
///<remarks></remarks> |
|
private bool? _isChecked = false; |
|
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 ResultsCatalog Parent { get; set; } |
|
public bool IsExpanded { get; set; } |
|
public string Type { get; set; } |
|
/// <summary> |
|
/// 文件类型(只有当Type=File时有效) |
|
/// </summary> |
|
public string FileType { get; set; } |
|
/// <summary> |
|
/// 文件模板(只有当Type=File时有效) |
|
/// </summary> |
|
public string FileTempalate { get; set; } |
|
public List<ResultsCatalog> SubCatalog { get; set; } |
|
|
|
public event PropertyChangedEventHandler PropertyChanged; |
|
private void NotifyPropertyChanged(String info) |
|
{ |
|
if (PropertyChanged != null) |
|
{ |
|
PropertyChanged(this, new PropertyChangedEventArgs(info)); |
|
} |
|
} |
|
|
|
/// <summary> |
|
/// 子节点的isChecked改变了, 通知父节点是否要跟着改变 isChecked |
|
/// </summary> |
|
/// <param name="value"></param> |
|
public virtual void SetIsCheckedByChild(bool? value) |
|
{ |
|
if (this._isChecked == value) |
|
{ |
|
return; |
|
} |
|
|
|
bool isAllChildrenChecked = this.SubCatalog.All(c => c.IsChecked == value); |
|
if (!isAllChildrenChecked) |
|
{ |
|
this._isChecked = null; |
|
} |
|
else |
|
{ |
|
this._isChecked = value; |
|
} |
|
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 (SubCatalog == null) |
|
{ |
|
return; |
|
} |
|
foreach (var child in SubCatalog) |
|
{ |
|
child.SetIsCheckedByParent(value); |
|
} |
|
} |
|
} |
|
}
|
|
|