终端一体化运控平台
25개 이상의 토픽을 선택하실 수 없습니다. Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

222 lines
5.1 KiB

  1. using BeDesignerSCADA.Controls;
  2. using BPASmartClient.Compiler;
  3. using Microsoft.Toolkit.Mvvm.ComponentModel;
  4. using System;
  5. using System.Collections.Generic;
  6. using System.Collections.ObjectModel;
  7. using System.Linq;
  8. using System.Text;
  9. using System.Threading.Tasks;
  10. using System.Windows;
  11. using System.Windows.Markup;
  12. namespace BeDesignerSCADA.Common
  13. {
  14. /// <summary>
  15. /// 页面菜单属性
  16. /// </summary>
  17. public class MenuModel : ObservableObject
  18. {
  19. /// <summary>
  20. /// 是否显示菜单
  21. /// </summary>
  22. private bool _IsVisibility = true;
  23. public bool IsVisibility
  24. {
  25. get
  26. {
  27. return _IsVisibility;
  28. }
  29. set
  30. {
  31. _IsVisibility = value;
  32. OnPropertyChanged("IsVisibility");
  33. }
  34. }
  35. /// <summary>
  36. /// 程序集名称
  37. /// </summary>
  38. private string _Name = "可视化程序";
  39. public string Name
  40. {
  41. get
  42. {
  43. return _Name;
  44. }
  45. set
  46. {
  47. _Name = value;
  48. OnPropertyChanged("Name");
  49. }
  50. }
  51. /// <summary>
  52. /// 菜单显示方向
  53. /// </summary>
  54. private MenuAlignment _Alignment = MenuAlignment.左边;
  55. public MenuAlignment Alignment
  56. {
  57. get
  58. {
  59. return _Alignment;
  60. }
  61. set
  62. {
  63. _Alignment = value;
  64. OnPropertyChanged("Alignment");
  65. }
  66. }
  67. /// <summary>
  68. /// 选中页面
  69. /// </summary>
  70. private PageModel _SelectPageModels;
  71. public PageModel SelectPageModels
  72. {
  73. get
  74. {
  75. return _SelectPageModels;
  76. }
  77. set
  78. {
  79. _SelectPageModels = value;
  80. OnPropertyChanged("SelectPageModels");
  81. }
  82. }
  83. /// <summary>
  84. /// 页面Model
  85. /// </summary>
  86. private ObservableCollection<PageModel> _pageModels;
  87. public ObservableCollection<PageModel> pageModels
  88. {
  89. get
  90. {
  91. return _pageModels;
  92. }
  93. set
  94. {
  95. _pageModels = value;
  96. OnPropertyChanged("pageModels");
  97. }
  98. }
  99. }
  100. /// <summary>
  101. /// 菜单选择枚举
  102. /// </summary>
  103. public enum MenuAlignment
  104. {
  105. 左边,
  106. 顶部,
  107. 右边,
  108. 底部,
  109. }
  110. /// <summary>
  111. /// 页面
  112. /// </summary>
  113. public class PageModel : ObservableObject
  114. {
  115. /// <summary>
  116. /// 是否首页
  117. /// </summary>
  118. private bool _IsHome;
  119. public bool IsHome
  120. {
  121. get
  122. {
  123. return _IsHome;
  124. }
  125. set
  126. {
  127. _IsHome = value;
  128. OnPropertyChanged("IsHome");
  129. }
  130. }
  131. /// <summary>
  132. /// 排序
  133. /// </summary>
  134. private int _Sort;
  135. public int Sort
  136. {
  137. get
  138. {
  139. return _Sort;
  140. }
  141. set
  142. {
  143. _Sort = value;
  144. OnPropertyChanged("Sort");
  145. }
  146. }
  147. /// <summary>
  148. /// 页面名称
  149. /// </summary>
  150. private string _Name;
  151. public string Name
  152. {
  153. get
  154. {
  155. return _Name;
  156. }
  157. set
  158. {
  159. _Name = value;
  160. OnPropertyChanged("Name");
  161. }
  162. }
  163. /// <summary>
  164. /// 页面ID
  165. /// </summary>
  166. public string Id { get; set; }
  167. /// <summary>
  168. /// 页面子控件集合
  169. /// </summary>
  170. public List<string> ChildrenStr { get; set; }
  171. /// <summary>
  172. /// 页面控件集合,不被序列化
  173. /// </summary>
  174. private CanvasPanel _visual { get; set; }
  175. [Newtonsoft.Json.JsonIgnore]
  176. public CanvasPanel visual
  177. {
  178. get
  179. {
  180. return _visual;
  181. }
  182. set
  183. {
  184. _visual = value;
  185. try
  186. {
  187. List<string> ChildrenStr = new List<string>();
  188. foreach (FrameworkElement element in _visual?.Children)
  189. {
  190. string xamlText = XamlWriter.Save(element);
  191. ChildrenStr.Add(xamlText);
  192. }
  193. ChildrenStr = ChildrenStr;
  194. }
  195. catch (Exception ex)
  196. {
  197. }
  198. OnPropertyChanged("visual");
  199. }
  200. }
  201. /// <summary>
  202. /// 运行Canvas
  203. /// </summary>
  204. [Newtonsoft.Json.JsonIgnore]
  205. public RunCanvas runCanvas { get; set; }
  206. public PageModel()
  207. {
  208. ChildrenStr = new List<string>();
  209. visual = new CanvasPanel();
  210. Id = Guid.NewGuid().ToString();
  211. }
  212. }
  213. }