private void Button_Click_Add_Crypto(object sender, RoutedEventArgs e) { string cryptoCurrency = ParseCurrencyInput(nameOfCryptoCurrency, FileType.CRYPTO_CURRENCY); string currency = ParseCurrencyInput(nameOfCurrency, FileType.CURRENCY); if (!currency.Equals("") & !cryptoCurrency.Equals("")) { string nameOfSeries = cryptoCurrency + "__" + currency; bool success = Gvm.addSeries(nameOfSeries, "CRYPTO CURRENCIES"); if (success) { Thread newWindowThread = new Thread(new ThreadStart(showWaitDialog)); newWindowThread.SetApartmentState(ApartmentState.STA); newWindowThread.IsBackground = true; newWindowThread.Start(); string contentOfTimeSeriesComboBox = TimeSeriesTypeComboBox.Text; int counterAttempts = 0; List <DataPoint> dataPoints; do { dataPoints = Mwvm.getSpecificData(cryptoCurrency, contentOfTimeSeriesComboBox, currentSelectedForCrypto + " crypto", "", currency); if (dataPoints != null) { Gvm.addPoints(nameOfSeries, dataPoints); double[] values = Statistics.getValues(dataPoints); StatisticsTable.Items.Add(new Statistics(values, "crypto", nameOfSeries)); } counterAttempts++; } while (dataPoints == null && counterAttempts < 3); CloseDialogSafe(); newWindowThread.Abort(); if (dataPoints == null) { Gvm.removeSeries(nameOfSeries); MessageBox.Show("Problem with data delivery for " + nameOfSeries, "Error"); } } else { MessageBox.Show("This series already exists!"); } } else { MessageBox.Show("Invalid input!"); } PlotView.InvalidatePlot(true); // refresh }
private void Button_Delete_Click(object sender, RoutedEventArgs e) { int index = StatisticsTable.SelectedIndex; if (index >= 0) { StatisticsTable.Items.RemoveAt(index); Gvm.removeSeries(index); PlotView.InvalidatePlot(true); // refresh } }
void Window_Closing(object sender, System.ComponentModel.CancelEventArgs e) { //DialogForSaveWorkspace dfsw = new DialogForSaveWorkspace(); //dfsw.ShowDialog(); string messageBoxText = "Do you want to save workspace?"; string caption = "Save workspace"; MessageBoxButton button = MessageBoxButton.YesNoCancel; MessageBoxImage icon = MessageBoxImage.Question; MessageBoxResult result = MessageBox.Show(messageBoxText, caption, button, icon); // Process message box results switch (result) { case MessageBoxResult.Yes: List <string> titles = Gvm.getAllSeriesTitles(); string interval; string timeSeriesType = TimeSeriesTypeComboBox.Text; if (timeSeriesType.Equals("INTRADAY")) { interval = IntervalComboBox.Text; } else { interval = ""; } saveWorkspace(titles, currentSelectedForShares, currentSelectedForCrypto, timeSeriesType, interval); e.Cancel = false; break; case MessageBoxResult.No: e.Cancel = false; break; case MessageBoxResult.Cancel: e.Cancel = true; break; } }
/*private void selektujOdgovarajuciRadioButton() * { * switch(currentSelected) * { * case "open": * rbOpen.IsChecked = true; * break; * case "high": * rbHigh.IsChecked = true; * break; * case "low": * rbLow.IsChecked = true; * break; * case "close": * rbClose.IsChecked = true; * break; * case "volume": * rbVolume.IsChecked = true; * break; * // all - ne moze biti inicijalno selektovano, jer nema all u glavnom prozoru * default: break; * } * }*/ /*private void rbOpen_Click(object sender, RoutedEventArgs e) * { * if (currentSelected.Equals("open")) return; * * currentSelected = "open"; * string contentOfTimeSeriesComboBox = TimeSeriesTypeComboBox.Text; * string interval; * * if (contentOfTimeSeriesComboBox.Equals("INTRADAY")) * { * interval = IntervalComboBox.Text; * } * else * { * interval = ""; * } * iscrtajIspocetka(contentOfTimeSeriesComboBox); * } * * private void rbHigh_Click(object sender, RoutedEventArgs e) * { * if (currentSelected.Equals("high")) return; * * currentSelected = "high"; * string contentOfTimeSeriesComboBox = TimeSeriesTypeComboBox.Text; * string interval; * * if (contentOfTimeSeriesComboBox.Equals("INTRADAY")) * { * interval = IntervalComboBox.Text; * } * else * { * interval = ""; * } * * iscrtajIspocetka(contentOfTimeSeriesComboBox); * } * * private void rbLow_Click(object sender, RoutedEventArgs e) * { * if (currentSelected.Equals("low")) return; * * currentSelected = "low"; * string contentOfTimeSeriesComboBox = TimeSeriesTypeComboBox.Text; * string interval; * * if (contentOfTimeSeriesComboBox.Equals("INTRADAY")) * { * interval = IntervalComboBox.Text; * } * else * { * interval = ""; * } * * iscrtajIspocetka(contentOfTimeSeriesComboBox); * } * * private void rbClose_Click(object sender, RoutedEventArgs e) * { * if (currentSelected.Equals("close")) return; * * currentSelected = "close"; * string contentOfTimeSeriesComboBox = TimeSeriesTypeComboBox.Text; * string interval; * * if (contentOfTimeSeriesComboBox.Equals("INTRADAY")) * { * interval = IntervalComboBox.Text; * } * else * { * interval = ""; * } * * iscrtajIspocetka(contentOfTimeSeriesComboBox); * } * * private void rbVolume_Click(object sender, RoutedEventArgs e) * { * if (currentSelected.Equals("volume")) return; * * currentSelected = "volume"; * string contentOfTimeSeriesComboBox = TimeSeriesTypeComboBox.Text; * string interval; * * if (contentOfTimeSeriesComboBox.Equals("INTRADAY")) * { * interval = IntervalComboBox.Text; * } * else * { * interval = ""; * } * * iscrtajIspocetka(contentOfTimeSeriesComboBox); * } * * private void rbAll_Click(object sender, RoutedEventArgs e) * { * if (currentSelected.Equals("all")) return; * * currentSelected = "all"; * string contentOfTimeSeriesComboBox = TimeSeriesTypeComboBox.Text; * string interval; * * if (contentOfTimeSeriesComboBox.Equals("INTRADAY")) * { * interval = IntervalComboBox.Text; * } * else * { * interval = ""; * } * * iscrtajIspocetka(contentOfTimeSeriesComboBox); * }*/ private void iscrtajIspocetka(string contentOfTimeSeriesComboBox) { Gvm.clearAllSeries(); string symbol; string market; string interval = ""; string[] allSeries; if (Title.Contains("__")) { string[] tokens = Title.Split(new string[] { "__" }, System.StringSplitOptions.None); symbol = tokens[0]; market = tokens[1]; if (contentOfTimeSeriesComboBox.Equals("INTRADAY")) { allSeries = contentsForRadioButtonsIntraday; } else { allSeries = contentsForRadioButtonsAnother; } } else { symbol = Title; market = ""; allSeries = contentsForRadioButtonsForShares; if (contentOfTimeSeriesComboBox.Equals("INTRADAY")) { interval = IntervalComboBox.Text; } } if (!currentSelected.Equals("all")) { Gvm.addSeriesWithOutCheck(currentSelected.ToUpper()); List <DataPoint> dataPoints = Mwvm.getSpecificData(symbol, contentOfTimeSeriesComboBox, currentSelected, interval, market); if (dataPoints != null) { Gvm.addPoints(currentSelected.ToUpper(), dataPoints); } else { MessageBox.Show("Problem sa dobavljanjem podataka", "Greska"); } } else { Gvm.addAllSeries(allSeries); List <DataPoint>[] dataPointsArray; if (market.Equals("")) { dataPointsArray = Mwvm.getDataForOpenHighLowCloseForShares(Title, contentOfTimeSeriesComboBox, interval); } else { dataPointsArray = Mwvm.getDataForOpenHighLowCloseForCrypto(Title, contentOfTimeSeriesComboBox); } List <string> seriesTitles = Gvm.getAllSeriesTitles(); for (int i = 0; i < seriesTitles.Count; i++) { if (dataPointsArray[i] != null) { Gvm.addPoints(seriesTitles[i], dataPointsArray[i]); } } } PlotView.InvalidatePlot(true); // refresh }
private void iscrtajIspocetka(string contentOfTimeSeriesComboBox) { Gvm.clearAllPoints(); StatisticsTable.Items.Clear(); List <string> potencijalneGreske = new List <string>(); List <DataPoint> dataPoints; List <string> seriesTitles = Gvm.getAllSeriesTitles(); string market; string currentSelected; string symbol; string[] tokens; string type; string interval; /*Thread newWindowThread = new Thread(new ThreadStart(showWaitDialog)); * newWindowThread.SetApartmentState(ApartmentState.STA); * newWindowThread.IsBackground = true; * newWindowThread.Start();*/ foreach (string st in seriesTitles) { if (st.Contains("__")) { //ovo imaju crypto valute u svom nazivu currentSelected = currentSelectedForCrypto + " crypto"; tokens = st.Split(new string[] { "__" }, System.StringSplitOptions.None); symbol = tokens[0]; market = tokens[1]; type = "crypto"; interval = ""; } else { currentSelected = currentSelectedForShares; symbol = st; market = ""; type = "shares"; if (contentOfTimeSeriesComboBox.Equals("INTRADAY")) { interval = IntervalComboBox.Text; } else { interval = ""; } } int counterAttempts = 0; do { dataPoints = Mwvm.getSpecificData(symbol, contentOfTimeSeriesComboBox, currentSelected, interval, market); if (dataPoints != null) { Gvm.addPoints(st, dataPoints); double[] values = Statistics.getValues(dataPoints); StatisticsTable.Items.Add(new Statistics(values, type, st)); } counterAttempts++; } while (dataPoints == null && counterAttempts < 3); if (dataPoints == null) { potencijalneGreske.Add(st); //MessageBox.Show("Problem with data delivery for " + st, "Error"); } } //LastUpdatedTextBlock.Text = "Last Updated: " + DateTime.Now; PlotView.InvalidatePlot(true); // refresh //CloseDialogSafe(); //newWindowThread.Abort(); if (potencijalneGreske.Count > 0) { MessageBox.Show("Problem with data delivery for: " + getMessage(potencijalneGreske), "Error"); } }
private void Button_Click_Add_Shares(object sender, RoutedEventArgs e) { bool success = false; string share = ParseCurrencyInput(titleOfSeries, FileType.SHARE); if (!share.Equals("")) { success = Gvm.addSeries(share, "SHARES"); if (success) { Thread newWindowThread = new Thread(new ThreadStart(showWaitDialog)); newWindowThread.SetApartmentState(ApartmentState.STA); newWindowThread.IsBackground = true; newWindowThread.Start(); string contentOfTimeSeriesComboBox = TimeSeriesTypeComboBox.Text; string interval; if (contentOfTimeSeriesComboBox.Equals("INTRADAY")) { interval = IntervalComboBox.Text; } else { interval = ""; } List <DataPoint> dataPoints; int counterAttempts = 0; do { dataPoints = Mwvm.getSpecificData(share, contentOfTimeSeriesComboBox, currentSelectedForShares, interval, ""); if (dataPoints != null) { Gvm.addPoints(share, dataPoints); double[] values = Statistics.getValues(dataPoints); StatisticsTable.Items.Add(new Statistics(values, "shares", titleOfSeries.Text.ToUpper())); } counterAttempts++; }while (dataPoints == null && counterAttempts < 3); CloseDialogSafe(); newWindowThread.Abort(); if (dataPoints == null) { Gvm.removeSeries(share); MessageBox.Show("Problem with data delivery for " + share, "Error"); } } else { MessageBox.Show("This series already exists!"); } } else { MessageBox.Show("Invalid input!"); } PlotView.InvalidatePlot(true); // refresh }
private void Window_Loaded(object sender, RoutedEventArgs e) { List <string> potencijalneGreske = new List <string>(); Thread newWindowThread = new Thread(new ThreadStart(showWaitDialog)); newWindowThread.SetApartmentState(ApartmentState.STA); newWindowThread.IsBackground = true; newWindowThread.Start(); Workspace ws = loadWorkspace(); if (ws == null) { return; } currentSelectedForShares = ws.CurrentSelectedForShares; currentSelectedForCrypto = ws.CurrentSelectedForCrypto; selektujOdgovarajuciRadioButtonForShares(); if (ws.TimeSeriesType.Equals("INTRADAY")) { addRadioButtons(contentsForRadioButtonsIntraday, currentSelectedForCrypto); } else { addRadioButtons(contentsForRadioButtonsAnother, currentSelectedForCrypto); } TimeSeriesTypeComboBox.Text = ws.TimeSeriesType; if (!ws.Interval.Equals("")) { IntervalComboBox.Visibility = Visibility.Visible; IntervalComboBox.Text = ws.Interval; } string currentSelected; bool success; List <DataPoint> dataPoints; string interval; string typeForSeries; string type; string symbol; string market; string[] tokens; foreach (string title in ws.Titles) { if (title.Contains("__")) { typeForSeries = "CRYPTO CURRENCIES"; currentSelected = currentSelectedForCrypto + " crypto"; tokens = title.Split(new string[] { "__" }, System.StringSplitOptions.None); symbol = tokens[0]; market = tokens[1]; type = "crypto"; interval = ""; } else { currentSelected = currentSelectedForShares; typeForSeries = "SHARES"; symbol = title; market = ""; type = "shares"; interval = ws.Interval; } success = Gvm.addSeries(title, typeForSeries); if (success) { int counterAttempts = 0; do { dataPoints = Mwvm.getSpecificData(symbol, ws.TimeSeriesType, currentSelected, interval, market); if (dataPoints != null) { Gvm.addPoints(title, dataPoints); double[] values = Statistics.getValues(dataPoints); StatisticsTable.Items.Add(new Statistics(values, type, title)); } counterAttempts++; }while (dataPoints == null && counterAttempts < 3); if (dataPoints == null) { Gvm.removeSeries(title); potencijalneGreske.Add(title); } } } CloseDialogSafe(); newWindowThread.Abort(); if (potencijalneGreske.Count > 0) { MessageBox.Show("Problem with data delivery for: " + getMessage(potencijalneGreske), "Error"); } LastUpdatedTextBlock.Text = "Last Updated: " + DateTime.Now; }