Esempio n. 1
0
        private void button1_Click(object sender, EventArgs e)
        {
            OpenFileDialog openFileDialog1 = new OpenFileDialog();

            try
            {
                string filename = txt_path.Text;
                openFileDialog1.FileName = filename;
                string[]  filelines = File.ReadAllLines(filename);
                ArrayList chartData = new ArrayList();
                string[]  fileName  = openFileDialog1.SafeFileName.Split('.');

                ArrayList usersCharts = DataBase.getUsersChartList(User.curUsername);
                if (usersCharts.Contains(fileName[0]))
                {
                    MessageBox.Show("You allready have " + fileName[0] + " in your chart list!");
                    return;
                }

                foreach (String line in filelines)
                {
                    string[] words = line.Split(',');
                    try
                    {
                        DateTime myDate = DateTime.ParseExact(words[0], "yyyyMMdd", System.Globalization.CultureInfo.InvariantCulture, System.Globalization.DateTimeStyles.None);
                        DateTime myTime = DateTime.ParseExact(words[1], "HHmmss", System.Globalization.CultureInfo.InvariantCulture, System.Globalization.DateTimeStyles.None);

                        myDate = myDate.Add(myTime.TimeOfDay);

                        Double open  = Convert.ToDouble(words[2]);
                        Double high  = Convert.ToDouble(words[3]);
                        Double low   = Convert.ToDouble(words[4]);
                        Double close = Convert.ToDouble(words[5]);
                        chartData.Add(new Candle(myDate, high, low, open, close));
                    }
                    catch
                    {
                        MessageBox.Show("File format is invalid. Error in line: \n" + line);
                        return;
                    }
                }

                progressBar1.Show();
                if (DataBase.addNewChart(chartData, fileName[0], User.curUsername))
                {
                    cmbbx_importedCharts.Items.Add(fileName[0]);
                    frm_mainForm frm = ((frm_mainForm)Application.OpenForms["frm_mainForm"]);
                    frm.BuildMenuItems();
                }

                progressBar1.Hide();;
            }
            catch (Exception ex)
            {
                MessageBox.Show("File error: " + ex.Message);
                progressBar1.Hide();
            }
        }
Esempio n. 2
0
        public void getDataFromGoogle_Async(String exchange, String symbol, String period, int interval)
        {
            DownloadURIBuilder db      = new DownloadURIBuilder();
            WebClient          wClient = new WebClient();
            Uri urlAddress             = new Uri(db.getGetPricesUri(symbol, exchange, period, interval));

            wClient.DownloadStringCompleted += new DownloadStringCompletedEventHandler((sender, e) => DownloadComplete(sender, e, symbol));
            wClient.DownloadStringAsync(urlAddress);

            foreach (Form frm in Application.OpenForms)
            {
                if (frm.Name == "frm_mainForm")
                {
                    frm_mainForm form = (frm_mainForm)frm;
                    form.isConnected = false;
                }
            }
        }
Esempio n. 3
0
        private void btn_delete_Click(object sender, EventArgs e)
        {
            if (cmbbx_importedCharts.SelectedIndex == -1)
            {
                return;
            }
            if (DataBase.deleteChartData(cmbbx_importedCharts.SelectedItem.ToString(), User.curUsername))
            {
                MessageBox.Show(cmbbx_importedCharts.SelectedItem.ToString() + " deleted from the chart list");
                cmbbx_importedCharts.Items.Clear();
                ArrayList ImportedCharts = DataBase.getUsersImportedChartList(User.curUsername);
                foreach (String symbolName in ImportedCharts)
                {
                    cmbbx_importedCharts.Items.Add(symbolName);
                    frm_mainForm frm = ((frm_mainForm)Application.OpenForms["frm_mainForm"]);
                    frm.BuildMenuItems();
                }
            }

            cmbbx_importedCharts.SelectedIndex = -1;
        }
Esempio n. 4
0
        public void DownloadComplete(Object sender, DownloadStringCompletedEventArgs e, String symbol)
        {
            if (!e.Cancelled && e.Error == null)
            {
                string        result  = (string)e.Result;
                MemoryStream  ms      = new MemoryStream(System.Text.Encoding.Default.GetBytes(result));
                DataProcessor dp      = new DataProcessor();
                ArrayList     candles = dp.getHistory(ms, 60);
                foreach (Form frm in Application.OpenForms)
                {
                    if (frm.Name == symbol)
                    {
                        frm_chart form = (frm_chart)frm;
                        form.dispayChart(form.ChartControl, candles);
                    }

                    if (frm.Name == "frm_mainForm")
                    {
                        frm_mainForm form = (frm_mainForm)frm;
                        form.isConnected = true;
                    }

                    if (frm.Name == "frm_LiveQuotes")
                    {
                        frm_LiveQuotes form = (frm_LiveQuotes)frm;
                        form.update(symbol, (Candle)candles[candles.Count - 1]);
                    }

                    if (frm.Name == "frm_Alerts")
                    {
                        frm_Alerts form = (frm_Alerts)frm;
                        form.update(symbol, (Candle)candles[candles.Count - 1]);
                    }
                }
            }
        }
Esempio n. 5
0
        private void frm_LiveQuotes_FormClosed(object sender, FormClosedEventArgs e)
        {
            frm_mainForm frm = (frm_mainForm)Application.OpenForms["frm_mainForm"];

            frm.enbaleQuotes();
        }