コード例 #1
0
        private void Button1_Click(object sender, EventArgs e)
        {
            if (string.IsNullOrWhiteSpace(server_name.Text) ||
                string.IsNullOrWhiteSpace(server_local.Text) ||
                string.IsNullOrWhiteSpace(server_core.Text))
            {
                MessageBox.Show("参数缺少,请检查");
                return;
            }
            string a = server_save.server_name;

            server_save.server_name  = server_name.Text;
            server_save.server_local = server_local.Text;
            server_save.server_core  = server_core.Text;
            server_save.server_arg   = server_arg.Text;
            server_save.java_local   = java_local.Text;
            server_save.java_arg     = java_arg.Text;
            server_save.min_m        = (int)java_min.Value;
            server_save.max_m        = (int)java_max.Value;
            server_save.auto_restart = auto_restart.Checked;
            server_save.open_start   = open_start.Checked;
            Config_write.write_server(Start.APP_local + Config_file.server, server_save);
            if (Config_file.server_list.ContainsKey(a) == true)
            {
                Config_file.server_list.Remove(a);
            }
            Config_file.server_list.Add(server_save.server_name, server_save);
            Start.updata = true;
        }
コード例 #2
0
 private void Button_add_Click(object sender, EventArgs e)
 {
     if (string.IsNullOrWhiteSpace(server_name.Text) ||
         string.IsNullOrWhiteSpace(server_local.Text) ||
         string.IsNullOrWhiteSpace(server_core.Text))
     {
         MessageBox.Show("参数缺少,请检查");
         return;
     }
     Dictionary <string, Server_Save> .ValueCollection temp = Config_file.server_list.Values;
     foreach (Server_Save a in temp)
     {
         if (a.Config.server_name == server_name.Text)
         {
             MessageBox.Show("服务器名已存在,请更换");
             return;
         }
         else if (a.Config.server_local == server_local.Text)
         {
             MessageBox.Show("服务器名已存在,请更换");
             return;
         }
     }
     try
     {
         Server_Save server = new Server_Save()
         {
             Config = new Server_Config()
             {
                 server_name  = server_name.Text,
                 server_local = server_local.Text,
                 server_core  = server_core.Text,
                 java_local   = java_local.Text,
                 java_arg     = java_arg.Text,
                 auto_restart = auto_restart.Checked,
                 open_start   = open_start.Checked,
                 min_m        = (int)java_min.Value,
                 max_m        = (int)java_max.Value
             }
         };
         Config_write.write_server(Start.APP_local + Config_file.server, server);
         Config_file.server_list.Add(server.Config.server_name, server);
         MessageBox.Show("已添加");
         Start.updata = true;
         Close();
     }
     catch (Exception ex)
     {
         logs.Log_write("[ERROR]" + ex.Message);
     }
 }