| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114 |
- using System;
- using System.Windows.Input;
- using Muchinfo.MTPClient.Analysis.ViewModels;
- using Muchinfo.MTPClient.Data.Enums;
- using Muchinfo.MTPClient.Infrastructure.Interfaces;
- using Muchinfo.MTPClient.Infrastructure.Utilities;
- using System.Windows;
- using System.Windows.Forms;
- using KeyEventArgs = System.Windows.Input.KeyEventArgs;
- using UserControl = System.Windows.Controls.UserControl;
- namespace Muchinfo.MTPClient.Analysis.Views
- {
- /// <summary>
- /// CChartView.xaml 的交互逻辑
- /// </summary>
- public partial class CChartView : UserControl, IDisposable
- {
- public CChartView(ChartWindowItem chartItem)
- {
- InitializeComponent();
- var userControl = new System.Windows.Forms.ListView();
- // userControl.BackColor = System.Drawing.Color.Transparent;
- var colorStyle = UserManager.GetCurrentColorStyle();
- switch (colorStyle)
- {
- case ColorStyle.BlueWhite:
- userControl.BackColor = System.Drawing.Color.White;
- break;
- case ColorStyle.DarkBlue:
- case ColorStyle.CoolBlack:
- userControl.BackColor = System.Drawing.Color.Black;
- break;
- default:
- break;
- }
- userControl.BorderStyle = BorderStyle.None;
- FormsHost.Child = userControl;
- var handle = userControl.Handle.ToInt32();
- var goods = chartItem.Goods;
- this.DataContext = new CChartViewModel(goods, handle);
- // _currentGoods = goods;
- // _quoteDataService = SimpleIoc.Default.GetInstance<IQuoteDataService>();
- // WareAttributeClass war = ConverWare(goods);
- // this.m_Ware = war;
- //// QuoteChartManager.AddWare(this.Ware);
- // AddWare(war);
- // CreateChartView(_currentGoods);
- //MessengerHelper.DefaultRegister<CommandFunc>(this, MessengerTokens.QuoteGoodsListToken, (msg) =>
- //{
- // var viewModel = this.DataContext as CChartViewModel;
- // if (viewModel == null)
- // {
- // return;
- // }
- // if (this.IsKeyboardFocusWithin)
- // {
- // switch (msg)
- // {
- // case CommandFunc.QuotePageDown:
- // viewModel.ChangeGoodsNextFront(true);
- // break;
- // case CommandFunc.QuotePageup:
- // viewModel.ChangeGoodsNextFront(false);
- // break;
- // }
- // }
- //});
- }
- private void CChartView_OnUnloaded(object sender, RoutedEventArgs e)
- {
- this.InputBindings.Clear();
- // var dataContext = this.DataContext as CChartViewModel;
- //if (dataContext != null)
- //{
- // dataContext.Dispose();
- //}
- }
- public void Dispose()
- {
- this.InputBindings.Clear();
- TabPriceView.Dispose();
- }
- private void CChartView_OnLoaded(object sender, RoutedEventArgs e)
- {
- FormsHost.Focusable = true;
- FormsHost.Focus();
- }
- private void FormsHost_OnKeyUp(object sender, KeyEventArgs e)
- {
- var dataContext = this.DataContext as CChartViewModel;
- if (dataContext != null)
- {
- if (e.Key == Key.PageDown || e.Key == Key.PageUp)
- {
- dataContext.EnterCommand.Execute(e.Key);
- }
- }
- }
- private void FormsHost_OnLoaded(object sender, RoutedEventArgs e)
- {
- FormsHost.Focus();
- }
- }
- }
|