示例#1
0
文件: Form1.cs 项目: Neophear/MassSSH
        private void OpenScriptCol(string path)
        {
            try
            {
                scol      = ScriptCollection.Deserialize(path);
                this.Text = Path.GetFileName(scol.SavedPath);

                scol.PropertyChanged   += Scol_PropertyChanged;
                lstbxScripts.DataSource = scol.Scripts;
                AddLatest(path);
            }
            catch (FileNotFoundException)
            {
                if (fpcLatest.Exists(x => x == path))
                {
                    if (MessageBox.Show("Filen findes ikke. Fjern fra Seneste?", "Fil ikke fundet", MessageBoxButtons.YesNo) == DialogResult.Yes)
                    {
                        fpcLatest.RemoveAt(fpcLatest.FindIndex(x => x == path));
                        RefreshLatestMenu();
                    }
                }
                else
                {
                    MessageBox.Show("Filen findes ikke.");
                }
            }
            catch (InvalidOperationException)
            {
                MessageBox.Show("Kunne ikke åbne. Filen er muligvis korrupt.");
            }
        }
示例#2
0
文件: Form1.cs 项目: Neophear/MassSSH
 private void SaveAs(string path)
 {
     ScriptCollection.Serialize(scol, path);
     SetBottomText("Gemt");
     saved     = true;
     this.Text = Path.GetFileName(path);
     AddLatest(path);
 }
示例#3
0
        public static void Serialize(ScriptCollection scol, string path)
        {
            XmlSerializer serializer = new XmlSerializer(typeof(ScriptCollection));

            using (TextWriter writer = new StreamWriter(path))
            {
                serializer.Serialize(writer, scol);
            }

            scol.savedPath = path;
        }
示例#4
0
文件: Form1.cs 项目: Neophear/MassSSH
 private void mnuFileNew_Click(object sender, EventArgs e)
 {
     if (CheckIfSaved())
     {
         scol = new ScriptCollection();
         lstbxScripts.DataSource = null;
         lstbxHosts.DataSource   = null;
         saved     = true;
         this.Text = "Nyt script";
         txtCommands.Clear();
         txtUsername.Clear();
         txtPassword.Clear();
         txtOutput.Clear();
     }
 }