Exemplo n.º 1
0
        /// <summary>
        /// Load the Account Details from a CSV File
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void loadToolStripMenuItem_Click(object sender, EventArgs e)
        {
            const string FILTER = "CSV Files|*.csv|TXT FILES|*.txt|All Files|*.*";

            string[] lineRead     = null;
            string   lineReadFull = "";

            AutoSave.Filter = FILTER;

            if (AutoSave.ShowDialog() == DialogResult.OK)
            {
                try
                {
                    StreamReader reader = File.OpenText(AutoSave.FileName);

                    while (!reader.EndOfStream)
                    {
                        lineReadFull = reader.ReadLine();
                        lineRead     = lineReadFull.Split(',');

                        if (lineReadFull == "<!DOCTYPE html PUBLIC")
                        {
                        }
                        else
                        {
                            try
                            {
                                //Set the textboxes equal to data
                                if (lineRead[0] != null)
                                {
                                    kongUsername         = lineRead[0];
                                    textBoxKongUser.Text = lineRead[0];
                                }
                                if (lineRead[1] != null)
                                {
                                    kongID             = lineRead[1];
                                    textBoxKongID.Text = lineRead[1];
                                }
                                if (lineRead[2] != null)
                                {
                                    kongToken             = lineRead[2];
                                    textBoxKongToken.Text = lineRead[2];
                                }
                                if (tabPage1.Text == "Client")
                                {
                                    this.Size = new Size(736, 538);
                                    //Set the IOU Client to its approiate sizing
                                    tabControl.Width  = 746;
                                    tabControl.Height = 580;
                                    this.Size         = new Size(756, 600);
                                    //this.Size = new Size(1052, 768);
                                    oldIOUclient.Height = 550;
                                    oldIOUclient.Width  = 736;
                                    //Get the black cut off
                                    oldIOUclient.Location = new Point(0, 0);
                                    updateClient(oldIOUclient);
                                }
                                else
                                {
                                    string  title     = "TabPage " + (tabControl.TabCount + 1).ToString();
                                    TabPage myTabPage = new TabPage(title);
                                    tabControl.TabPages.Add(myTabPage);
                                    myTabPage.Text         = kongUsername;
                                    tabControl.SelectedTab = myTabPage;

                                    WebBrowser IOUclient2 = new WebBrowser();
                                    myTabPage.Controls.Add(IOUclient2);
                                    IOUclient2.Height = 550;
                                    IOUclient2.Width  = 736;
                                    //Update the client
                                    updateClient(IOUclient2);
                                }
                            }
                            catch (Exception ex)
                            {
                                MessageBox.Show(ex.ToString());
                            }
                        }
                    }
                    reader.Close();
                }
                catch (FileNotFoundException ex)
                {
                    MessageBox.Show(ex.Message);
                }
            }
        }