AccountMenuService.cs 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239
  1. using GalaSoft.MvvmLight.Command;
  2. using GalaSoft.MvvmLight.Ioc;
  3. using Muchinfo.MTPClient.Account.ViewModels;
  4. using Muchinfo.MTPClient.Account.ViewModels.Notices;
  5. using Muchinfo.MTPClient.Account.Views;
  6. using Muchinfo.MTPClient.Account.Views.AllOrderView;
  7. using Muchinfo.MTPClient.Account.Views.Notices;
  8. using Muchinfo.MTPClient.Account.Views.OrderTabView;
  9. using Muchinfo.MTPClient.Account.Views.OrderView;
  10. using Muchinfo.MTPClient.Data;
  11. using Muchinfo.MTPClient.Data.Enums;
  12. using Muchinfo.MTPClient.Infrastructure.Helpers;
  13. using Muchinfo.MTPClient.Infrastructure.Utilities;
  14. using Muchinfo.MTPClient.IService;
  15. using System.Collections.Generic;
  16. //----------------------------------------------------------------
  17. //Module Name: $safeprojectname$
  18. //Purpose:
  19. //CopyRight: Muchinfo
  20. //History:
  21. //----------------------------------------------------------------
  22. //DateTime 2016/2/3 13:50:23
  23. //Author
  24. //Description Create
  25. //----------------------------------------------------------------
  26. using System.Windows;
  27. using System.Windows.Input;
  28. using Muchinfo.MTPClient.Account.Views.AllOrderView.SPSL;
  29. namespace Muchinfo.MTPClient.Account.Utilities
  30. {
  31. public class AccountMenuService : IModuleMenuService
  32. {
  33. /// <summary>
  34. /// 查询账号信息菜单
  35. /// </summary>
  36. /// <returns></returns>
  37. public Dictionary<MenuCommandType, SysMenuItem> GetModuleMenuItems()
  38. {
  39. var sysMenu = new Dictionary<MenuCommandType, SysMenuItem>();
  40. sysMenu.Add(MenuCommandType.Query, new SysMenuItem(MenuCommandType.Query));
  41. sysMenu.Add(MenuCommandType.TradeSum,
  42. new SysMenuItem(MenuCommandType.TradeSum) { Command = MenuCommand, ViewType = typeof(MOTradeSum) });
  43. sysMenu.Add(MenuCommandType.AccountInfo,
  44. new SysMenuItem(MenuCommandType.AccountInfo) { Command = MenuCommand, ViewType = typeof(MAccountInfoView) });
  45. //sysMenu.Add(MenuCommandType.EntrustOrder,
  46. // new SysMenuItem(MenuCommandType.EntrustOrder) { Command = MenuCommand, ViewType = typeof(MOrderDetailView) });
  47. // sysMenu.Add(MenuCommandType.HoldDetails,
  48. // new SysMenuItem(MenuCommandType.HoldDetails) { Command = MenuCommand, ViewType = typeof(MHoldDetailView) });
  49. // sysMenu.Add(MenuCommandType.CloseOrder,
  50. // new SysMenuItem(MenuCommandType.CloseOrder) { Command = MenuCommand, ViewType = typeof(MCloseOrderView) });
  51. // sysMenu.Add(MenuCommandType.Position,
  52. // new SysMenuItem(MenuCommandType.Position) { Command = MenuCommand, ViewType = typeof(MHoldSubView) });
  53. // sysMenu.Add(MenuCommandType.CompleteOrder,
  54. // new SysMenuItem(MenuCommandType.CompleteOrder) { Command = MenuCommand, ViewType = typeof(MOpenCompleteView) });
  55. // sysMenu.Add(MenuCommandType.PrePostOrder,
  56. //new SysMenuItem(MenuCommandType.PrePostOrder) { Command = MenuCommand, ViewType = typeof(PrePostDetailView) });
  57. //不分市场查询
  58. sysMenu.Add(MenuCommandType.HoldDetails,
  59. new SysMenuItem(MenuCommandType.HoldDetails) { Command = MenuCommand, ViewType = typeof(MOMainListHolderView) });
  60. sysMenu.Add(MenuCommandType.EntrustOrder,
  61. new SysMenuItem(MenuCommandType.EntrustOrder) { Command = MenuCommand, ViewType = typeof(MOMainListView) });
  62. sysMenu.Add(MenuCommandType.Position,
  63. new SysMenuItem(MenuCommandType.Position) { Command = MenuCommand, ViewType = typeof(MOMainListHolderView) });
  64. if (UserManager.CurrentTradeAccount != null &&
  65. UserManager.CurrentTradeAccount.AccountType != eUserType.USERTYPE_INVESTOR)
  66. {
  67. sysMenu.Add(MenuCommandType.MemberPosition,
  68. new SysMenuItem(MenuCommandType.MemberPosition)
  69. {
  70. Command = MenuCommand,
  71. ViewType = typeof(MOHoldPositionsView)
  72. });
  73. }
  74. ////预埋单需判断是否显示
  75. if (ApplicationParameter.IsPrePostVisible == 1)
  76. {
  77. sysMenu.Add(MenuCommandType.PrePostOrder,
  78. new SysMenuItem(MenuCommandType.PrePostOrder)
  79. {
  80. Command = MenuCommand,
  81. ViewType = typeof(MOPrePostDetailView)
  82. });
  83. }
  84. sysMenu.Add(MenuCommandType.TransactionOrder,
  85. new SysMenuItem(MenuCommandType.TransactionOrder) { Command = MenuCommand, ViewType = typeof(MOTransactionListView) });
  86. //tab控件
  87. //sysMenu.Add(MenuCommandType.HoldDetails,
  88. // new SysMenuItem(MenuCommandType.HoldDetails) { Command = MenuCommand, ViewType = typeof(MTHoldDetailView) });
  89. //sysMenu.Add(MenuCommandType.EntrustOrder,
  90. // new SysMenuItem(MenuCommandType.EntrustOrder) { Command = MenuCommand, ViewType = typeof(MTOrderDetailView) });
  91. //sysMenu.Add(MenuCommandType.CloseOrder,
  92. // new SysMenuItem(MenuCommandType.CloseOrder) { Command = MenuCommand, ViewType = typeof(MTCloseOrderView) });
  93. //sysMenu.Add(MenuCommandType.Position,
  94. // new SysMenuItem(MenuCommandType.Position) { Command = MenuCommand, ViewType = typeof(MTHoldSummaryView) });
  95. sysMenu.Add(MenuCommandType.CompleteOrder,
  96. new SysMenuItem(MenuCommandType.CompleteOrder) { Command = MenuCommand, ViewType = typeof(MTOpenCompleteView) });
  97. //////预埋单需判断是否显示
  98. //if (ApplicationParameter.IsPrePostVisible == 1)
  99. //{
  100. // sysMenu.Add(MenuCommandType.PrePostOrder,
  101. // new SysMenuItem(MenuCommandType.PrePostOrder)
  102. // {
  103. // Command = MenuCommand,
  104. // ViewType = typeof (MTPrePostDetailView)
  105. // });
  106. //}
  107. //操作日志暂不处理
  108. //sysMenu.Add(MenuCommandType.OperationLog,
  109. // new SysMenuItem(MenuCommandType.OperationLog) { Command = MenuCommand, ViewType = typeof(OperateLogView) });
  110. sysMenu.Add(MenuCommandType.ReportQuery,
  111. new SysMenuItem(MenuCommandType.ReportQuery) { Command = MenuCommand, ViewType = null, IsDialog = true, }); //todo:报表ViewModel
  112. //公告通知
  113. sysMenu.Add(MenuCommandType.NoticeInform, new SysMenuItem(MenuCommandType.NoticeInform));
  114. sysMenu.Add(MenuCommandType.Notice,
  115. new SysMenuItem(MenuCommandType.Notice) { Command = AnnouncementCommand, ViewType = typeof(NoticesView), IsDialog = true });
  116. sysMenu.Add(MenuCommandType.Notify,
  117. new SysMenuItem(MenuCommandType.Notify) { Command = AnnouncementCommand, ViewType = typeof(NoticesView), IsDialog = true });
  118. //买入 卖出 撤单
  119. //sysMenu.Add(MenuCommandType.BuyIn, new SysMenuItem(MenuCommandType.BuyIn) { Command = SimpleIoc.Default.GetInstance<TradeHeaderViewModel>().BuyCommand });
  120. //sysMenu.Add(MenuCommandType.Sellout, new SysMenuItem(MenuCommandType.Sellout) { Command = SimpleIoc.Default.GetInstance<TradeHeaderViewModel>().SellCommand });
  121. //sysMenu.Add(MenuCommandType.Cancel, new SysMenuItem(MenuCommandType.Cancel) { Command = SimpleIoc.Default.GetInstance<TradeHeaderViewModel>().CancelCommand });
  122. sysMenu.Add(MenuCommandType.Trade, new SysMenuItem(MenuCommandType.Trade));
  123. sysMenu.Add(MenuCommandType.AmountQuety,
  124. new SysMenuItem(MenuCommandType.AmountQuety) { Command = MenuCommand, ViewType = typeof(AmountQuetyView) });
  125. ////资金流水查询
  126. sysMenu.Add(MenuCommandType.QueryAmountLog,
  127. new SysMenuItem(MenuCommandType.QueryAmountLog) { Command = MenuCommand, ViewType = typeof(QueryTaAmountLogListView) });
  128. ////协议平仓查询
  129. sysMenu.Add(MenuCommandType.DealClose, new SysMenuItem(MenuCommandType.DealClose) { Command = MenuCommand, ViewType = typeof(DealCloseView) });
  130. sysMenu.Add(MenuCommandType.HistoryOrder, new SysMenuItem(MenuCommandType.HistoryOrder) { Command = MenuCommand, ViewType = typeof(HistoryOrderQueryView) });
  131. //资管止盈止损查询
  132. sysMenu.Add(MenuCommandType.SPSLOrder, new SysMenuItem(MenuCommandType.SPSLOrder) { Command = MenuCommand, ViewType = typeof(MOMainSPSLListView) });
  133. return sysMenu;
  134. }
  135. private ICommand _menuCommand;
  136. /// <summary>
  137. /// 菜单操作
  138. /// </summary>
  139. public ICommand MenuCommand
  140. {
  141. get
  142. {
  143. if (_menuCommand == null)
  144. {
  145. _menuCommand = new RelayCommand<SysMenuItem>((item) =>
  146. {
  147. if (!item.IsDialog)
  148. {
  149. var type = item.ViewType;
  150. var assembly = System.Reflection.Assembly.GetAssembly(type);
  151. var view = assembly.CreateInstance(type.FullName, false, System.Reflection.BindingFlags.CreateInstance, null, item.Params == null ? null : item.Params.ToArray(), null, null) as FrameworkElement;
  152. if (view != null)
  153. {
  154. MessengerHelper.DefaultSend(view, MessengerTokens.ShowQueryContet);
  155. }
  156. }
  157. else
  158. {
  159. var type = item.ViewType;
  160. if (type == null) return;
  161. var assembly = System.Reflection.Assembly.GetAssembly(type);
  162. var view = assembly.CreateInstance(type.FullName, false, System.Reflection.BindingFlags.CreateInstance, null, item.Params == null ? null : item.Params.ToArray(), null, null) as Window;
  163. if (view != null)
  164. {
  165. view.ShowDialog();
  166. }
  167. }
  168. });
  169. }
  170. return _menuCommand;
  171. }
  172. }
  173. private ICommand _announcementCommand;
  174. /// <summary>
  175. /// 公告通知命令
  176. /// </summary>
  177. public ICommand AnnouncementCommand
  178. {
  179. get
  180. {
  181. if (_announcementCommand == null)
  182. {
  183. _announcementCommand = new RelayCommand<SysMenuItem>((item) =>
  184. {
  185. var type = item.ViewType;
  186. if (type == null) return;
  187. // var window = new NoticesView( );
  188. NoticesBase notices = null;
  189. if (item.SysCommandType == MenuCommandType.Notice)
  190. {
  191. // window.DataContext = new NoticesViewModel();
  192. notices = new NoticesViewModel();
  193. }
  194. else
  195. {
  196. // window.DataContext = new TradeMessageViewModel();
  197. notices = new TradeMessageViewModel();
  198. }
  199. //window.Owner = Application.Current.MainWindow;
  200. //window.WindowStartupLocation = WindowStartupLocation.CenterOwner;
  201. //window.ShowInTaskbar = false;
  202. //window.ShowDialog();
  203. MessengerHelper.DefaultSend(notices, MessengerTokens.AnnouncementDetail);
  204. });
  205. }
  206. return _announcementCommand;
  207. }
  208. }
  209. }
  210. }