private void QuotesDataGrid_SetDataGridStyleHandler(object sender, EventArgs e) { if (!TradeQuotesViewModel.GetInstance(null).IsQuoteCheck) { return; } int?type = sender as int?; if (type != null) { if (type == 1)//放大 { if (quotesDataGrid.FontSize > 25) { return; } quotesDataGrid.ColumnHeaderHeight = quotesDataGrid.ColumnHeaderHeight + 1; quotesDataGrid.RowHeight = quotesDataGrid.RowHeight + 1; quotesDataGrid.FontSize = quotesDataGrid.FontSize + 1; foreach (var item in quotesDataGrid.Columns) { item.Width = item.ActualWidth + 2; } } else { if (quotesDataGrid.FontSize <= 13) { return; } quotesDataGrid.ColumnHeaderHeight = quotesDataGrid.ColumnHeaderHeight - 1; quotesDataGrid.RowHeight = quotesDataGrid.RowHeight - 1; quotesDataGrid.FontSize = quotesDataGrid.FontSize - 1; foreach (var item in quotesDataGrid.Columns) { item.Width = item.ActualWidth - 2; } } //var aa = type; ////var bb= FindResource("StockSellStyle") as Style; //quotesDataGrid.fon //quotesDataGrid.Style.Setters.Add(new Setter(FontSizeProperty,25)); //foreach (Setter item in quotesDataGrid.Style.Setters) //{ // if(item.Property.Name.Equals("FontSize")) // { // new Setter(FontSizeProperty, 25); // } //} //var aa= quotesDataGrid.Style.Setters.Count; } }
private void UserControl_Loaded(object sender, RoutedEventArgs e) { TradeQuotesViewModel.GetInstance(null).SetDataGridStyleHandler -= QuotesDataGrid_SetDataGridStyleHandler; TradeQuotesViewModel.GetInstance(null).SetDataGridStyleHandler += QuotesDataGrid_SetDataGridStyleHandler; }
private void myTimer_Elapsed(object sender, System.Timers.ElapsedEventArgs e) { try { var trademodel = TradeQuotesViewModel.GetInstance(null); if (ServerStatusInfoHelper.Instace().IsReattached) { #region 行情重连之后执行 ServerStatusInfoHelper.Instace().IsReattached = false; var mainViewModel = MainViewModel.GetInstance(); if (mainViewModel.SelectItemViewModel != null) { if (Application.Current != null) //判断不为空 { Application.Current.Dispatcher.Invoke(System.Windows.Threading.DispatcherPriority.Normal, new Action( () => { mainViewModel.SelectItemViewModel.Tick.EachDealList.Clear(); })); } _scoketManager.SendSubscribeInfo(7, mainViewModel.SelectItemViewModel.ContractCode); } var clearDealList = mainViewModel.QuotesSubscribed.ToList(); foreach (var item in clearDealList) { var futuresModel = _viewModel.FuturesViewModelList.FirstOrDefault(o => !string.IsNullOrEmpty(o.ExchangeDisplay) && string.Equals(o.ContractCode, item)); if (futuresModel != null) { if (futuresModel.Tick.EachDealList.Count == 0) { continue; } if (Application.Current != null) //判断不为空 { Application.Current.Dispatcher.Invoke(System.Windows.Threading.DispatcherPriority.Normal, new Action( () => { futuresModel.Tick.EachDealList.Clear(); })); } } } mainViewModel.QuotesSubscribed.Clear(); LogHelper.Info("重连之后行情订阅:" + string.Join(",", mainViewModel.SubscribedStocks)); _scoketManager.SendSubscribeInfo(7, mainViewModel.SubscribedStocks); if (mainViewModel.SelectItemViewModel != null) { if (Application.Current != null) //判断不为空 { Application.Current.Dispatcher.Invoke(System.Windows.Threading.DispatcherPriority.Normal, new Action( () => { //if (trademodel.RealTimeVisibility == Visibility.Visible || trademodel.KLineVisibility == Visibility.Visible) //{ // mainViewModel.SelectItemViewModel.Tick.SetEachDealList(); //} })); } } #endregion } if (trademodel.IsInternationalCheck) { int rowIndex = -1; //int i = 0; List <string> subList = new List <string>(); List <string> viewList = new List <string>(); var mainViewModel = MainViewModel.GetInstance(); this.AllFuturesQuota.Dispatcher.Invoke(new Action(() => { TabItem tabItem = AllFuturesQuota.Items[_viewModel.SelectedIndex] as TabItem; var dataGrid = (tabItem.Content as QuotesDataGrid).quotesDataGrid; if (dataGrid.Items.Count > 0) { for (int a = 0; a < dataGrid.Items.Count; a++) { var item = dataGrid.Items[a]; var Row = (DataGridRow)dataGrid.ItemContainerGenerator.ContainerFromItem(item); if (Row != null) { if (Row.TransformToVisual(dataGrid).Transform(new Point(0, 0)).Y + Row.ActualHeight >= dataGrid.ActualHeight) { rowIndex = a; break; } } } if (rowIndex == -1) { rowIndex = dataGrid.Items.Count - 1; if (rowIndex == -1) { return; } } int j = 0; do { if (rowIndex < 0) { break; } var Row = (DataGridRow)dataGrid.ItemContainerGenerator.ContainerFromIndex(rowIndex); if (Row != null) { FuturesViewModel stock = Row.DataContext as FuturesViewModel; if (stock != null) { if (!mainViewModel.QuotesSubscribed.Contains(stock.ContractCode) && !mainViewModel.SubscribedStocks.Contains(stock.ContractCode)) { subList.Add(stock.ContractCode); mainViewModel.QuotesSubscribed.Add(stock.ContractCode); } viewList.Add(stock.ContractCode); } } rowIndex--; j++; } while (j < 28); } })); if (subList.Count > 0) { LogHelper.Info("行情订阅:" + string.Join(",", subList)); _scoketManager.SendSubscribeInfo(7, subList); } FuturesViewModel selectModel = mainViewModel.SelectItemViewModel; List <string> unSubList = new List <string>(); List <string> tempList = mainViewModel.QuotesSubscribed.ToList(); if (tempList.Count > 0) { foreach (var item in tempList) { if (!string.IsNullOrEmpty(item) && !viewList.Contains(item) && !mainViewModel.SubscribedStocks.Contains(item) && (selectModel == null || !string.Equals(selectModel.ContractCode, item))) { mainViewModel.QuotesSubscribed.Remove(item); unSubList.Add(item); } } } if (unSubList.Count > 0) { LogHelper.Info("行情反订阅:" + string.Join(",", unSubList)); _scoketManager.SendSubscribeInfo(8, unSubList); } } } catch (Exception ex) { LogHelper.Info("StockQuota:myTimer_Elapsed" + ex.ToString()); } }