Ejemplo n.º 1
0
        private void buttonImport_Click(object sender, EventArgs e)
        {
            try
            {
                if (importQuoteFileDialog.ShowDialog() != DialogResult.OK)
                {
                    return;
                }

                List <Quote> items   = null;
                int          pos     = importQuoteFileDialog.FileName.LastIndexOf('.');
                string       dirName = importQuoteFileDialog.FileName.Substring(0, pos);

                pos = dirName.LastIndexOf('\\');
                string name = dirName.Substring(pos + 1, dirName.Length - pos - 1);

                if (importQuoteFileDialog.FileName.EndsWith("txt"))
                {
                    textBoxFileName.Text = "";

                    items = TextImporter.Import(importQuoteFileDialog.FileName);

                    //foreach (string filename in importQuoteFileDialog.FileNames)
                    //{
                    //    textBoxFileName.Text += filename + " ";
                    //}

                    //int pos = importQuoteFileDialog.FileNames[0].LastIndexOf(importQuoteFileDialog.FileNames.Count() == 1 ? '.' : '\\');
                    //string dirName = importQuoteFileDialog.FileNames[0].Substring(0, pos);

                    //foreach (string fileName in importQuoteFileDialog.FileNames)
                    //{
                    //    List<Quote> newItems = TextImporter.Import(fileName);
                    //    items.AddRange(newItems);
                    //}
                }
                else if (importQuoteFileDialog.FileName.EndsWith(PoboImporter.FilePostfix))
                {
                    items = PoboImporter.Import(importQuoteFileDialog.FileName);
                }

                History = new QuoteCollection(name, items);

                if (History.Count != 0)
                {
                    loadQuoteInformation();
                    Ephemeris.CurrentEphemeris.Load(History.Since, History.Until);
                }

                launchDetailForm();
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
                Console.WriteLine(ex.StackTrace);
            }
        }
Ejemplo n.º 2
0
        private void browsePoboToolStripMenuItem_Click(object sender, EventArgs e)
        {
            PoboBrowser browser = new PoboBrowser();

            if (browser.ShowDialog() == DialogResult.OK && browser.SelectedFileName != "")
            {
                List <Quote> items = PoboImporter.Import(browser.SelectedFileName);

                History = new QuoteCollection(browser.FutureName, items);

                if (History.Count != 0)
                {
                    Ephemeris.CurrentEphemeris.Load(History.Since, History.Until);
                }

                launchDetailForm();
            }
        }