using System; using System.Collections.Generic; using System.Linq; using System.Text; //---------------------------------------------------------------- //Module Name: $safeprojectname$ //Purpose: //CopyRight: Muchinfo //History: //---------------------------------------------------------------- //DateTime 2016/4/14 15:53:02 //Author //Description Create //---------------------------------------------------------------- using System.Windows; using System.Windows.Input; using GalaSoft.MvvmLight.Command; using GalaSoft.MvvmLight.Messaging; using Muchinfo.MTPClient.Bank.Views; using Muchinfo.MTPClient.Data; using Muchinfo.MTPClient.Data.Enums; using Muchinfo.MTPClient.Infrastructure.Helpers; using Muchinfo.MTPClient.IService; namespace Muchinfo.MTPClient.Bank.ViewModels { public class BankMenuService : IModuleMenuService { public Dictionary GetModuleMenuItems() { var sysMenu = new Dictionary(); //消息中心 sysMenu.Add(MenuCommandType.BreakSign, new SysMenuItem(MenuCommandType.BreakSign)); //sysMenu.Add(MenuCommandType.Notice, // new SysMenuItem(MenuCommandType.Notice) { Command = MenuCommand, View = new AmountManagerView(), IsDialog = true }); sysMenu.Add(MenuCommandType.BankSign, new SysMenuItem(MenuCommandType.BankSign) { Command = MenuCommand, ViewType = typeof(BankSignQueryView),}); sysMenu.Add(MenuCommandType.AmountQuety, new SysMenuItem(MenuCommandType.AmountQuety) { Command = MenuCommand, ViewType = typeof(AmountQuetyView), }); //sysMenu.Add(MenuCommandType.BankBreak, // new SysMenuItem(MenuCommandType.BankBreak) { Command = MenuCommand, ViewType = typeof(BankTerminationView), IsDialog = true }); sysMenu.Add(MenuCommandType.BankUpdate, new SysMenuItem(MenuCommandType.BankUpdate) { Command = MenuCommand, ViewType = typeof(BankUpdateView), IsDialog = true }); sysMenu.Add(MenuCommandType.Apply, new SysMenuItem(MenuCommandType.Apply)); // sysMenu.Add(MenuCommandType.AmountInApply, //new SysMenuItem(MenuCommandType.AmountInApply) { Command = MenuCommand, ViewType = typeof(AmountManagerView), Params = new List() { FundsApplyType.Deposit }, IsDialog = true }); // sysMenu.Add(MenuCommandType.AmountOutApply, // new SysMenuItem(MenuCommandType.AmountOutApply) { Command = MenuCommand, ViewType = typeof (AmountManagerView),Params=new List() { FundsApplyType.Withdraw }, IsDialog = true }); // sysMenu.Add(MenuCommandType.Apply, 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; 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.WindowStartupLocation = WindowStartupLocation.CenterOwner; view.Owner = Application.Current.MainWindow; view.ShowInTaskbar = false; view.ShowDialog(); } } }); } return _menuCommand; } } } }