private void onClickManagementCockpit(object sender, RibbonControlEventArgs e) { //Historische Daten auswählen Konfigurator view = new Konfigurator(); view.ShowDialog(); if (view.hasBeenCancelled == false) { LiveConnectors variant; DialogResult dummyOrNot = MessageBox.Show("Möchten Sie mit echten Live-Daten (Ja) oder mit Dummy-Daten (Nein) arbeiten?", "Datentyp auswählen", MessageBoxButtons.YesNo); switch (dummyOrNot) { case DialogResult.Yes: variant = LiveConnectors.OnVista; break; case DialogResult.No: variant = LiveConnectors.OnVistaDummy; break; default: variant = LiveConnectors.OnVistaDummy; break; } TableObject historicalDataTableObject = null; ProgressIndicator progress = new ProgressIndicator(); progress.progressBar1.Maximum = 100; progress.progressBar1.Minimum = 0; progress.progressBar1.Value = 20; progress.Show(); progress.progressBar1.Value = 25; DataManager dataManager = DataManager.getInstance(); progress.progressBar1.Value = 30; List <StockDataTransferObject> historicalRecords = dataManager.getHistoricalStockData ( view.comboBox1.SelectedItem.ToString(), view.dateTimePicker1.Value, view.dateTimePicker2.Value, YahooFinanceAPI_Resolution.Daily ); if (historicalRecords != null) { historicalDataTableObject = new TableObject ( Globals.Factory.GetVstoObject ( Globals.ThisAddIn.Application.ActiveWorkbook.ActiveSheet ), Globals.ThisAddIn.Application.Cells[1, 1], historicalRecords, dataManager.getColumnsToDraw_forYahooHistoricalData() ); progress.progressBar1.Value = 45; historicalDataTableObject.changeSheetName("Historische Daten"); progress.progressBar1.Value = 55; historicalDataTableObject.drawOnlyRelevantColumns(); progress.progressBar1.Value = 60; } //Livedaten TableObject liveDataTableObject = new TableObject( Globals.Factory.GetVstoObject( Globals.ThisAddIn.Application.ActiveWorkbook.ActiveSheet), Globals.ThisAddIn.Application.Cells[1, 1]); progress.progressBar1.Value = 75; //liveDataTable.changeWorkbookName("OnVista-Livedaten"); liveDataTableObject.createNewWorksheet("Livedaten"); progress.progressBar1.Value = 80; dataManager.subscribeForLiveConnection(view.comboBox1.SelectedItem.ToString(), liveDataTableObject, variant); dataManager.pausePushWorkers(); //lege Worker schlafen progress.progressBar1.Value = 85; DiagramObject myDiagram = new DiagramObject(liveDataTableObject, historicalDataTableObject, view.comboBox1.SelectedItem.ToString()); progress.progressBar1.Value = 90; Algo algorithmus = new Algo(Globals.ThisAddIn.ac, view.comboBox1.SelectedItem.ToString(), variant); Globals.ThisAddIn.SharePane.Visible = true; progress.progressBar1.Value = 95; progress.progressBar1.Value = 100; progress.Close(); dataManager.pausePushWorkers(); //wecke Worker wieder auf } }
private void onClickAusfuehren(object sender, RibbonControlEventArgs e) { if (CB_Ziel_NeuesTB.Enabled == false & CB_Ziel_AktuellesTB.Enabled == false & CB_Ziel_Cursor.Enabled == false) { BTN_Aktionen_Ausfuehren.Enabled = false; } if (selectedOptions == 3) { Konfigurator view = new Konfigurator(); if (CB_Typ_Live.Checked) { view.groupBox1.Visible = false; } view.ShowDialog(); Workbook workBook; Worksheet workSheet = Globals.Factory.GetVstoObject(Globals.ThisAddIn.Application.ActiveWorkbook.ActiveSheet); Excel.Range position = Globals.ThisAddIn.Application.Cells[1, 1]; string stockSymbol = view.comboBox1.SelectedItem.ToString(); DateTime dateFrom = view.dateTimePicker1.Value; DateTime dateTo = view.dateTimePicker2.Value; DataManager dataManager = DataManager.getInstance(); TableObject tableObject = null; LiveConnectors liveVariant = LiveConnectors.OnVistaDummy; List <int> columnsToDraw = null; List <StockDataTransferObject> listOfRecords = null; if (view.hasBeenCancelled == false) { //************************* Position ************************************* //Aktive Zelle if (CB_Ziel_Cursor.Checked) { position = Globals.ThisAddIn.Application.ActiveCell; } //Aktuelles Tabellenblatt else if (CB_Ziel_AktuellesTB.Checked) { //nutze Standards } //Neues Tabellenblatt else if (CB_Ziel_NeuesTB.Checked) { workBook = Globals.Factory.GetVstoObject(Globals.ThisAddIn.Application.ActiveWorkbook); String tabellenblattName = Microsoft.VisualBasic.Interaction.InputBox("Bitte Tabellenblattnamen eingeben!", "Tabellenblattname eingeben", ""); foreach (Excel.Worksheet sheet in workBook.Worksheets) { if (sheet.Name.ToString() == tabellenblattName) { MessageBox.Show("Tabellenblattname bereits vorhanden! Bitte erneut ausführen!"); return; } } workSheet = Globals.Factory.GetVstoObject(Globals.ThisAddIn.Application.ActiveWorkbook.Worksheets.Add()); workSheet.Name = tabellenblattName; } //************************* Position ************************************* //************************* Historisch *********************************** //Yahoo API if (CB_Quelle_Yahoo.Checked) { listOfRecords = dataManager.getHistoricalStockData(stockSymbol, dateFrom, dateTo, YahooFinanceAPI_Resolution.Daily); columnsToDraw = dataManager.getColumnsToDraw_forYahooHistoricalData(); } //Lokale Daten else if (CB_Quelle_Lokal.Checked) { listOfRecords = dataManager.getLocallySavedStockData(stockSymbol, dateFrom, dateTo); columnsToDraw = dataManager.getColumnsToDraw_Standard(); } //************************* Historisch *********************************** //************************* Live ***************************************** //OnVista Live if (CB_Quelle_Onvista.Checked) { liveVariant = LiveConnectors.OnVista; } //Dummy Live else if (CB_Quelle_Dummy.Checked) { liveVariant = LiveConnectors.OnVistaDummy; } //************************* Live ***************************************** //************************* Zusammenführung ****************************** //Zusammenführung für historische Variante if (CB_Quelle_Yahoo.Checked || CB_Quelle_Lokal.Checked) { tableObject = new TableObject(workSheet, position, listOfRecords, columnsToDraw); tableObject.drawAll(); } //Zusammenführung für Live-Variante else if (CB_Quelle_Onvista.Checked || CB_Quelle_Dummy.Checked) { tableObject = new TableObject(workSheet, position, dataManager.getColumnsToDraw_LiveStockData()); dataManager.subscribeForLiveConnection(stockSymbol, tableObject, liveVariant); tableObject.drawAll(); } //************************* Zusammenführung ****************************** } } else { MessageBox.Show("Es sind nicht alle nötigen Optionen ausgefüllt! Bitte Auswahl überprüfen!"); } }