Exemplo 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);
            }
        }
Exemplo 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();
            }
        }
Exemplo n.º 3
0
        private void appendGoodsSummary()
        {
            if (tabControlMarkets.SelectedTab.Controls.Count != 0)
            {
                return;
            }

            DataGridView  allGoodsView    = new DataGridView();
            BindingSource summaryBindings = new BindingSource();

            allGoodsView.Dock                = DockStyle.Fill;
            allGoodsView.ScrollBars          = ScrollBars.Both;
            allGoodsView.MultiSelect         = false;
            allGoodsView.AutoGenerateColumns = true;
            allGoodsView.SelectionMode       = DataGridViewSelectionMode.FullRowSelect;
            tabControlMarkets.SelectedTab.Controls.Add(allGoodsView);

            Dictionary <string, string> allGoods = PoboImporter.AllGoodsOf(tabControlMarkets.SelectedTab.Tag as string);

            allGoodsView.Tag = allGoods;

            List <PoboDayFileSummary> summaries = new List <PoboDayFileSummary>();

            foreach (KeyValuePair <string, string> kvp in allGoods)
            {
                PoboDayFileSummary newSummary = new PoboDayFileSummary(kvp.Key, kvp.Value);
                if (newSummary == null)
                {
                    continue;
                }

                summaries.Add(newSummary);
            }

            summaryBindings.DataSource     = summaries;
            allGoodsView.DataSource        = summaryBindings;
            allGoodsView.SelectionChanged += new EventHandler(allGoodsView_SelectionChanged);
            allGoodsView.AutoResizeColumns(DataGridViewAutoSizeColumnsMode.AllCells);
            //allGoodsView.Invalidate();
        }