using GalaSoft.MvvmLight.Command; using Muchinfo.MTPClient.Data; using Muchinfo.MTPClient.Data.Enums; using Muchinfo.MTPClient.Delivery.Views; using Muchinfo.MTPClient.Infrastructure.Helpers; using Muchinfo.MTPClient.IService; using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Windows; using System.Windows.Input; namespace Muchinfo.MTPClient.Delivery.Utilities { /// /// 交收管理菜单 /// Add By DK 20160804 /// public class DeliveryMenuService : IModuleMenuService { /// /// Gets the module menu items. /// /// System.Collections.Generic.Dictionary{Muchinfo.MTPClient.Data.Enums.MenuCommandType,Muchinfo.MTPClient.Data.SysMenuItem}. public Dictionary GetModuleMenuItems() { var sysMenu = new Dictionary(); sysMenu.Add(MenuCommandType.DeliveryManage, new SysMenuItem(MenuCommandType.DeliveryManage)); sysMenu.Add(MenuCommandType.DeliveryDeclaration, new SysMenuItem(MenuCommandType.DeliveryDeclaration) { Command = MenuCommand, ViewType = typeof(NDeliveryOrderView), IsDialog = true }); //sysMenu.Add(MenuCommandType.DeliveryDeclarationSearch, new SysMenuItem(MenuCommandType.DeliveryDeclarationSearch) { Command = MenuCommand, ViewType = typeof(DeliveryEntructOrderView), }); sysMenu.Add(MenuCommandType.DeliveryDeclarationSearch, new SysMenuItem(MenuCommandType.DeliveryDeclarationSearch) { Command = MenuCommand, ViewType = typeof(NDeliveryEntructOrderView), }); sysMenu.Add(MenuCommandType.DeliveryOrderSearch, new SysMenuItem(MenuCommandType.DeliveryOrderSearch) { Command = MenuCommand, ViewType = typeof(DryHoldDetailView), }); sysMenu.Add(MenuCommandType.WarehouseManagement, new SysMenuItem(MenuCommandType.WarehouseManagement)); //仓单查询 sysMenu.Add(MenuCommandType.WarehouseSearch, new SysMenuItem(MenuCommandType.WarehouseSearch) { Command = MenuCommand, ViewType = typeof(DeliveryWarehouseOrderView), }); //提货申请 sysMenu.Add(MenuCommandType.TakaDeliveryGoodsApply, new SysMenuItem(MenuCommandType.TakaDeliveryGoodsApply) { Command = MenuCommand, ViewType = typeof(TakaDeliveryGoodsApplyView), IsDialog = true }); //提货查询 sysMenu.Add(MenuCommandType.TakaDeliveryGoodsQuery, new SysMenuItem(MenuCommandType.TakaDeliveryGoodsQuery) { Command = MenuCommand, ViewType = typeof(TakaDeliveryGoodsQueryView), }); //成交单查询 sysMenu.Add(MenuCommandType.DeliveryComplete, new SysMenuItem(MenuCommandType.DeliveryComplete) { Command = MenuCommand, ViewType = typeof(DeliveryComplete), }); 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.Owner = Application.Current.MainWindow; view.WindowStartupLocation = WindowStartupLocation.CenterOwner; view.ShowDialog(); } } }); } return _menuCommand; } } } }