using BeDesignerSCADA.Controls; using BPASmartClient.Compiler; using Microsoft.Toolkit.Mvvm.ComponentModel; using System; using System.Collections.Generic; using System.Collections.ObjectModel; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows; using System.Windows.Markup; namespace BeDesignerSCADA.Common { /// /// 页面菜单属性 /// public class MenuModel : ObservableObject { /// /// 是否显示菜单 /// private bool _IsVisibility = true; public bool IsVisibility { get { return _IsVisibility; } set { _IsVisibility = value; OnPropertyChanged("IsVisibility"); } } /// /// 程序集名称 /// private string _Name = "可视化程序"; public string Name { get { return _Name; } set { _Name = value; OnPropertyChanged("Name"); } } /// /// 菜单显示方向 /// private MenuAlignment _Alignment = MenuAlignment.左边; public MenuAlignment Alignment { get { return _Alignment; } set { _Alignment = value; OnPropertyChanged("Alignment"); } } /// /// 选中页面 /// private PageModel _SelectPageModels; public PageModel SelectPageModels { get { return _SelectPageModels; } set { _SelectPageModels = value; OnPropertyChanged("SelectPageModels"); } } /// /// 页面Model /// private ObservableCollection _pageModels; public ObservableCollection pageModels { get { return _pageModels; } set { _pageModels = value; OnPropertyChanged("pageModels"); } } } /// /// 菜单选择枚举 /// public enum MenuAlignment { 左边, 顶部, 右边, 底部, } /// /// 页面 /// public class PageModel : ObservableObject { /// /// 是否首页 /// private bool _IsHome; public bool IsHome { get { return _IsHome; } set { _IsHome = value; OnPropertyChanged("IsHome"); } } /// /// 排序 /// private int _Sort; public int Sort { get { return _Sort; } set { _Sort = value; OnPropertyChanged("Sort"); } } /// /// 页面名称 /// private string _Name; public string Name { get { return _Name; } set { _Name = value; OnPropertyChanged("Name"); } } /// /// 页面ID /// public string Id { get; set; } /// /// 页面子控件集合 /// public List ChildrenStr { get; set; } /// /// 页面控件集合,不被序列化 /// private CanvasPanel _visual { get; set; } [Newtonsoft.Json.JsonIgnore] public CanvasPanel visual { get { return _visual; } set { _visual = value; try { List ChildrenStr = new List(); foreach (FrameworkElement element in _visual?.Children) { string xamlText = XamlWriter.Save(element); ChildrenStr.Add(xamlText); } ChildrenStr = ChildrenStr; } catch (Exception ex) { } OnPropertyChanged("visual"); } } /// /// 运行Canvas /// [Newtonsoft.Json.JsonIgnore] public RunCanvas runCanvas { get; set; } public PageModel() { ChildrenStr = new List(); visual = new CanvasPanel(); Id = Guid.NewGuid().ToString(); } } }