示例#1
0
 private void btnOK_Click(object sender, EventArgs e)
 {
     ComboBox cbKit = ((frmKits)this.Owner).cbKit;
     Kit newkit = new Kit(this.tbName.Text);
     if (!cbKit.Items.Contains(newkit))
     {
         cbKit.Items.Add(newkit);
         cbKit.SelectedIndex = cbKit.Items.Count - 1;
     }
     this.Close();
 }
示例#2
0
 void LoadKitThread(object kitname_x)
 {
     string kitname = (string)kitname_x;
     bool downloadsucc = Program.DownloadURLToFile("http://internal.mcadmin.eu/kitshare/kits/" + kitname + ".kit", "tmpkit.kit");
     Kit thiskit = null;
     if (downloadsucc)
     {
         thiskit = new Kit(kitname, "tmpkit.kit");
         File.Delete("tmpkit.kit");
     }
     lvItems.Invoke(new MethodInvoker(delegate()
     {
         lvItems.Items.Clear();
         if (downloadsucc && thiskit != null)
         {
             foreach (KeyValuePair<int, int> kv in thiskit.items)
             {
                 lvItems.Items.Add(new ListViewItem(new string[] { kv.Key.ToString(), Program.blockIDEnum[kv.Key], kv.Value.ToString() }));
             }
             btnDownload.Enabled = true;
             lvItems.Enabled = true;
         }
     }));
 }
示例#3
0
文件: Program.cs 项目: astory/MCAdmin
 public static void LoadKits()
 {
     kits.Clear();
     if (!Directory.Exists("kits")) Directory.CreateDirectory("kits");
     Kit k;
     foreach (string f in Directory.GetFiles("kits", "*.kit"))
     {
         string kn = f.Remove(f.Length - 4).Substring(5);
         try
         {
             k = new Kit(kn);
         }
         catch (BadImageFormatException)
         {
             File.Delete("NBT.dll");
             DownloadURLToFile("https://internal.mcadmin.eu/NBT.dll", "NBT.dll");
             try
             {
                 k = new Kit(kn);
             }
             catch (BadImageFormatException)
             {
                 AddRTLine(Color.Red, "Restart me!\r\n", false);
                 if (consoleOnly) Console.In.ReadLine();
                 else MessageBox.Show("Restart me!");
                 KillServer();
                 Environment.Exit(0);
                 return;
             }
             catch (Exception e)
             {
                 AddRTLine(Color.Red, "Error loading kit " + kn + ": \r\n\r\n" + e.ToString(), false);
                 k = null;
             }
         }
         catch (Exception e)
         {
             AddRTLine(Color.Red, "Error loading kit " + kn + ": \r\n\r\n" + e.ToString(), false);
             k = null;
         }
         if (k != null && k.saved) kits.Add(k);
         else File.Delete(f);
     }
 }