|
- 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();
- }
- }
- }
|