public ChooseContract() { InitializeComponent(); //CodeSet.Init(); //chooseSet = UserCodeSetInstance.GetContractListByUserCodeSet(UserCodeSetInstance.GetUserCodeSetList()[0]); this.dgChooseCode.ItemsSource = _AreaCodeSet; //this.dgChoosedCode.ItemsSource = chooseSet; cbUserCodeSet.DisplayMemberPath = "Name"; cbUserCodeSet.SelectedValuePath = "Id"; cbUserCodeSet.ItemsSource = UserCodeSetInstance.GetUserCodeSetList(); IsUpdated = false; //string selectedUserCodeSet = JYDataServer.getServerInstance().getMainWindow().userCodeSetBar.getSelectedUserCodeSetId(); //cbUserCodeSet.SelectedValue = selectedUserCodeSet; }
/// <summary> /// 重新更新板块按钮 /// </summary> public void ResetBlockButtons() { stackGridBlock.Children.Clear(); ObservableCollection <UserCodeSet> lstUserCodeSet = UserCodeSetInstance.GetUserCodeSetList(); int i = 0; foreach (var item in lstUserCodeSet) { Button btn = new Button(); btn.Content = item.Name; btn.Tag = item.Id; btn.Click += new RoutedEventHandler(btn_Click); btn.HorizontalAlignment = HorizontalAlignment.Left; btn.Margin = new Thickness(i * 85, -1, 0, 0); btn.Width = 80; btn.Height = 23; stackGridBlock.Children.Add(btn); //btn.FontWeight = FontWeights.Normal; //btn.Foreground = new SolidColorBrush(Colors.Black); //btn.Style = (Style)FindResource("btnDefault"); if (item.IsDefault && defaultButton == null) { defaultButton = btn; } else if (defaultButton.Content.Equals(item.Name)) { defaultButton = btn; } i += 1; } //defaultButton.Style = (Style)FindResource("btnDefault_Selected"); btn_Click(defaultButton, null); }
private void btnReportSetting_Click(object sender, RoutedEventArgs e) { ChooseContract chooseContract = new ChooseContract(); chooseContract.DataContext = this._MainWindow; Window codeSetWindow = CommonUtil.GetWindow("合约设置", chooseContract, _MainWindow); codeSetWindow.Closed += new EventHandler(codeSetWindow_Closed); ObservableCollection <UserCodeSet> lstUserCodeSet = UserCodeSetInstance.GetUserCodeSetList(); int i = 0; UserCodeSet userCodeSet = null; foreach (var item in lstUserCodeSet) { userCodeSet = item as UserCodeSet; if (defaultButton != null && defaultButton.Content.ToString() == userCodeSet.Name) { break; } i += 1; } chooseContract.cbUserCodeSet.SelectedIndex = i; codeSetWindow.ShowDialog(); }
void btn_Click(object sender, RoutedEventArgs e) { //if (IsNeedNotice()) //{ // //警告 // MessageBox.Show(Login.GetChangeCodeSetSleepMessage()); // return; //} ObservableCollection <UserCodeSet> lstUserCodeSet = UserCodeSetInstance.GetUserCodeSetList(); string userCodeSetId = (sender as Button).Tag.ToString(); foreach (var realItem in lstUserCodeSet) { if (realItem.Id == userCodeSetId) { if (!realItem.IsArbitrage) //单腿 { if (dgGroupRealData.Visibility == Visibility.Visible) { ObservableCollection <Contract> newCodes = new ObservableCollection <Contract>(); ChangeUserGroupCodeSet(newCodes); } //if (realItem.IsZhuli) //{ // btnZLCodeSort.Visibility = Visibility.Visible; //} //else //{ // btnZLCodeSort.Visibility = Visibility.Hidden; //} ChangeUserCodeSet(false, UserCodeSetInstance.GetContractListByUserCodeSet(userCodeSetId)); } else //套利 { if (dgRealData.Visibility == Visibility.Visible) { ObservableCollection <Contract> newCodes = new ObservableCollection <Contract>(); ChangeUserCodeSet(false, newCodes); } //RequestRealData(GroupHQRealData); ChangeUserGroupCodeSet(UserCodeSetInstance.GetContractListByUserCodeSet(userCodeSetId)); } break; } } foreach (var item in stackGridBlock.Children) { if (item is Button) { Button btn = item as Button; btn.IsEnabled = true; } } defaultButton = sender as Button; defaultButton.IsEnabled = false; foreach (var item in lstUserCodeSet) { if ((sender as Button).Content.ToString() == item.Name) { if (item.IsArbitrage) { _MainWindow.uscHangqing.dgRealData.Visibility = Visibility.Hidden; _MainWindow.uscHangqing.dgGroupRealData.Visibility = Visibility.Visible; } else { _MainWindow.uscHangqing.dgRealData.Visibility = Visibility.Visible; _MainWindow.uscHangqing.dgGroupRealData.Visibility = Visibility.Hidden; } break; } } }
private void ReformBlockButtons() { ObservableCollection <UserCodeSet> userCodeSetList = UserCodeSetInstance.GetUserCodeSetList(); }
private void RequestRealData(BackgroundDataServer hqRealData) { ObservableCollection <UserCodeSet> lstUserCodeSet = UserCodeSetInstance.GetUserCodeSetList(); //先删除合约 bool bChanged = false; _DelCodeList.Clear(); foreach (Contract temp in hqRealData.m_oldCodeArray) { if (!hqRealData.m_codeArray.Contains(temp)) { _DelCodeList.Add(temp); } } if (_DelCodeList.Count > 0) { bChanged = true; hqRealData.AddContract(_DelCodeList.ToArray()); hqRealData.UnRequest(); try { RealData tempData = null; foreach (Contract temp in _DelCodeList) { string tempKey = temp.Code + "_" + temp.ExchCode; if (_BackupCodeDic.ContainsKey(tempKey)) { tempData = _BackupCodeDic[tempKey]; if (tempData != null) { DisplayRealData tempDisplayData = UpdateDisplayProperties(tempData); if (hqRealData == HQRealData) { //Util.Log("<<:" + tempData.ToString()); _MainWindow.RealDataCollection.Remove(tempDisplayData); } else if (hqRealData == GroupHQRealData) { _MainWindow.RealDataArbitrageCollection.Remove(tempDisplayData); } _BackupCodeDic.Remove(tempKey); } } } } catch (Exception ex) { Util.Log_Error("exception: " + ex.Message); Util.Log_Error("exception: " + ex.StackTrace); } } //在请求新增的合约 _AddCodeList.Clear(); foreach (Contract temp in hqRealData.m_codeArray) { if (!hqRealData.m_oldCodeArray.Contains(temp)) { _AddCodeList.Add(temp); } } if (_AddCodeList.Count > 0) { foreach (Contract temp in _AddCodeList) { if (temp == null) { continue; } string tempKey = temp.Code + "_" + temp.ExchCode; if (_BackupCodeDic.ContainsKey(tempKey) == false) { RealData tempData2 = new RealData(); //Contract tempContract = CodeSetManager.GetContractInfo(temp.Code); tempData2.CodeInfo = CodeSetManager.GetContractInfo(temp.Code, temp.ExchCode); if (tempData2.CodeInfo == null) { tempData2.CodeInfo = new Contract(temp.Code); } //tempData2.Name = tempContract.Name; //decimal fluct = 0.00M; //CodeSetManager.GetHycsAndFluct(tempData2.codeInfo.Code, out (double)tempData2.m_hycs, out fluct); _BackupCodeDic.Add(tempKey, tempData2); } } bChanged = true; hqRealData.AddContract(_AddCodeList.ToArray()); hqRealData.GetRealData(); hqRealData.Request(); } DeepCopyInfo(hqRealData.m_codeArray, hqRealData.m_oldCodeArray); if (bChanged == false) { RealData tempData2 = null; _MainWindow.RealDataCollection.Clear(); _MainWindow.RealDataArbitrageCollection.Clear(); foreach (Contract temp in hqRealData.m_oldCodeArray) { //Util.Log(this.defaultButton.Content + " 添加内容 Old-----"); string tempKey = temp.Code + "_" + temp.ExchCode; if (_BackupCodeDic.ContainsKey(tempKey)) { tempData2 = _BackupCodeDic[tempKey]; if (tempData2 != null) { DisplayRealData tempDisplayData = UpdateDisplayProperties(tempData2); if (hqRealData == HQRealData) { //Util.Log(">>:" + tempData2.ToString()); _MainWindow.RealDataCollection.Add(tempDisplayData); } else if (hqRealData == GroupHQRealData) { if (tempData2.CodeInfo.Code.Contains("&")) { //string[] tempType = tempData2.codeInfo.Code.Split(' '); //string[] tempGroup = tempType[1].Split('&'); //tempData2.Code = tempGroup[0]; //tempData2.Code2 = tempGroup[1]; } _MainWindow.RealDataArbitrageCollection.Add(UpdateDisplayProperties(tempData2)); } } } } } else { RealData tempData2 = null; _MainWindow.RealDataCollection.Clear(); _MainWindow.RealDataArbitrageCollection.Clear(); if (hqRealData == HQRealData) { //Util.Log(this.defaultButton.Content + " 添加内容-----"); foreach (Contract temp in _CodeArray) { if (temp != null) { string tempKey = temp.Code + "_" + temp.ExchCode; if (_BackupCodeDic.ContainsKey(tempKey) == false) { tempData2 = new RealData(); //Contract tempContract = CodeSetManager.GetContractInfo(temp.Code); tempData2.CodeInfo = CodeSetManager.GetContractInfo(temp.Code, temp.ExchCode); if (tempData2.CodeInfo == null) { tempData2.CodeInfo = new Contract(temp.Code); } //tempData2.Name = tempContract.Name; //double fluct = 0; //CodeSetManager.GetHycsAndFluct(tempData2.Code, out tempData2.m_hycs, out fluct); _BackupCodeDic.Add(tempKey, tempData2); } else { tempData2 = _BackupCodeDic[tempKey]; } DisplayRealData tempDisplayData = UpdateDisplayProperties(tempData2); //Util.Log(">>:"+tempData2.ToString()); _MainWindow.RealDataCollection.Add(tempDisplayData); //Util.Log("mainWindow.RealDataCollection.count=" + mainWindow.RealDataCollection.Count); } } } else if (hqRealData == GroupHQRealData) { foreach (Contract temp in _GroupCodeArray) { if (temp != null) { string tempKey = temp.Code + "_" + temp.ExchCode; if (_BackupCodeDic.ContainsKey(tempKey) == false) { tempData2 = new RealData(); tempData2.CodeInfo = CodeSetManager.GetContractInfo(temp.Code, temp.ExchCode); if (tempData2.CodeInfo == null) { tempData2.CodeInfo = new Contract(tempKey); } //decimal fluct = 0; //CodeSetManager.GetHycsAndFluct(temp.Code, out tempData2.m_hycs, out fluct); _BackupCodeDic.Add(tempKey, tempData2); } else { tempData2 = _BackupCodeDic[tempKey]; } if (tempData2.CodeInfo.Code.Contains("&")) { //string[] tempType = tempData2.Code.Split(' '); //string[] tempGroup = tempType[1].Split('&'); //tempData2.Code1 = tempGroup[0]; //tempData2.Code2 = tempGroup[1]; } _MainWindow.RealDataArbitrageCollection.Add(UpdateDisplayProperties(tempData2)); } } } } hqRealData.UpdateRealDataList(); }