예제 #1
0
 public static void LoadSettings()
 {
     var json = Properties.Settings.Default.Boxes;
     var jsonSerialiser = new JavaScriptSerializer();
     // Deserialise
     var deserialised = jsonSerialiser.Deserialize<Box[]>(json);
     foreach (Box box in deserialised)
     {
         MainWindow.vagrantBoxList.id++;
         int newID = MainWindow.vagrantBoxList.id;
         Box objBox = new Box(newID, box.boxName, box.boxPath, false);
         MainWindow.vagrantBoxList.list.Add(box);
     }
 }
예제 #2
0
 private void AddBoxProcess()
 {
     // Check that the file is a Vagrantfile, and name is not empty
     if (txtName.Text != "" && Path.GetFileName(txtPath.Text).ToLower() == "vagrantfile" && Path.GetExtension(txtPath.Text) == "" && File.Exists(txtPath.Text))
     {
         MainWindow.vagrantBoxList.id++;
         int newID = MainWindow.vagrantBoxList.id;
         Box objBox = new Box(newID, txtName.Text, txtPath.Text, false);
         MainWindow.vagrantBoxList.AddBox(objBox);
         this.Close();
     }
     else if (txtName.Text == "")
     {
         MessageBox.Show("The name of this box cannot be blank.");
     }
     else
     {
         MessageBox.Show("Sorry, that isn't a valid Vagrantfile.");
     }
 }
예제 #3
0
 // They can just do list.Add(box) but this AddBox also refreshes the menu
 public void AddBox(Box Box)
 {
     list.Add(Box);
     Program.mainWindow.RefreshMenu();
 }