MainContentViewModel.cs 32 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809
  1. using GalaSoft.MvvmLight;
  2. using GalaSoft.MvvmLight.Ioc;
  3. using GalaSoft.MvvmLight.Threading;
  4. using Muchinfo.MTPClient.Account.ViewModels;
  5. using Muchinfo.MTPClient.Analysis.ViewModels;
  6. using Muchinfo.MTPClient.Analysis.Views;
  7. using Muchinfo.MTPClient.Analysis.Views.PriceCard;
  8. using Muchinfo.MTPClient.Data.DTO;
  9. using Muchinfo.MTPClient.Data.Enums;
  10. using Muchinfo.MTPClient.Data.Model;
  11. using Muchinfo.MTPClient.Data.Model.Account;
  12. using Muchinfo.MTPClient.Data.Model.Analysis;
  13. using Muchinfo.MTPClient.Data.Model.Listing;
  14. using Muchinfo.MTPClient.Infrastructure.Cache;
  15. using Muchinfo.MTPClient.Infrastructure.Enums;
  16. using Muchinfo.MTPClient.Infrastructure.Helpers;
  17. using Muchinfo.MTPClient.Infrastructure.Interfaces;
  18. using Muchinfo.MTPClient.Infrastructure.MessengerArgs;
  19. using Muchinfo.MTPClient.Infrastructure.Utilities;
  20. using Muchinfo.MTPClient.IService;
  21. using Muchinfo.MTPClient.Listing.ViewModel;
  22. using Muchinfo.MTPClient.Listing.Views;
  23. using Muchinfo.MTPClient.Report.Views;
  24. using System;
  25. using System.Collections.Generic;
  26. using System.Linq;
  27. //----------------------------------------------------------------
  28. //Module Name: $safeprojectname$
  29. //Purpose:
  30. //CopyRight: Muchinfo
  31. //History:
  32. //----------------------------------------------------------------
  33. //DateTime 2016/2/17 17:33:10
  34. //Author
  35. //Description Create
  36. //----------------------------------------------------------------
  37. using System.Windows;
  38. namespace Muchinfo.MTPClient.UI.ViewModels
  39. {
  40. public class MainContentViewModel : ViewModelBase
  41. {
  42. private int _oldTabIndex;
  43. private IGoodsService _goodsService;
  44. private MarketsInfoModel _currentGroup;
  45. private SearchCommissionsParameter parameters;
  46. public MainContentViewModel()
  47. {
  48. //DataGrid currentDataGrid = QuoteDataGridHelper.FindChild<DataGrid>(Application.Current.MainWindow, "QuoteListDataGrid");
  49. //currentDataGrid.Focus();
  50. //打开内容窗口
  51. // MessengerHelper.DefaultRegister<AddContentPageArgs>(this, MessengerTokens.AddContentPage, AddContentPage);
  52. _goodsService = SimpleIoc.Default.GetInstance<IGoodsService>();
  53. // _oldTabIndex = 9;
  54. TabContetMode = TabContetMode.QuoteList;
  55. //todo: 默认显示的,改成由左边标签类型来做实现
  56. //var window = new QuoteListView(null);
  57. //window.ShowWindow();
  58. IsShowChart = !UserManager.IsAccountLogin; ////游客登录默认显示图表
  59. MessengerHelper.DefaultRegister<QuoteGoodsDTO>(this, MessengerTokens.SelectGoodsChange, SelectGoodsChange);
  60. ////此消息不能在Dispatcher线程处理,否则会使左边功能RadioButton显示出错
  61. MessengerHelper.DefaultRegister<MarketsInfoModel>(this, MessengerTokens.SelectGoodsGroupChange,
  62. SelectGoodsGrounpChange, false);
  63. MessengerHelper.DefaultRegister<OpenQuoteChartWindowArg>(this, MessengerTokens.OpenQuoteChartWindow,
  64. (e) =>
  65. {
  66. TabContetMode = TabContetMode.QuoteChart;
  67. });
  68. ///主窗口发送F10快捷键命令
  69. MessengerHelper.DefaultRegister<TabContetMode>(this, MessengerTokens.ChangeGoodsInfo,
  70. (e) =>
  71. {
  72. ShowF10();
  73. });
  74. ///主窗口发送五档历史
  75. MessengerHelper.DefaultRegister<SearchCommissionsParameter>(this, MessengerTokens.HistoryCommissionsTab,
  76. (e) =>
  77. {
  78. this.parameters = e;
  79. TabContetMode = TabContetMode.HistoryCommissions;
  80. });
  81. ///
  82. MessengerHelper.DefaultRegister<TabContetMode>(this, MessengerTokens.MainContentChange, (e) =>
  83. {
  84. if (e == TabContetMode.QuoteChart)
  85. {
  86. if (_currentGroup == null || _currentGroup.TradeMode == eTradeMode.TRADEMODE_SALE ||
  87. _currentGroup.TradeMode == eTradeMode.TRADEMODE_HANGTAG)
  88. {
  89. return;
  90. }
  91. }
  92. TabContetMode = e;
  93. });
  94. ///布局改变时,图表需重新生成
  95. MessengerHelper.DefaultRegister<LayoutStyle>(this, MessengerTokens.UpdateLayoutChange, (layout) =>
  96. {
  97. LogInfoHelper.WriteInfo(" Enter MessengerTokens.UpdateLayoutChange");
  98. if (TabContetMode == TabContetMode.QuoteChart)
  99. {
  100. if (this.SelectedQuoteGoods != null)
  101. {
  102. if (Content != null && Content.DataContext is IDisposable)
  103. {
  104. Content.InputBindings.Clear();
  105. (Content.DataContext as IDisposable).Dispose(); ////清除图表数据,注册消息
  106. if (Content is IDisposable)
  107. {
  108. (Content as IDisposable).Dispose();
  109. }
  110. }
  111. // var formchart = new FormChartView(new ChartWindowItem(string.Empty, this.SelectedQuoteGoods, CycleType.Minutes1));
  112. var formchart =
  113. new CChartView(new ChartWindowItem(string.Empty, this.SelectedQuoteGoods, CycleType.Minutes1));
  114. Content = formchart;
  115. }
  116. }
  117. });
  118. ////显示历史Tik分笔
  119. MessengerHelper.DefaultRegister<QuoteGoods>(this, MessengerTokens.ShowTikDetail, (goods) =>
  120. {
  121. if (TabContetMode != TabContetMode.QuoteChart)
  122. {
  123. TabContetMode = TabContetMode.QuoteChart;
  124. }
  125. var quoteTik =new QuoteTikDetailView(goods);
  126. Content = quoteTik;
  127. });
  128. ////显示挂牌报价大厅
  129. MessengerHelper.DefaultRegister<ListingDeliveryGoods>(this, MessengerTokens.ShowListingBoard, (goods) =>
  130. {
  131. if (TabContetMode != TabContetMode.ListingBoard)
  132. {
  133. TabContetMode = TabContetMode.ListingBoard;
  134. }
  135. else
  136. {
  137. var board = new ListingApplyBoard(goods);
  138. Content = board;
  139. }
  140. });
  141. MessengerHelper.QuoteRegister<List<QuoteGoods>>(this, MessengerTokens.ReceiveRealTimeQuote, (quoteList) =>
  142. {
  143. //更新账户浮动盈亏
  144. FloatPLExpressions.UpdateAccountTotalFloatPL();
  145. });
  146. MessengerHelper.DefaultRegister<TradeAccount>(this, MessengerTokens.UpdateAccountFloatPL, (e) =>
  147. {
  148. //更新账户浮动盈亏
  149. FloatPLExpressions.UpdateAccountTotalFloatPL();
  150. });
  151. //调用MOPosition,初始化持仓汇总MOHoldSummaryViewModel, 以便接收头寸变更通知更新持仓汇总缓存
  152. var vm = ViewModelLocator.MOProsition;
  153. }
  154. private FrameworkElement _contentElement;
  155. /// <summary>
  156. /// 显示内容
  157. /// </summary>
  158. public FrameworkElement Content
  159. {
  160. get { return _contentElement; }
  161. set { Set(() => Content, ref _contentElement, value); }
  162. }
  163. private UIElement _GoodsInfoContentElement;
  164. /// <summary>
  165. /// 显示内容
  166. /// </summary>
  167. public UIElement GoodsInfoContent
  168. {
  169. get { return _GoodsInfoContentElement; }
  170. set { Set(() => GoodsInfoContent, ref _GoodsInfoContentElement, value); }
  171. }
  172. private UIElement _historyCmContentElement;
  173. /// <summary>
  174. /// 五档历史内容
  175. /// </summary>
  176. public UIElement HistoryCmContent
  177. {
  178. get { return _historyCmContentElement; }
  179. set { Set(() => HistoryCmContent, ref _historyCmContentElement, value); }
  180. }
  181. private TabContetMode _tabContetMode;
  182. /// <summary>
  183. /// 当前选择的类型
  184. /// </summary>
  185. public TabContetMode TabContetMode
  186. {
  187. get { return _tabContetMode; }
  188. set
  189. {
  190. if ((int)value == -1) return;
  191. ////F10弹窗显示 -- 嵌入显示则注释以下代码
  192. if (value == TabContetMode.QuoteGoodsInfo)
  193. {
  194. MessengerHelper.DefaultSend<TabContetMode>(TabContetMode.QuoteGoodsInfo, MessengerTokens.ChangeGoodsInfo);
  195. return;
  196. }
  197. if (value != _tabContetMode)
  198. {
  199. SetSelectTabItem(value);
  200. }
  201. Set(() => TabContetMode, ref _tabContetMode, value);
  202. UserManager.QuotationWindowType = _tabContetMode;
  203. }
  204. }
  205. #region 是否显示行情报价面板
  206. private Visibility _isVisibilityQuoteBorad = Visibility.Visible;
  207. /// <summary>
  208. /// 是否显示行情报价面板
  209. /// </summary>
  210. public Visibility IsVisibilityQuoteBorad
  211. {
  212. get
  213. {
  214. return _isVisibilityQuoteBorad;
  215. }
  216. set
  217. {
  218. Set(() => IsVisibilityQuoteBorad, ref _isVisibilityQuoteBorad, value);
  219. }
  220. }
  221. #endregion
  222. #region 是否显示K线图面板
  223. private Visibility _isVisibilityKline = Visibility.Collapsed;
  224. /// <summary>
  225. /// 是否显示K线图面板
  226. /// </summary>
  227. public Visibility IsVisibilityKline
  228. {
  229. get
  230. {
  231. return _isVisibilityKline;
  232. }
  233. set
  234. {
  235. Set(() => IsVisibilityKline, ref _isVisibilityKline, value);
  236. }
  237. }
  238. #endregion
  239. #region 是否显示F10面板
  240. private Visibility _isVisibilityFten = Visibility.Collapsed;
  241. /// <summary>
  242. /// 是否显示F10面板
  243. /// </summary>
  244. public Visibility IsVisibilityFten
  245. {
  246. get
  247. {
  248. return _isVisibilityFten;
  249. }
  250. set
  251. {
  252. Set(() => IsVisibilityFten, ref _isVisibilityFten, value);
  253. }
  254. }
  255. #endregion
  256. #region 是否显示历史五档内容
  257. private Visibility _isVisibilityHistoryCommissions = Visibility.Collapsed;
  258. /// <summary>
  259. /// 是否显示历史五档内容
  260. /// </summary>
  261. public Visibility IsVisibilityHistoryCommissions
  262. {
  263. get
  264. {
  265. return _isVisibilityHistoryCommissions;
  266. }
  267. set
  268. {
  269. Set(() => IsVisibilityHistoryCommissions, ref _isVisibilityHistoryCommissions, value);
  270. }
  271. }
  272. #endregion
  273. #region 是否显示历史五档按钮
  274. private Visibility _isVisHistoryCommissionsBtn = Visibility.Collapsed;
  275. /// <summary>
  276. ///是否显示历史五档按钮
  277. /// </summary>
  278. public Visibility IsVisHistoryCommissionsBtn
  279. {
  280. get
  281. {
  282. return _isVisHistoryCommissionsBtn;
  283. }
  284. set
  285. {
  286. Set(() => IsVisHistoryCommissionsBtn, ref _isVisHistoryCommissionsBtn, value);
  287. }
  288. }
  289. #endregion
  290. #region 是否显示大字报价
  291. private bool _isShowQuoteBoard;
  292. /// <summary>
  293. /// 是否显示大字报价
  294. /// </summary>
  295. public bool IsShowQuoteBoard
  296. {
  297. get
  298. {
  299. var result = ApplicationParameter.IsShowQuoteBoard == 1 && UserManager.IsAccountLogin; //(游客登录不显示大字报价牌); ///是否显示报价牌
  300. if (this._currentGroup == null)
  301. {
  302. return result;
  303. }
  304. else
  305. {
  306. switch (_currentGroup.TradeMode)
  307. {
  308. case eTradeMode.AllGoods:
  309. case eTradeMode.MySelected:
  310. case eTradeMode.TRADEMODE_MARKETMAKE:
  311. case eTradeMode.TRADEMODE_BIDDING:
  312. case eTradeMode.TRADEMODE_BIDDINGMARKETMAKE:
  313. break;
  314. case eTradeMode.TRADEMODE_SALE:
  315. case eTradeMode.Deposit:
  316. case eTradeMode.TRADEMODE_HANGTAG:
  317. //case eTradeMode.TRADEMODE_AUCTION:
  318. //case eTradeMode.TRADEMODE_MALL:
  319. result = false;
  320. break;
  321. default:
  322. break;
  323. }
  324. return result;
  325. }
  326. }
  327. }
  328. #endregion
  329. #region 是否显示商品资料
  330. private bool _isShowGoodsDetailInfo = false;
  331. /// <summary>
  332. /// 是否显示商品资料
  333. /// </summary>
  334. public bool IsShowGoodsDetailInfo
  335. {
  336. get
  337. {
  338. return _isShowGoodsDetailInfo;
  339. }
  340. set
  341. {
  342. Set(() => IsShowGoodsDetailInfo, ref _isShowGoodsDetailInfo, value);
  343. }
  344. }
  345. #endregion
  346. /// <summary>
  347. /// 打开F10
  348. /// </summary>
  349. private void ShowF10()
  350. {
  351. string exchHqCode = string.Empty, goodsCode = string.Empty;
  352. //F10嵌入显示
  353. //TabContetMode = TabContetMode.QuoteGoodsInfo;
  354. if (_currentGroup != null && _currentGroup.TradeMode == eTradeMode.TRADEMODE_HANGTAG)
  355. {
  356. var viewModel = SimpleIoc.Default.GetInstance<ListingDeliveryGoodsViewModel>();
  357. if (viewModel.CurrentGoods != null)
  358. {
  359. // exchHqCode = viewModel.CurrentGoods.ExchHqCode;
  360. goodsCode = viewModel.CurrentGoods.DeliveryGoodsCode;
  361. }
  362. }
  363. else
  364. {//F10弹窗显示
  365. if (this.SelectedQuoteGoods != null)
  366. {
  367. exchHqCode = SelectedQuoteGoods.ExchHqCode;
  368. goodsCode = SelectedQuoteGoods.GoodsCode;
  369. }
  370. }
  371. if (!string.IsNullOrEmpty(ApplicationParameter.FtenAddress))
  372. {
  373. DispatcherHelper.RunAsync(() =>
  374. {
  375. var reportView = new F10View(exchHqCode, goodsCode)
  376. {
  377. Owner = Application.Current.MainWindow
  378. };
  379. reportView.ShowDialog();
  380. });
  381. }
  382. }
  383. public QuoteGoods SelectedQuoteGoods { get; set; }
  384. /// <summary>
  385. /// 选择商品改变
  386. /// </summary>
  387. /// <param name="goods">The goods.</param>
  388. private void SelectGoodsChange(QuoteGoodsDTO goods)
  389. {
  390. var quoteGoods = CacheManager.CacheGoodsBaseInfos.FirstOrDefault((item) => item.Symbol == goods.Symbol);
  391. // bool showChart;
  392. //if (quoteGoods != null && quoteGoods.GoodsParameters != null)
  393. //{
  394. //todo:
  395. //if (goods.GoodsParameters.TradeMode == TradeModeType.BidGoods)
  396. //{
  397. // showChart = ApplicationParameter.ShowChart == 2; //设置竞价商品才显示图表
  398. //}
  399. // }
  400. //IsShowChart = ApplicationParameter.ShowChart == 1 || showChart;
  401. SelectedQuoteGoods = quoteGoods;
  402. if (!UserManager.IsAccountLogin) ////游客登录
  403. {
  404. return;
  405. }
  406. if (string.IsNullOrEmpty(ApplicationParameter.FtenAddress))
  407. {
  408. IsShowGoodsDetailInfo = false;
  409. }
  410. //Application.Current.Dispatcher.BeginInvoke(new Action(() =>
  411. //{
  412. // var tradeFunc =
  413. // UserManager.TradeFuncMenus.FirstOrDefault(
  414. // (item) => item.FuncMenuCode == (int) MenuCommandType.Sellout);
  415. // if (SelectedQuoteGoods != null &&tradeFunc != null )
  416. // {
  417. // if (SelectedQuoteGoods.GoodsParameters.MoneyMode == eMoneyMode.MONEYMODE_PAY )
  418. // {
  419. // var holders = UserManager.GetCacheOrders<HoldingOrder>();
  420. // tradeFunc.IsEnabled =
  421. // holders.Any((hold) => hold.GoodsId == goods.GoodsId && hold.Direction == Direction.Bid);
  422. // }
  423. // else
  424. // {
  425. // tradeFunc.IsEnabled = true;
  426. // }
  427. // }
  428. //}));
  429. //卖出
  430. }
  431. /// <summary>
  432. /// 选择商品组改变时
  433. /// </summary>
  434. /// <param name="goodsGroup"></param>
  435. private void SelectGoodsGrounpChange(MarketsInfoModel goodsGroup)
  436. {
  437. IsVisibilityQuoteBorad = Visibility.Visible;
  438. IsVisibilityKline = Visibility.Collapsed;
  439. IsVisibilityFten = Visibility.Collapsed;
  440. UserManager.CurrentGroupHasGoods = false;
  441. _currentGroup = goodsGroup;
  442. RaisePropertyChanged(() => IsShowQuoteBoard);
  443. ////当选择市场改变时从图表切换回到行情列表
  444. if (_tabContetMode == TabContetMode.QuoteChart || _tabContetMode == TabContetMode.QuoteGoodsInfo || _tabContetMode == TabContetMode.HistoryCommissions)
  445. {
  446. TabContetMode = TabContetMode.QuoteList;
  447. }
  448. if (!UserManager.IsAccountLogin) ////游客登录都是看有行情商品
  449. {
  450. IsShowChart = goodsGroup.TradeMode != eTradeMode.TRADEMODE_SALE;
  451. IsChartEnable = true;
  452. return;
  453. }
  454. #region 是否显示挂牌
  455. var instance = SimpleIoc.Default.GetInstance<TradeHeaderViewModel>();
  456. var isListingMarket = goodsGroup.TradeMode == eTradeMode.TRADEMODE_HANGTAG;
  457. instance.IsShowListing =isListingMarket;
  458. IsShowListingBoard = isListingMarket;
  459. #endregion
  460. var tradeFunc =
  461. UserManager.TradeFuncMenus.FirstOrDefault((item) => item.FuncMenuCode == MenuCommandType.Sellout.ToString());
  462. //卖出
  463. var saleFunc =
  464. UserManager.TradeFuncMenus.FirstOrDefault((item) => item.FuncMenuCode == MenuCommandType.SaleApply.ToString());
  465. //申购
  466. var buyFunc =
  467. UserManager.TradeFuncMenus.FirstOrDefault((item) => item.FuncMenuCode == MenuCommandType.BuyIn.ToString());
  468. //买入
  469. switch (goodsGroup.TradeMode)
  470. {
  471. case eTradeMode.Deposit:
  472. case eTradeMode.TRADEMODE_HANGTAG:
  473. IsShowChart = false;
  474. if (tradeFunc != null)
  475. {
  476. tradeFunc.IsEnabled = false;
  477. }
  478. if (buyFunc != null) //买入是否可用
  479. {
  480. buyFunc.IsEnabled = false;
  481. }
  482. IsShowGoodsDetailInfo = false;
  483. break;
  484. case eTradeMode.TRADEMODE_SALE:
  485. IsShowChart = false;
  486. if (tradeFunc != null)
  487. {
  488. tradeFunc.IsEnabled = false;
  489. }
  490. if (buyFunc != null) //买入是否可用
  491. {
  492. buyFunc.IsEnabled = false;
  493. }
  494. if (saleFunc != null)
  495. {
  496. var result = CacheManager.CacheGoodsBaseInfos != null && CacheManager.CacheGoodsBaseInfos.Any(
  497. (item) =>
  498. goodsGroup.MarketID == item.GoodsParameters.SortId &&
  499. item.GoodsParameters.RunSteps == eRunStep.RUNSTEP_BIDDINGCONTINUOUS);
  500. saleFunc.IsEnabled = result;
  501. UserManager.CurrentGroupHasGoods = result;
  502. }
  503. break;
  504. case eTradeMode.MySelected:
  505. //自选不做特殊处理
  506. //IsShowChart = ApplicationParameter.ShowChart == 1;
  507. //var ifavoriteService = SimpleIoc.Default.GetInstance<IFavoriteService>();
  508. //var goodsList = ifavoriteService.GetMyFavoriteGoodses(goodsGroup.MarketID);
  509. //bool enable = false;
  510. //enable = goodsList != null && _goodsService.ConvertGoodsDtos(goodsList.ToList()).Any();
  511. //if (buyFunc != null) //买入是否可用
  512. //{
  513. // buyFunc.IsEnabled = enable;
  514. //}
  515. //if (tradeFunc != null)
  516. //{
  517. // tradeFunc.IsEnabled = enable;
  518. //}
  519. //IsChartEnable = enable; ////当前商品组没有商品,不可点图表。
  520. //UserManager.CurrentGroupHasGoods = enable;
  521. //break;
  522. default:
  523. IsShowChart = ApplicationParameter.ShowChart == 1;
  524. //var goodsarr = _goodsService.GetQuoteGoodsDTOList(MenuCommandType.MarketQuote, goodsGroup);
  525. //var isHasGoods = CacheManager.CacheGoodsBaseInfos != null &&goodsarr!=null&&goodsarr.Any(); //当前商品组无商品时是否可买入
  526. var isHasGoods = CacheManager.CacheGoodsBaseInfos != null && CacheManager.CacheGoodsBaseInfos.Any();
  527. if (tradeFunc != null)
  528. {
  529. tradeFunc.IsEnabled = isHasGoods;
  530. if (buyFunc != null) //买入是否可用
  531. {
  532. buyFunc.IsEnabled = isHasGoods;
  533. }
  534. }
  535. if (saleFunc != null)
  536. {
  537. saleFunc.IsEnabled = false;
  538. }
  539. IsChartEnable = isHasGoods; ////当前商品组没有商品,不可点图表。
  540. UserManager.CurrentGroupHasGoods = isHasGoods;
  541. break;
  542. }
  543. }
  544. /// <summary>
  545. /// Sets the select tab item.
  546. /// </summary>
  547. /// <param name="tabContetMode">The tab contet mode.</param>
  548. private void SetSelectTabItem(TabContetMode tabContetMode)
  549. {
  550. ////先发送RadioButton激活通知
  551. MessengerHelper.DefaultSend(tabContetMode, MessengerTokens.ActiveMainRadio);
  552. if (Content != null && Content.DataContext is IDisposable)
  553. {
  554. Content.InputBindings.Clear();
  555. (Content.DataContext as IDisposable).Dispose(); ////清除图表数据,注册消息
  556. }
  557. #region 顶部买卖按钮与挂牌无关
  558. //switch (tabContetMode)
  559. //{
  560. // case TabContetMode.QuoteList:
  561. // case TabContetMode.QuoteGoodsInfo:
  562. // case TabContetMode.QuoteBoard:
  563. // case TabContetMode.QuoteChart:
  564. // MessengerHelper.DefaultSend<bool>(true, MessengerTokens.IsShowSellCommondBtn);
  565. // MessengerHelper.DefaultSend<bool>(true, MessengerTokens.IsShowBuyCommondBtn);
  566. // CacheManager.IsHasListingData = true;
  567. // MessengerHelper.DefaultSend<bool>(true, MessengerTokens.IsEnableBuyAndSellCommondBtn);
  568. // break;
  569. //}
  570. #endregion
  571. switch (tabContetMode)
  572. {
  573. case TabContetMode.QuoteList:
  574. CacheManager.FromType = eOrderFormType.Commom;
  575. //切换到系统默认的报价牌
  576. //UserManager.QuotationWindowType = QuotationWindowType.List;
  577. //WindowHelper.OpenDefaultQuoteListView(false);
  578. IsVisibilityQuoteBorad = Visibility.Visible;
  579. IsVisibilityKline = Visibility.Collapsed;
  580. IsVisibilityFten = Visibility.Collapsed;
  581. IsVisHistoryCommissionsBtn=IsVisibilityHistoryCommissions = Visibility.Collapsed;
  582. MessengerHelper.DefaultSend<QuotationWindowType>(QuotationWindowType.List, MessengerTokens.ChangeQuote);
  583. break;
  584. #region cancel
  585. //case TabContetMode.QuoteList:
  586. // //切换到光标选中的(当前)商品合约K线
  587. // // ExecuteCommand(new SysMenuItem(MenuNames.AnalysisCandlestick, MenuCommandType.CandleChart));
  588. // //k线图因为没有执行树形控件的记录当前市场的方法,所以要手动记录当前市场
  589. // MessengerHelper.DefaultSend<MenuCommandType>(MenuCommandType.CandleChart,
  590. // MessengerTokens.UpdateCurrentMarketType);
  591. // break;
  592. //case 2:
  593. // //切换到光标选中的(当前)商品合约分时
  594. // // ExecuteCommand(new SysMenuItem(MenuNames.AnalysisTimeSharing, MenuCommandType.TimeSharingChart));
  595. // break;
  596. //case 3:
  597. // //切换到光标选中的(当前)商品合约实时
  598. // // ExecuteCommand(new SysMenuItem(MenuNames.AnalysisTik, MenuCommandType.TikChart));
  599. // break;
  600. #endregion
  601. case TabContetMode.QuoteGoodsInfo:
  602. CacheManager.FromType = eOrderFormType.Commom;
  603. //切换到F10基本资料
  604. ShowF10();
  605. IsVisibilityFten = Visibility.Visible;
  606. IsVisibilityQuoteBorad = Visibility.Collapsed;
  607. IsVisibilityKline = Visibility.Collapsed;
  608. IsVisHistoryCommissionsBtn=IsVisibilityHistoryCommissions = Visibility.Collapsed;
  609. break;
  610. #region cancel
  611. //case 5:
  612. // //切换到新闻资讯
  613. // var newsCategory = CacheManager.CacheNewsCategory;
  614. // if (newsCategory != null && newsCategory.Any())
  615. // {
  616. // var first = newsCategory.FirstOrDefault();
  617. // if (first == null || string.IsNullOrWhiteSpace(first.ClassCode)) return;
  618. // WindowHelper.OpenNewsWindow(first.ClassCode);
  619. // }
  620. // break;
  621. //case 6:
  622. // //切换到经济数据
  623. // break;
  624. //case 8:
  625. // MessengerHelper.DefaultSend(TradeTreeMenu.MyInvestmentContract,
  626. // MessengerTokens.AccountFunction);
  627. // //MessengerHelper.DefaultSend<WindowType>(WindowType.QueryFinacing,
  628. // // MessengerTokens.ActiveHomeTab);
  629. // break;
  630. #endregion
  631. case TabContetMode.QuoteBoard:
  632. CacheManager.FromType = eOrderFormType.Commom;
  633. //大字报价牌
  634. IsVisibilityQuoteBorad = Visibility.Visible;
  635. IsVisibilityKline = Visibility.Collapsed;
  636. IsVisibilityFten = Visibility.Collapsed;
  637. IsVisHistoryCommissionsBtn = IsVisibilityHistoryCommissions = Visibility.Collapsed;
  638. MessengerHelper.DefaultSend<QuotationWindowType>(QuotationWindowType.Board, MessengerTokens.ChangeQuote);
  639. break;
  640. case TabContetMode.QuoteChart:
  641. CacheManager.FromType = eOrderFormType.Commom;
  642. IsVisibilityQuoteBorad = Visibility.Collapsed;
  643. IsVisibilityFten = Visibility.Collapsed;
  644. IsVisHistoryCommissionsBtn = IsVisibilityHistoryCommissions = Visibility.Collapsed;
  645. IsVisibilityKline = Visibility.Visible;
  646. //图表
  647. // MessengerHelper.DefaultSend<QuotationWindowType>(QuotationWindowType.Board, MessengerTokens.);
  648. if (this.SelectedQuoteGoods != null)
  649. {
  650. // var formchart = new FormChartView(new ChartWindowItem(string.Empty, this.SelectedQuoteGoods, CycleType.Minutes1));
  651. var formchart = new CChartView(new ChartWindowItem(string.Empty, this.SelectedQuoteGoods, CycleType.Minutes1));
  652. Content = formchart;
  653. }
  654. break;
  655. case TabContetMode.ListingBoard:
  656. CacheManager.FromType = eOrderFormType.Commom;
  657. IsVisibilityQuoteBorad = Visibility.Collapsed;
  658. IsVisibilityFten = Visibility.Collapsed;
  659. IsVisHistoryCommissionsBtn = IsVisibilityHistoryCommissions = Visibility.Collapsed;
  660. IsVisibilityKline = Visibility.Visible;
  661. //图表
  662. // MessengerHelper.DefaultSend<QuotationWindowType>(QuotationWindowType.Board, MessengerTokens.);
  663. var viewModel = SimpleIoc.Default.GetInstance<ListingDeliveryGoodsViewModel>();
  664. if (viewModel.CurrentGoods != null)
  665. {
  666. var board = new ListingApplyBoard(viewModel.CurrentGoods);
  667. Content = board;
  668. }
  669. break;
  670. //历史五档
  671. case TabContetMode.HistoryCommissions:
  672. CacheManager.FromType = eOrderFormType.Commom;
  673. IsVisibilityQuoteBorad = Visibility.Collapsed;
  674. IsVisibilityFten = Visibility.Collapsed;
  675. IsVisibilityKline = Visibility.Collapsed;
  676. IsVisHistoryCommissionsBtn = IsVisibilityHistoryCommissions = Visibility.Visible;
  677. var viewHistoryCommissionsListModel = SimpleIoc.Default.GetInstance<HistoryCommissionsListViewModel>();
  678. if (viewHistoryCommissionsListModel != null)
  679. {
  680. var HistoryCommissionsContent = new HistoryCommissionsList(viewHistoryCommissionsListModel);
  681. HistoryCmContent = HistoryCommissionsContent;
  682. if (parameters != null)
  683. {
  684. MessengerHelper.DefaultSend<SearchCommissionsParameter>(parameters, MessengerTokens.HistoryCommissions);
  685. }
  686. }
  687. break;
  688. }
  689. }
  690. private bool _isShowChart = true;
  691. /// <summary>
  692. /// 是否显示图表
  693. /// </summary>
  694. public bool IsShowChart
  695. {
  696. get { return _isShowChart; }
  697. set { Set(() => IsShowChart, ref _isShowChart, value); }
  698. }
  699. private bool _isChartEnabled;
  700. private bool _isShowListingBoard;
  701. /// <summary>
  702. /// 是否显示报价大厅
  703. /// </summary>
  704. public bool IsShowListingBoard
  705. {
  706. get { return _isShowListingBoard; }
  707. set { Set(() => IsShowListingBoard, ref _isShowListingBoard, value); }
  708. }
  709. /// <summary>
  710. /// 是否可用
  711. /// </summary>
  712. public bool IsChartEnable
  713. {
  714. get { return _isChartEnabled; }
  715. set { Set(() => IsChartEnable, ref _isChartEnabled, value); }
  716. }
  717. /// <summary>
  718. /// 交易登录后在初始化的内容
  719. /// </summary>
  720. public void InitMainPanel()
  721. {
  722. IsShowChart = ApplicationParameter.ShowChart == 1;
  723. }
  724. }
  725. }