📄 setfield.cs
字号:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
namespace Match
{
public partial class SetField : Form
{
string[] Fields = new string[8];
bool OnOk = false;
public SetField()
{
InitializeComponent();
}
public void SetData(int[] NumPlayers,int NumField)
{
for (int i = 0; i < NumPlayers.Length; i++)
{
ComboBox cb=new ComboBox();
switch (i)
{
case 0:
textBox16.Text = NumPlayers[i].ToString();
cb = comboBox1;
break;
case 1:
textBox15.Text = NumPlayers[i].ToString();
cb = comboBox2;
break;
case 2:
textBox14.Text = NumPlayers[i].ToString();
cb = comboBox3;
break;
case 3:
textBox13.Text = NumPlayers[i].ToString();
cb = comboBox4;
break;
case 4:
textBox12.Text = NumPlayers[i].ToString();
cb = comboBox5;
break;
case 5:
textBox11.Text = NumPlayers[i].ToString();
cb = comboBox6;
break;
case 6:
textBox10.Text = NumPlayers[i].ToString();
cb = comboBox7;
break;
case 7:
textBox9.Text = NumPlayers[i].ToString();
cb = comboBox8;
break;
}
if (NumPlayers[i] > 0)
{
for (int j = 0; j < NumField; j++)
{
object Field = (char)(j + 65);
cb.Items.Add(Field);
}
}
else
{
cb.Enabled = false;
}
}
}
public void SetFields(string[] Field)
{
for (int i = 0; i < Field.Length; i++)
{
switch (i)
{
case 0: comboBox1.Text = Field[i];
break;
case 1: comboBox2.Text = Field[i];
break;
case 2: comboBox3.Text = Field[i];
break;
case 3: comboBox4.Text = Field[i];
break;
case 4: comboBox5.Text = Field[i];
break;
case 5: comboBox6.Text = Field[i];
break;
case 6: comboBox7.Text = Field[i];
break;
case 7: comboBox8.Text = Field[i];
break;
}
}
}
private void button_OK_Click(object sender, EventArgs e)
{
if (!Check()) {
MessageBox.Show("有的组没有设置场地!");
return;
}
OnOk = true;
this.Close();
}
private bool Check()
{
for (int i = 0; i < 8; i++)
{
switch (i)
{
case 0: if (textBox16.Text != "0" && comboBox1.Text == "") return false;
break;
case 1: if (textBox15.Text != "0" && comboBox2.Text == "") return false;
break;
case 2: if (textBox14.Text != "0" && comboBox3.Text == "") return false;
break;
case 3: if (textBox13.Text != "0" && comboBox4.Text == "") return false;
break;
case 4: if (textBox12.Text != "0" && comboBox5.Text == "") return false;
break;
case 5: if (textBox11.Text != "0" && comboBox6.Text == "") return false;
break;
case 6: if (textBox10.Text != "0" && comboBox7.Text == "") return false;
break;
case 7: if (textBox9.Text != "0" && comboBox8.Text == "") return false;
break;
}
}
return true;
}
public bool GetReturn()
{
return OnOk;
}
public string[] GetField()
{
return Fields;
}
private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
{
Fields[0] = comboBox1.Text;
}
private void comboBox2_SelectedIndexChanged(object sender, EventArgs e)
{
Fields[1] = comboBox2.Text;
}
private void comboBox3_SelectedIndexChanged(object sender, EventArgs e)
{
Fields[2] = comboBox3.Text;
}
private void comboBox4_SelectedIndexChanged(object sender, EventArgs e)
{
Fields[3] = comboBox4.Text;
}
private void comboBox5_SelectedIndexChanged(object sender, EventArgs e)
{
Fields[4] = comboBox5.Text;
}
private void comboBox6_SelectedIndexChanged(object sender, EventArgs e)
{
Fields[5] = comboBox6.Text;
}
private void comboBox7_SelectedIndexChanged(object sender, EventArgs e)
{
Fields[6] = comboBox7.Text;
}
private void comboBox8_SelectedIndexChanged(object sender, EventArgs e)
{
Fields[7] = comboBox8.Text;
}
private void button1_Click(object sender, EventArgs e)
{
OnOk = false;
this.Close();
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -