| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374 |
- using GalaSoft.MvvmLight.Command;
- using Muchinfo.MTPClient.Account.Views;
- using Muchinfo.MTPClient.Data;
- using Muchinfo.MTPClient.Data.Enums;
- using Muchinfo.MTPClient.Infrastructure.Helpers;
- using Muchinfo.MTPClient.IService;
- using System.Collections.Generic;
- using System.Windows;
- using System.Windows.Input;
- namespace Muchinfo.MTPClient.Account.ViewModels
- {
- /// <summary>
- /// 关于公告菜单的定义
- /// </summary>
- public class AnnouncementMenuService : IModuleMenuService
- {
- public Dictionary<Data.Enums.MenuCommandType, Data.SysMenuItem> GetModuleMenuItems()
- {
- var sysMenu = new Dictionary<MenuCommandType, SysMenuItem>();
- //公告通知
- sysMenu.Add(MenuCommandType.NoticeInform, new SysMenuItem(MenuCommandType.NoticeInform));
- //公告
- //sysMenu.Add(MenuCommandType.Notice, new SysMenuItem(MenuCommandType.Notice) { Command = MenuCommand, ViewType = typeof(SystemAnnouncementView), IsDialog = true });
- ////通知
- //sysMenu.Add(MenuCommandType.Notify, new SysMenuItem(MenuCommandType.Notify) { Command = MenuCommand, ViewType = typeof(SystemAnnouncementView), IsDialog = true });
- return sysMenu;
- }
- private ICommand _menuCommand;
- /// <summary>
- /// 菜单操作
- /// </summary>
- public ICommand MenuCommand
- {
- get
- {
- if (_menuCommand == null)
- {
- _menuCommand = new RelayCommand<SysMenuItem>((item) =>
- {
- if (!item.IsDialog)
- {
- var view = item.View 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.ShowDialog();
- }
- }
- });
- }
- return _menuCommand;
- }
- }
- }
- }
|