using System; using System.Collections.Generic; using System.ComponentModel.Design; using System.Linq; using System.Text; //---------------------------------------------------------------- //Module Name: $safeprojectname$ //Purpose: //CopyRight: Muchinfo //History: //---------------------------------------------------------------- //DateTime 2016/4/19 17:09:50 //Author //Description Create //---------------------------------------------------------------- using System.Windows; using System.Windows.Input; using GalaSoft.MvvmLight.Command; using GalaSoft.MvvmLight.Ioc; using GalaSoft.MvvmLight.Messaging; using Muchinfo.MTPClient.Data; using Muchinfo.MTPClient.Data.Enums; using Muchinfo.MTPClient.Infrastructure.Cache; using Muchinfo.MTPClient.Infrastructure.Helpers; using Muchinfo.MTPClient.IService; using Muchinfo.MTPClient.Sale.ViewModels; using Muchinfo.MTPClient.Sale.Views; namespace Muchinfo.MTPClient.Sale.Utilities { public class SaleMenuService:IModuleMenuService { public Dictionary GetModuleMenuItems() { var sysMenu = new Dictionary(); //sysMenu.Add(MenuCommandType.SaleOrder, new SysMenuItem(MenuCommandType.SaleOrder)); // sysMenu.Add(MenuCommandType.AccountInfo, // new SysMenuItem(MenuCommandType.AccountInfo) { Command = MenuCommand, View = new QueryDealPurchaseView()}); //sysMenu.Add(MenuCommandType.SaleApply, new SysMenuItem(MenuCommandType.SaleApply) { Command = SimpleIoc.Default.GetInstance().DetailCommand } ); sysMenu.Add(MenuCommandType.Distribute, new SysMenuItem(MenuCommandType.Distribute) { Command = MenuCommand, ViewType = typeof(DistributeBallotView) }); var showQuery = CacheManager.CacheMarketsGroups != null && CacheManager.CacheMarketsGroups.Any((goodsGroups) => goodsGroups.TradeMode == eTradeMode.TRADEMODE_SALE); if (showQuery) ////没有发售市场不显示 { sysMenu.Add(MenuCommandType.DepositQuery, new SysMenuItem(MenuCommandType.DepositQuery) { Command = MenuCommand, ViewType = typeof (QueryDepositAppView) }); } 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; } } } }