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 { /// /// 查询账号信息菜单 /// /// public Dictionary GetModuleMenuItems() { var sysMenu = new Dictionary(); 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().BuyCommand }); //sysMenu.Add(MenuCommandType.Sellout, new SysMenuItem(MenuCommandType.Sellout) { Command = SimpleIoc.Default.GetInstance().SellCommand }); //sysMenu.Add(MenuCommandType.Cancel, new SysMenuItem(MenuCommandType.Cancel) { Command = SimpleIoc.Default.GetInstance().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; /// /// 菜单操作 /// public ICommand MenuCommand { get { if (_menuCommand == null) { _menuCommand = new RelayCommand((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; /// /// 公告通知命令 /// public ICommand AnnouncementCommand { get { if (_announcementCommand == null) { _announcementCommand = new RelayCommand((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; } } } }