using PLCSharp.VVMs.Authority; using Prism.Commands; using Prism.Dialogs; using Prism.Mvvm; namespace PLCSharp.Core.Prism { /// /// Navigate项 /// public class NavigateItem : BindableBase, IComparable { /// /// Navigate项 /// public NavigateItem(IDialogService dialogService) { _dialogService = dialogService; } private string _ViewName; /// /// 视图名称 /// public string ViewName { get { return _ViewName; } set { SetProperty(ref _ViewName, value); } } private string _IconKind; /// /// IconKind /// public string IconKind { get { return _IconKind; } set { SetProperty(ref _IconKind, value); } } private string _DisplayName; /// /// Display名称 /// public string DisplayName { get { return _DisplayName; } set { SetProperty(ref _DisplayName, value); } } private Authority _UserLevel; /// /// 用户Level /// public Authority UserLevel { get { return _UserLevel; } set { SetProperty(ref _UserLevel, value); } } private bool _Display; /// /// Display /// public bool Display { get { return _Display; } set { SetProperty(ref _Display, value); } } /// /// 当前索引 /// public int Index { get; set; } /// /// CompareTo /// /// other /// 返回整数值 public int CompareTo(NavigateItem other) { if (other == null) return 1; return Index.CompareTo(other.Index); } private DelegateCommand _Open; /// /// 打开 /// public DelegateCommand Open => _Open ??= new DelegateCommand(ExecuteOpen); void ExecuteOpen() { if (ShowList.Contains(ViewName) == false) { ShowList.Add(ViewName); try { _dialogService.Show(ViewName, r => { if (ShowList.Contains(ViewName)) { ShowList.Remove(ViewName); } }); } catch (Exception) { ShowList.Remove(ViewName); } } } private List ShowList = []; IDialogService _dialogService { get; set; } } }