IWindow.cs 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267
  1. using Muchinfo.MTPClient.Data.Enums;
  2. using Muchinfo.MTPClient.Data.Model;
  3. using Muchinfo.MTPClient.Infrastructure.Enums;
  4. using System;
  5. namespace Muchinfo.MTPClient.Infrastructure.Interfaces
  6. {
  7. /// <summary>
  8. /// IWindow接口
  9. /// </summary>
  10. public interface IWindow
  11. {
  12. #region Properties
  13. /// <summary>
  14. /// Gets the type of the toolbar.
  15. /// </summary>
  16. ToolbarButtonType ToolbarType
  17. {
  18. get;
  19. }
  20. WindowItem WindowItem
  21. {
  22. get;
  23. }
  24. #endregion Properties
  25. #region Methods
  26. /// <summary>
  27. /// Shows the window.
  28. /// </summary>
  29. void ShowWindow();
  30. #endregion Methods
  31. }
  32. /// <summary>
  33. /// WindowItem类
  34. /// </summary>
  35. public abstract class WindowItem
  36. {
  37. #region Fields
  38. protected DateTime _createDateTime;
  39. #endregion Fields
  40. #region Constructors
  41. /// <summary>
  42. /// Initializes a new instance of the <see cref="WindowItem" /> class.
  43. /// </summary>
  44. /// <param name="windowType">窗体类型</param>
  45. /// <param name="title">窗体标题</param>
  46. /// <param name="key">窗体关键字</param>
  47. /// <param name="additionalInfo">其它附加信息</param>
  48. protected WindowItem(WindowType windowType, string title, string additionalInfo)
  49. {
  50. this.WindowType = windowType;
  51. this.Title = title;
  52. this.AdditionalInfo = additionalInfo;
  53. _createDateTime = DateTime.Now;
  54. }
  55. #endregion Constructors
  56. #region Properties
  57. #region Public Properties
  58. /// <summary>
  59. /// 获取和设置the additional info
  60. /// </summary>
  61. public string AdditionalInfo
  62. {
  63. get;
  64. set;
  65. }
  66. /// <summary>
  67. /// 获取和设置the content id - 供窗口反序列化用
  68. /// </summary>
  69. public virtual string ContentId
  70. {
  71. get
  72. {
  73. return WindowType.ToString() + "_" + Title + "_" + AdditionalInfo;
  74. }
  75. }
  76. /// <summary>
  77. /// 获取和设置窗体标题
  78. /// </summary>
  79. public string Title
  80. {
  81. get;
  82. set;
  83. }
  84. /// <summary>
  85. /// 获取和设置窗体关键字
  86. /// </summary>
  87. public virtual string WindowKey
  88. {
  89. get
  90. {
  91. return WindowType.ToString() + "_" + _createDateTime.Ticks;
  92. }
  93. }
  94. /// <summary>
  95. /// Gets or sets the type of the window.
  96. /// </summary>
  97. public WindowType WindowType
  98. {
  99. get;
  100. set;
  101. }
  102. #endregion Public Properties
  103. #endregion Properties
  104. }
  105. /// <summary>
  106. /// QuoteWindowItem类
  107. /// </summary>
  108. public class WindowItemWithCommandType : WindowItem
  109. {
  110. #region Constructors
  111. /// <summary>
  112. /// Initializes a new instance of the <see cref="WindowItemWithCommandType"/> class.
  113. /// </summary>
  114. /// <param name="windowType">Type of the window.</param>
  115. /// <param name="title">The title.</param>
  116. /// <param name="menuCommandType">Type of the menu command.</param>
  117. /// <param name="additionalInfo">The additional info.</param>
  118. public WindowItemWithCommandType(WindowType windowType, string title, MenuCommandType menuCommandType, string additionalInfo)
  119. //: base(windowType, title, menuCommandType.ToString() + (string.IsNullOrWhiteSpace(additionalInfo) ? string.Empty : ":" + additionalInfo))
  120. : base(windowType, title, additionalInfo)
  121. {
  122. this.MenuCommandType = menuCommandType;
  123. }
  124. #endregion Constructors
  125. #region Properties
  126. #region Public Properties
  127. /// <summary>
  128. /// 确定窗口类型
  129. /// </summary>
  130. public MenuCommandType MenuCommandType
  131. {
  132. get;
  133. set;
  134. }
  135. /// <summary>
  136. /// 获取和设置the content id - 供窗口反序列化用
  137. /// </summary>
  138. public override string ContentId
  139. {
  140. get
  141. {
  142. return WindowType.ToString() + "_" + Title + "_" + MenuCommandType.ToString() + (string.IsNullOrWhiteSpace(AdditionalInfo) ? string.Empty : ":" + AdditionalInfo);
  143. }
  144. }
  145. #endregion Public Properties
  146. #endregion Properties
  147. }
  148. public class ChartWindowItem : WindowItem
  149. {
  150. //additionalinfo为布局加载时用
  151. public ChartWindowItem(string title, QuoteGoods goods, CycleType cycleType)
  152. : base(WindowType.QuoteChartView, title, goods.Symbol + ":" + cycleType.ToString())
  153. {
  154. Goods = goods;
  155. CycleType = cycleType;
  156. }
  157. public QuoteGoods Goods { get; set; }
  158. public CycleType CycleType { get; set; }
  159. }
  160. /// <summary>
  161. /// AccountWindowItem类
  162. /// </summary>
  163. public class AccountWindowItem : WindowItem
  164. {
  165. public AccountWindowItem(string title)
  166. : base(WindowType.AccountManagerView, title, string.Empty)
  167. {
  168. }
  169. /// <summary>
  170. /// 获取和设置窗体关键字
  171. /// </summary>
  172. public override string WindowKey
  173. {
  174. get
  175. {
  176. return WindowType.ToString();
  177. }
  178. }
  179. }
  180. public class NewsWindowItem : WindowItem
  181. {
  182. #region Constructors
  183. public NewsWindowItem(string title, string categoryCode, string newsId)
  184. : base(WindowType.NewsView, title, string.Empty)
  185. {
  186. this.CategoryCode = categoryCode;
  187. this.NewsId = newsId;
  188. }
  189. #endregion Constructors
  190. #region Properties
  191. #region Public Properties
  192. /// <summary>
  193. /// 新闻分类代码
  194. /// </summary>
  195. public string CategoryCode
  196. {
  197. get;
  198. set;
  199. }
  200. /// <summary>
  201. /// 新闻Id
  202. /// </summary>
  203. public string NewsId { get; set; }
  204. /// <summary>
  205. /// 获取和设置the content id - 供窗口反序列化用
  206. /// </summary>
  207. public override string ContentId
  208. {
  209. get
  210. {
  211. return WindowType.ToString() + "_" + Title + "_" + CategoryCode;
  212. }
  213. }
  214. #endregion Public Properties
  215. #endregion Properties
  216. }
  217. }