|
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221 |
- 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
- {
-
- /// <summary>
- /// 页面菜单属性
- /// </summary>
- public class MenuModel : ObservableObject
- {
- /// <summary>
- /// 是否显示菜单
- /// </summary>
- private bool _IsVisibility = true;
- public bool IsVisibility
- {
- get
- {
- return _IsVisibility;
- }
- set
- {
- _IsVisibility = value;
- OnPropertyChanged("IsVisibility");
- }
- }
- /// <summary>
- /// 程序集名称
- /// </summary>
- private string _Name = "可视化程序";
- public string Name
- {
- get
- {
- return _Name;
- }
- set
- {
- _Name = value;
- OnPropertyChanged("Name");
- }
- }
- /// <summary>
- /// 菜单显示方向
- /// </summary>
- private MenuAlignment _Alignment = MenuAlignment.左边;
- public MenuAlignment Alignment
- {
- get
- {
- return _Alignment;
- }
- set
- {
- _Alignment = value;
- OnPropertyChanged("Alignment");
- }
- }
-
- /// <summary>
- /// 选中页面
- /// </summary>
- private PageModel _SelectPageModels;
- public PageModel SelectPageModels
- {
- get
- {
- return _SelectPageModels;
- }
- set
- {
- _SelectPageModels = value;
- OnPropertyChanged("SelectPageModels");
- }
- }
-
- /// <summary>
- /// 页面Model
- /// </summary>
- private ObservableCollection<PageModel> _pageModels;
- public ObservableCollection<PageModel> pageModels
- {
- get
- {
- return _pageModels;
- }
- set
- {
- _pageModels = value;
- OnPropertyChanged("pageModels");
- }
- }
- }
- /// <summary>
- /// 菜单选择枚举
- /// </summary>
- public enum MenuAlignment
- {
- 左边,
- 顶部,
- 右边,
- 底部,
- }
- /// <summary>
- /// 页面
- /// </summary>
- public class PageModel : ObservableObject
- {
- /// <summary>
- /// 是否首页
- /// </summary>
- private bool _IsHome;
- public bool IsHome
- {
- get
- {
- return _IsHome;
- }
- set
- {
- _IsHome = value;
- OnPropertyChanged("IsHome");
- }
- }
- /// <summary>
- /// 排序
- /// </summary>
- private int _Sort;
- public int Sort
- {
- get
- {
- return _Sort;
- }
- set
- {
- _Sort = value;
- OnPropertyChanged("Sort");
- }
- }
- /// <summary>
- /// 页面名称
- /// </summary>
- private string _Name;
- public string Name
- {
- get
- {
- return _Name;
- }
- set
- {
- _Name = value;
- OnPropertyChanged("Name");
- }
- }
- /// <summary>
- /// 页面ID
- /// </summary>
- public string Id { get; set; }
- /// <summary>
- /// 页面子控件集合
- /// </summary>
- public List<string> ChildrenStr { get; set; }
-
- /// <summary>
- /// 页面控件集合,不被序列化
- /// </summary>
-
- private CanvasPanel _visual { get; set; }
- [Newtonsoft.Json.JsonIgnore]
- public CanvasPanel visual
- {
- get
- {
- return _visual;
- }
- set
- {
- _visual = value;
- try
- {
- List<string> ChildrenStr = new List<string>();
- foreach (FrameworkElement element in _visual?.Children)
- {
- string xamlText = XamlWriter.Save(element);
- ChildrenStr.Add(xamlText);
- }
- ChildrenStr = ChildrenStr;
- }
- catch (Exception ex)
- {
-
- }
-
- OnPropertyChanged("visual");
- }
- }
- /// <summary>
- /// 运行Canvas
- /// </summary>
- [Newtonsoft.Json.JsonIgnore]
- public RunCanvas runCanvas { get; set; }
- public PageModel()
- {
- ChildrenStr = new List<string>();
- visual = new CanvasPanel();
- Id = Guid.NewGuid().ToString();
- }
- }
- }
|