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
{
///
/// 关于公告菜单的定义
///
public class AnnouncementMenuService : IModuleMenuService
{
public Dictionary GetModuleMenuItems()
{
var sysMenu = new Dictionary();
//公告通知
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;
///
/// 菜单操作
///
public ICommand MenuCommand
{
get
{
if (_menuCommand == null)
{
_menuCommand = new RelayCommand((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;
}
}
}
}