CChartView.xaml.cs 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  1. using System;
  2. using System.Windows.Input;
  3. using Muchinfo.MTPClient.Analysis.ViewModels;
  4. using Muchinfo.MTPClient.Data.Enums;
  5. using Muchinfo.MTPClient.Infrastructure.Interfaces;
  6. using Muchinfo.MTPClient.Infrastructure.Utilities;
  7. using System.Windows;
  8. using System.Windows.Forms;
  9. using KeyEventArgs = System.Windows.Input.KeyEventArgs;
  10. using UserControl = System.Windows.Controls.UserControl;
  11. namespace Muchinfo.MTPClient.Analysis.Views
  12. {
  13. /// <summary>
  14. /// CChartView.xaml 的交互逻辑
  15. /// </summary>
  16. public partial class CChartView : UserControl, IDisposable
  17. {
  18. public CChartView(ChartWindowItem chartItem)
  19. {
  20. InitializeComponent();
  21. var userControl = new System.Windows.Forms.ListView();
  22. // userControl.BackColor = System.Drawing.Color.Transparent;
  23. var colorStyle = UserManager.GetCurrentColorStyle();
  24. switch (colorStyle)
  25. {
  26. case ColorStyle.BlueWhite:
  27. userControl.BackColor = System.Drawing.Color.White;
  28. break;
  29. case ColorStyle.DarkBlue:
  30. case ColorStyle.CoolBlack:
  31. userControl.BackColor = System.Drawing.Color.Black;
  32. break;
  33. default:
  34. break;
  35. }
  36. userControl.BorderStyle = BorderStyle.None;
  37. FormsHost.Child = userControl;
  38. var handle = userControl.Handle.ToInt32();
  39. var goods = chartItem.Goods;
  40. this.DataContext = new CChartViewModel(goods, handle);
  41. // _currentGoods = goods;
  42. // _quoteDataService = SimpleIoc.Default.GetInstance<IQuoteDataService>();
  43. // WareAttributeClass war = ConverWare(goods);
  44. // this.m_Ware = war;
  45. //// QuoteChartManager.AddWare(this.Ware);
  46. // AddWare(war);
  47. // CreateChartView(_currentGoods);
  48. //MessengerHelper.DefaultRegister<CommandFunc>(this, MessengerTokens.QuoteGoodsListToken, (msg) =>
  49. //{
  50. // var viewModel = this.DataContext as CChartViewModel;
  51. // if (viewModel == null)
  52. // {
  53. // return;
  54. // }
  55. // if (this.IsKeyboardFocusWithin)
  56. // {
  57. // switch (msg)
  58. // {
  59. // case CommandFunc.QuotePageDown:
  60. // viewModel.ChangeGoodsNextFront(true);
  61. // break;
  62. // case CommandFunc.QuotePageup:
  63. // viewModel.ChangeGoodsNextFront(false);
  64. // break;
  65. // }
  66. // }
  67. //});
  68. }
  69. private void CChartView_OnUnloaded(object sender, RoutedEventArgs e)
  70. {
  71. this.InputBindings.Clear();
  72. // var dataContext = this.DataContext as CChartViewModel;
  73. //if (dataContext != null)
  74. //{
  75. // dataContext.Dispose();
  76. //}
  77. }
  78. public void Dispose()
  79. {
  80. this.InputBindings.Clear();
  81. TabPriceView.Dispose();
  82. }
  83. private void CChartView_OnLoaded(object sender, RoutedEventArgs e)
  84. {
  85. FormsHost.Focusable = true;
  86. FormsHost.Focus();
  87. }
  88. private void FormsHost_OnKeyUp(object sender, KeyEventArgs e)
  89. {
  90. var dataContext = this.DataContext as CChartViewModel;
  91. if (dataContext != null)
  92. {
  93. if (e.Key == Key.PageDown || e.Key == Key.PageUp)
  94. {
  95. dataContext.EnterCommand.Execute(e.Key);
  96. }
  97. }
  98. }
  99. private void FormsHost_OnLoaded(object sender, RoutedEventArgs e)
  100. {
  101. FormsHost.Focus();
  102. }
  103. }
  104. }