private void Button_Click(object sender, RoutedEventArgs e) { try { listBox1.Items.Clear(); if (chbConnectToServer.IsChecked == false) { dsource = new QuotesFromBD(); (dsource as QuotesFromBD).glassgraph = GlassVisual; dsource.OnConnected += new ConnectedHandler(ConnectedEvent); dsource.OnGetInstruments += new GetInstrumentsHandler(GetInstrumentsEvent); (dsource as QuotesFromBD).OnThreadTesterStart += new ThreadStarted(ThreadTesterStarted); (dsource as QuotesFromBD).OnChangeProgress += MainWindow_OnChangeProgress; (dsource as QuotesFromBD).OnFinishOneThread += MainWindow_OnFinishOneThread; //if (chbVisualisationTest.IsChecked == true) //{ (dsource as QuotesFromBD).paramTh = new ParametrsForTest(0, new List <string> { } , int.Parse(tbGlassCurrent.Text), float.Parse(tbAverageCurrent.Text) , int.Parse(tbProfitLongCurrent.Text), int.Parse(tbLossLongCurrent.Text) , int.Parse(tbIndicatorEnterCurrent.Text), int.Parse(tbMartingCurrent.Text) , int.Parse(tbLossShortCurrent.Text), int.Parse(tbProfitShortCurrent.Text) , int.Parse(tbIndicatorExitCurrent.Text), int.Parse(tbDelayCurrent.Text)); //} } else { dsource = new QuotesFromSmartCom(textBox1.Text, passBox1.Password); (dsource as QuotesFromSmartCom).glassgraph = GlassVisual; GlassVisual.OnDoTradeLong += (dsource as QuotesFromSmartCom).DoTradeLong; GlassVisual.OnDoTradeShort += (dsource as QuotesFromSmartCom).DoTradeShort; (dsource as QuotesFromSmartCom).Trading = (bool)chbTrading.IsChecked; (dsource as QuotesFromSmartCom).paramTh = new ParametrsForTest(0, new List <string> { } , int.Parse(tbGlassCurrent.Text), float.Parse(tbAverageCurrent.Text) , int.Parse(tbProfitLongCurrent.Text), int.Parse(tbLossLongCurrent.Text) , int.Parse(tbIndicatorEnterCurrent.Text), int.Parse(tbMartingCurrent.Text) , int.Parse(tbLossShortCurrent.Text), int.Parse(tbProfitShortCurrent.Text) , int.Parse(tbIndicatorExitCurrent.Text), int.Parse(tbDelayCurrent.Text)); (dsource as QuotesFromSmartCom).OnChangeIndicator += MainWindow_OnChangeIndicator; } dsource.ConnectToDataSource(); dsource.OnInformation += dsource_OnInformation; dsource.OnChangeGlass += GlassVisual.ChangeValues; dsource.OnAddTick += GlassVisual.AddTick; } catch (Exception ee) { MessageBox.Show(ee.Message); } }