WindowHelper.cs 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151
  1. using Muchinfo.MTPClient.Data.Enums;
  2. using Muchinfo.MTPClient.Infrastructure.Enums;
  3. using Muchinfo.MTPClient.Infrastructure.MessengerArgs;
  4. using System;
  5. using System.Collections.Generic;
  6. using System.Diagnostics;
  7. using System.Reflection;
  8. using System.Windows;
  9. using System.Windows.Controls;
  10. namespace Muchinfo.MTPClient.UI.Utilities
  11. {
  12. public class WindowHelper
  13. {
  14. public const string restratCommand = "restart";
  15. /// <summary>
  16. /// 缓存窗口信息
  17. /// </summary>
  18. private static Dictionary<WindowType, UserControl> _windowsDictionary = new Dictionary<WindowType, UserControl>();
  19. #region Public Static Methods
  20. /// <summary>
  21. /// 添加内容窗口
  22. /// </summary>
  23. /// <param name="arg">The arg.</param>
  24. public static void OpenWindow(OpenWindowArg arg)
  25. {
  26. switch (arg.Type)
  27. {
  28. }
  29. }
  30. /// <summary>
  31. /// 打开新闻窗口
  32. /// </summary>
  33. /// <param name="categoryCode">The category code.</param>
  34. public static void OpenNewsWindow(string categoryCode, string newsId = "")
  35. {
  36. return;
  37. //var newsView = WindowHelper.GetWindow<NewsView>(WindowType.NewsView);
  38. //if (newsView == null)
  39. //{
  40. // var item = new NewsWindowItem(MenuNames.News, categoryCode, newsId);
  41. // var window = new NewsView(item);
  42. // window.ShowWindow();
  43. //}
  44. //else
  45. //{
  46. // newsView.NavigateTo(categoryCode, newsId);
  47. // newsView.ShowWindow();
  48. //}
  49. }
  50. /// <summary>
  51. /// 打开分析窗口
  52. /// </summary>
  53. /// <param name="arg">The arg.</param>
  54. public static void OpenQuoteChartWindow(OpenQuoteChartWindowArg arg)
  55. {
  56. return;
  57. //if (arg == null || arg.Goods == null) return;
  58. //var quoteChartView = GetWindow<FormChartView>(WindowType.QuoteChartView);
  59. //if (arg.CreateNew || quoteChartView == null)
  60. //{
  61. // var item = AnalysisWindowHelper.CreateQuoteChartWindowItem(arg.Goods, arg.CycleType);
  62. // if (ApplicationParameter.QuotationProxy == 1)
  63. // {
  64. // //报价牌放在分析图的位置,0-不显示,1-左边,2-右边
  65. // var window = new FormChartView(item)
  66. // {
  67. // //PriceCard = PriceCardHelper.GetPriceCard(arg.Goods),
  68. // //PriceCardPosition = 2
  69. // };
  70. // window.ShowWindow();
  71. // }
  72. // else
  73. // {
  74. // //报价牌放在分析图的位置,0-不显示,1-左边,2-右边
  75. // var window = new QuoteChartView(item)
  76. // {
  77. // PriceCard = PriceCardHelper.GetPriceCard(arg.Goods),
  78. // PriceCardPosition = 2
  79. // };
  80. // window.ShowWindow();
  81. // }
  82. //}
  83. ////else
  84. ////{
  85. //// quoteChartView.UpdateGoods(arg.Goods, arg.CycleType);
  86. //// quoteChartView.ShowWindow();
  87. ////}
  88. //MessengerHelper.DefaultSend<bool>(true, MessengerTokens.ShowChartMsg); ////显示图表
  89. //MessengerHelper.DefaultSend(TradeTreeMenu.AccountInfo, MessengerTokens.AccountFunction);
  90. ////激活Tab标签
  91. //MessengerHelper.DefaultSend<WindowType>(WindowType.QuoteChartView, MessengerTokens.ActiveHomeTab);
  92. }
  93. /// <summary>
  94. /// Shows the amount manager.
  95. /// </summary>
  96. /// <param name="applyType">Type of the apply.</param>
  97. public static void ShowAmountManager(FundsApplyType applyType)
  98. {
  99. return;
  100. //if (UserManager.CurrentTradeAccount == null)
  101. //{
  102. // MessageBoxHelper.ShowInfo(Client_Resource.UI2014_PleaseLogin, Muchinfo.MTPClient.Resources.Client_Resource.UI2014_LoginTips);
  103. //}
  104. //else
  105. //{
  106. // GalaSoft.MvvmLight.Threading.DispatcherHelper.RunAsync(() =>
  107. // {
  108. // var dialog = new AmountManagerView(applyType) { Owner = Application.Current.MainWindow };
  109. // dialog.ShowDialog();
  110. // });
  111. //}
  112. }
  113. /// <summary>
  114. /// 重新启动应用程序
  115. /// </summary>
  116. /// <param name="isRerun">是否重新启动程序</param>
  117. public static void RerunApplication(bool isRerun = true)
  118. {
  119. ////关闭CEF浏览器
  120. //CefRuntime.Shutdown();
  121. CefSharp.CEF.Shutdown();
  122. var assembly = Assembly.GetEntryAssembly();
  123. if (isRerun) Process.Start(assembly.Location, restratCommand);
  124. if (Application.Current != null)
  125. {
  126. Environment.Exit(0);
  127. }
  128. }
  129. #endregion Public Static Methods
  130. }
  131. }