BankMenuService.cs 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. //----------------------------------------------------------------
  6. //Module Name: $safeprojectname$
  7. //Purpose:
  8. //CopyRight: Muchinfo
  9. //History:
  10. //----------------------------------------------------------------
  11. //DateTime 2016/4/14 15:53:02
  12. //Author
  13. //Description Create
  14. //----------------------------------------------------------------
  15. using System.Windows;
  16. using System.Windows.Input;
  17. using GalaSoft.MvvmLight.Command;
  18. using GalaSoft.MvvmLight.Messaging;
  19. using Muchinfo.MTPClient.Bank.Views;
  20. using Muchinfo.MTPClient.Data;
  21. using Muchinfo.MTPClient.Data.Enums;
  22. using Muchinfo.MTPClient.Infrastructure.Helpers;
  23. using Muchinfo.MTPClient.IService;
  24. namespace Muchinfo.MTPClient.Bank.ViewModels
  25. {
  26. public class BankMenuService : IModuleMenuService
  27. {
  28. public Dictionary<Data.Enums.MenuCommandType, Data.SysMenuItem> GetModuleMenuItems()
  29. {
  30. var sysMenu = new Dictionary<MenuCommandType, SysMenuItem>();
  31. //消息中心
  32. sysMenu.Add(MenuCommandType.BreakSign, new SysMenuItem(MenuCommandType.BreakSign));
  33. //sysMenu.Add(MenuCommandType.Notice,
  34. // new SysMenuItem(MenuCommandType.Notice) { Command = MenuCommand, View = new AmountManagerView(), IsDialog = true });
  35. sysMenu.Add(MenuCommandType.BankSign,
  36. new SysMenuItem(MenuCommandType.BankSign) { Command = MenuCommand, ViewType = typeof(BankSignQueryView),});
  37. sysMenu.Add(MenuCommandType.AmountQuety,
  38. new SysMenuItem(MenuCommandType.AmountQuety) { Command = MenuCommand, ViewType = typeof(AmountQuetyView), });
  39. //sysMenu.Add(MenuCommandType.BankBreak,
  40. // new SysMenuItem(MenuCommandType.BankBreak) { Command = MenuCommand, ViewType = typeof(BankTerminationView), IsDialog = true });
  41. sysMenu.Add(MenuCommandType.BankUpdate,
  42. new SysMenuItem(MenuCommandType.BankUpdate) { Command = MenuCommand, ViewType = typeof(BankUpdateView), IsDialog = true });
  43. sysMenu.Add(MenuCommandType.Apply, new SysMenuItem(MenuCommandType.Apply));
  44. // sysMenu.Add(MenuCommandType.AmountInApply,
  45. //new SysMenuItem(MenuCommandType.AmountInApply) { Command = MenuCommand, ViewType = typeof(AmountManagerView), Params = new List<object>() { FundsApplyType.Deposit }, IsDialog = true });
  46. // sysMenu.Add(MenuCommandType.AmountOutApply,
  47. // new SysMenuItem(MenuCommandType.AmountOutApply) { Command = MenuCommand, ViewType = typeof (AmountManagerView),Params=new List<object>() { FundsApplyType.Withdraw }, IsDialog = true });
  48. // sysMenu.Add(MenuCommandType.Apply,
  49. return sysMenu;
  50. }
  51. private ICommand _menuCommand;
  52. /// <summary>
  53. /// 菜单操作
  54. /// </summary>
  55. public ICommand MenuCommand
  56. {
  57. get
  58. {
  59. if (_menuCommand == null)
  60. {
  61. _menuCommand = new RelayCommand<SysMenuItem>((item) =>
  62. {
  63. if (!item.IsDialog)
  64. {
  65. var type = item.ViewType;
  66. var assembly = System.Reflection.Assembly.GetAssembly(type);
  67. var view = assembly.CreateInstance(type.FullName, false, System.Reflection.BindingFlags.CreateInstance, null, item.Params == null ? null : item.Params.ToArray(), null, null) as FrameworkElement;
  68. if (view != null)
  69. {
  70. MessengerHelper.DefaultSend(view, MessengerTokens.ShowQueryContet);
  71. }
  72. }
  73. else
  74. {
  75. var type= item.ViewType;
  76. var assembly= System.Reflection.Assembly.GetAssembly(type);
  77. var view = assembly.CreateInstance(type.FullName,false,System.Reflection.BindingFlags.CreateInstance,null, item.Params==null?null:item.Params.ToArray(),null,null) as Window;
  78. if (view != null)
  79. {
  80. view.WindowStartupLocation = WindowStartupLocation.CenterOwner;
  81. view.Owner = Application.Current.MainWindow;
  82. view.ShowInTaskbar = false;
  83. view.ShowDialog();
  84. }
  85. }
  86. });
  87. }
  88. return _menuCommand;
  89. }
  90. }
  91. }
  92. }