| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239 |
- using GalaSoft.MvvmLight.Command;
- using GalaSoft.MvvmLight.Ioc;
- using Muchinfo.MTPClient.Account.ViewModels;
- using Muchinfo.MTPClient.Account.ViewModels.Notices;
- using Muchinfo.MTPClient.Account.Views;
- using Muchinfo.MTPClient.Account.Views.AllOrderView;
- using Muchinfo.MTPClient.Account.Views.Notices;
- using Muchinfo.MTPClient.Account.Views.OrderTabView;
- using Muchinfo.MTPClient.Account.Views.OrderView;
- using Muchinfo.MTPClient.Data;
- using Muchinfo.MTPClient.Data.Enums;
- using Muchinfo.MTPClient.Infrastructure.Helpers;
- using Muchinfo.MTPClient.Infrastructure.Utilities;
- using Muchinfo.MTPClient.IService;
- using System.Collections.Generic;
- //----------------------------------------------------------------
- //Module Name: $safeprojectname$
- //Purpose:
- //CopyRight: Muchinfo
- //History:
- //----------------------------------------------------------------
- //DateTime 2016/2/3 13:50:23
- //Author
- //Description Create
- //----------------------------------------------------------------
- using System.Windows;
- using System.Windows.Input;
- using Muchinfo.MTPClient.Account.Views.AllOrderView.SPSL;
- namespace Muchinfo.MTPClient.Account.Utilities
- {
- public class AccountMenuService : IModuleMenuService
- {
- /// <summary>
- /// 查询账号信息菜单
- /// </summary>
- /// <returns></returns>
- public Dictionary<MenuCommandType, SysMenuItem> GetModuleMenuItems()
- {
- var sysMenu = new Dictionary<MenuCommandType, SysMenuItem>();
- sysMenu.Add(MenuCommandType.Query, new SysMenuItem(MenuCommandType.Query));
- sysMenu.Add(MenuCommandType.TradeSum,
- new SysMenuItem(MenuCommandType.TradeSum) { Command = MenuCommand, ViewType = typeof(MOTradeSum) });
- sysMenu.Add(MenuCommandType.AccountInfo,
- new SysMenuItem(MenuCommandType.AccountInfo) { Command = MenuCommand, ViewType = typeof(MAccountInfoView) });
- //sysMenu.Add(MenuCommandType.EntrustOrder,
- // new SysMenuItem(MenuCommandType.EntrustOrder) { Command = MenuCommand, ViewType = typeof(MOrderDetailView) });
- // sysMenu.Add(MenuCommandType.HoldDetails,
- // new SysMenuItem(MenuCommandType.HoldDetails) { Command = MenuCommand, ViewType = typeof(MHoldDetailView) });
- // sysMenu.Add(MenuCommandType.CloseOrder,
- // new SysMenuItem(MenuCommandType.CloseOrder) { Command = MenuCommand, ViewType = typeof(MCloseOrderView) });
- // sysMenu.Add(MenuCommandType.Position,
- // new SysMenuItem(MenuCommandType.Position) { Command = MenuCommand, ViewType = typeof(MHoldSubView) });
- // sysMenu.Add(MenuCommandType.CompleteOrder,
- // new SysMenuItem(MenuCommandType.CompleteOrder) { Command = MenuCommand, ViewType = typeof(MOpenCompleteView) });
- // sysMenu.Add(MenuCommandType.PrePostOrder,
- //new SysMenuItem(MenuCommandType.PrePostOrder) { Command = MenuCommand, ViewType = typeof(PrePostDetailView) });
- //不分市场查询
- sysMenu.Add(MenuCommandType.HoldDetails,
- new SysMenuItem(MenuCommandType.HoldDetails) { Command = MenuCommand, ViewType = typeof(MOMainListHolderView) });
- sysMenu.Add(MenuCommandType.EntrustOrder,
- new SysMenuItem(MenuCommandType.EntrustOrder) { Command = MenuCommand, ViewType = typeof(MOMainListView) });
- sysMenu.Add(MenuCommandType.Position,
- new SysMenuItem(MenuCommandType.Position) { Command = MenuCommand, ViewType = typeof(MOMainListHolderView) });
- if (UserManager.CurrentTradeAccount != null &&
- UserManager.CurrentTradeAccount.AccountType != eUserType.USERTYPE_INVESTOR)
- {
- sysMenu.Add(MenuCommandType.MemberPosition,
- new SysMenuItem(MenuCommandType.MemberPosition)
- {
- Command = MenuCommand,
- ViewType = typeof(MOHoldPositionsView)
- });
- }
- ////预埋单需判断是否显示
- if (ApplicationParameter.IsPrePostVisible == 1)
- {
- sysMenu.Add(MenuCommandType.PrePostOrder,
- new SysMenuItem(MenuCommandType.PrePostOrder)
- {
- Command = MenuCommand,
- ViewType = typeof(MOPrePostDetailView)
- });
- }
- sysMenu.Add(MenuCommandType.TransactionOrder,
- new SysMenuItem(MenuCommandType.TransactionOrder) { Command = MenuCommand, ViewType = typeof(MOTransactionListView) });
- //tab控件
- //sysMenu.Add(MenuCommandType.HoldDetails,
- // new SysMenuItem(MenuCommandType.HoldDetails) { Command = MenuCommand, ViewType = typeof(MTHoldDetailView) });
- //sysMenu.Add(MenuCommandType.EntrustOrder,
- // new SysMenuItem(MenuCommandType.EntrustOrder) { Command = MenuCommand, ViewType = typeof(MTOrderDetailView) });
- //sysMenu.Add(MenuCommandType.CloseOrder,
- // new SysMenuItem(MenuCommandType.CloseOrder) { Command = MenuCommand, ViewType = typeof(MTCloseOrderView) });
- //sysMenu.Add(MenuCommandType.Position,
- // new SysMenuItem(MenuCommandType.Position) { Command = MenuCommand, ViewType = typeof(MTHoldSummaryView) });
- sysMenu.Add(MenuCommandType.CompleteOrder,
- new SysMenuItem(MenuCommandType.CompleteOrder) { Command = MenuCommand, ViewType = typeof(MTOpenCompleteView) });
- //////预埋单需判断是否显示
- //if (ApplicationParameter.IsPrePostVisible == 1)
- //{
- // sysMenu.Add(MenuCommandType.PrePostOrder,
- // new SysMenuItem(MenuCommandType.PrePostOrder)
- // {
- // Command = MenuCommand,
- // ViewType = typeof (MTPrePostDetailView)
- // });
- //}
- //操作日志暂不处理
- //sysMenu.Add(MenuCommandType.OperationLog,
- // new SysMenuItem(MenuCommandType.OperationLog) { Command = MenuCommand, ViewType = typeof(OperateLogView) });
- sysMenu.Add(MenuCommandType.ReportQuery,
- new SysMenuItem(MenuCommandType.ReportQuery) { Command = MenuCommand, ViewType = null, IsDialog = true, }); //todo:报表ViewModel
- //公告通知
- sysMenu.Add(MenuCommandType.NoticeInform, new SysMenuItem(MenuCommandType.NoticeInform));
- sysMenu.Add(MenuCommandType.Notice,
- new SysMenuItem(MenuCommandType.Notice) { Command = AnnouncementCommand, ViewType = typeof(NoticesView), IsDialog = true });
- sysMenu.Add(MenuCommandType.Notify,
- new SysMenuItem(MenuCommandType.Notify) { Command = AnnouncementCommand, ViewType = typeof(NoticesView), IsDialog = true });
- //买入 卖出 撤单
- //sysMenu.Add(MenuCommandType.BuyIn, new SysMenuItem(MenuCommandType.BuyIn) { Command = SimpleIoc.Default.GetInstance<TradeHeaderViewModel>().BuyCommand });
- //sysMenu.Add(MenuCommandType.Sellout, new SysMenuItem(MenuCommandType.Sellout) { Command = SimpleIoc.Default.GetInstance<TradeHeaderViewModel>().SellCommand });
- //sysMenu.Add(MenuCommandType.Cancel, new SysMenuItem(MenuCommandType.Cancel) { Command = SimpleIoc.Default.GetInstance<TradeHeaderViewModel>().CancelCommand });
- sysMenu.Add(MenuCommandType.Trade, new SysMenuItem(MenuCommandType.Trade));
- sysMenu.Add(MenuCommandType.AmountQuety,
- new SysMenuItem(MenuCommandType.AmountQuety) { Command = MenuCommand, ViewType = typeof(AmountQuetyView) });
- ////资金流水查询
- sysMenu.Add(MenuCommandType.QueryAmountLog,
- new SysMenuItem(MenuCommandType.QueryAmountLog) { Command = MenuCommand, ViewType = typeof(QueryTaAmountLogListView) });
- ////协议平仓查询
- sysMenu.Add(MenuCommandType.DealClose, new SysMenuItem(MenuCommandType.DealClose) { Command = MenuCommand, ViewType = typeof(DealCloseView) });
- sysMenu.Add(MenuCommandType.HistoryOrder, new SysMenuItem(MenuCommandType.HistoryOrder) { Command = MenuCommand, ViewType = typeof(HistoryOrderQueryView) });
- //资管止盈止损查询
- sysMenu.Add(MenuCommandType.SPSLOrder, new SysMenuItem(MenuCommandType.SPSLOrder) { Command = MenuCommand, ViewType = typeof(MOMainSPSLListView) });
- return sysMenu;
- }
- private ICommand _menuCommand;
- /// <summary>
- /// 菜单操作
- /// </summary>
- public ICommand MenuCommand
- {
- get
- {
- if (_menuCommand == null)
- {
- _menuCommand = new RelayCommand<SysMenuItem>((item) =>
- {
- if (!item.IsDialog)
- {
- var type = item.ViewType;
- var assembly = System.Reflection.Assembly.GetAssembly(type);
- var view = assembly.CreateInstance(type.FullName, false, System.Reflection.BindingFlags.CreateInstance, null, item.Params == null ? null : item.Params.ToArray(), null, null) as FrameworkElement;
- if (view != null)
- {
- MessengerHelper.DefaultSend(view, MessengerTokens.ShowQueryContet);
- }
- }
- else
- {
- var type = item.ViewType;
- if (type == null) return;
- var assembly = System.Reflection.Assembly.GetAssembly(type);
- var view = assembly.CreateInstance(type.FullName, false, System.Reflection.BindingFlags.CreateInstance, null, item.Params == null ? null : item.Params.ToArray(), null, null) as Window;
- if (view != null)
- {
- view.ShowDialog();
- }
- }
- });
- }
- return _menuCommand;
- }
- }
- private ICommand _announcementCommand;
- /// <summary>
- /// 公告通知命令
- /// </summary>
- public ICommand AnnouncementCommand
- {
- get
- {
- if (_announcementCommand == null)
- {
- _announcementCommand = new RelayCommand<SysMenuItem>((item) =>
- {
- var type = item.ViewType;
- if (type == null) return;
- // var window = new NoticesView( );
- NoticesBase notices = null;
- if (item.SysCommandType == MenuCommandType.Notice)
- {
- // window.DataContext = new NoticesViewModel();
- notices = new NoticesViewModel();
- }
- else
- {
- // window.DataContext = new TradeMessageViewModel();
- notices = new TradeMessageViewModel();
- }
- //window.Owner = Application.Current.MainWindow;
- //window.WindowStartupLocation = WindowStartupLocation.CenterOwner;
- //window.ShowInTaskbar = false;
- //window.ShowDialog();
- MessengerHelper.DefaultSend(notices, MessengerTokens.AnnouncementDetail);
- });
- }
- return _announcementCommand;
- }
- }
- }
- }
|