コード例 #1
0
        private void restoreForms()
        {
            string        tempPath = Application.StartupPath + "/temp";
            DirectoryInfo d        = new DirectoryInfo(tempPath); //Assuming Test is your Folder

            FileInfo[] Files = d.GetFiles("*.xml");               //Getting Text files
            foreach (FileInfo file in Files)
            {
                using (StreamReader streamReader = new StreamReader(file.FullName, Encoding.UTF8))
                {
                    string        props    = streamReader.ReadToEnd();
                    FormProps     formprop = FormProps.ConvertFromXMLString(props);
                    cli_generator cli      = new cli_generator(formprop);

                    if (cli.AddSSH(txtHost.Text, txtUsername.Text, txtPassword.Text, txtPort.Text))
                    {
                        cli.ShowForm();
                    }



                    statusBox.BackColor = System.Drawing.Color.LimeGreen;
                    btnCLI.Enabled      = true;
                    menuCLINew.Enabled  = true;
                    btnConnect.Enabled  = false;

                    Thread.Sleep(500);
                }
            }
            formsRestored = true;



            foreach (FileInfo file in Files)
            {
                if (File.Exists(file.FullName))
                {
                    File.Delete(file.FullName);
                }
            }
        }
コード例 #2
0
        public void loadCLIForm()
        {
            if (!formsRestored)
            {
                string        tempPath = Application.StartupPath + "/temp";
                DirectoryInfo d2       = new DirectoryInfo(tempPath); //Assuming Test is your Folder
                                                                      //  FileInfo[] Files2 = d2.GetFiles("*.xml"); //Getting Text files
                if (d2.GetFiles("*.xml").Any())
                {
                    if (MessageBox.Show("Do you want to load previous session?", Text, MessageBoxButtons.YesNo, MessageBoxIcon.Information) == DialogResult.Yes)
                    {
                        restoreForms();
                    }
                    else
                    {
                        FileInfo[] Files2 = d2.GetFiles("*.xml"); //Getting Text files

                        foreach (FileInfo file in Files2)
                        {
                            if (File.Exists(file.FullName))
                            {
                                File.Delete(file.FullName);
                            }
                        }
                        cli_generator cli = new cli_generator();

                        //cli.AddSSH(txtHost.Text, txtUsername.Text, txtPassword.Text, txtPort.Text);

                        if (cli.AddSSH(txtHost.Text, txtUsername.Text, txtPassword.Text, txtPort.Text))
                        {
                            cli.ShowForm();
                        }



                        formsRestored = true;
                    }
                }
                else
                {
                    cli_generator cli = new cli_generator();
                    if (cli.AddSSH(txtHost.Text, txtUsername.Text, txtPassword.Text, txtPort.Text))
                    {
                        cli.ShowForm();
                    }
                    statusBox.BackColor = System.Drawing.Color.LimeGreen;
                    btnCLI.Enabled      = true;
                    menuCLINew.Enabled  = true;
                    btnConnect.Enabled  = false;
                    formsRestored       = true;
                }
            }
            else
            {
                cli_generator cli = new cli_generator();

                if (cli.AddSSH(txtHost.Text, txtUsername.Text, txtPassword.Text, txtPort.Text))
                {
                    cli.ShowForm();
                }
                statusBox.BackColor = System.Drawing.Color.LimeGreen;
                btnCLI.Enabled      = true;
                menuCLINew.Enabled  = true;
                btnConnect.Enabled  = false;
            }
        }