【发布时间】:2014-01-27 16:23:50
【问题描述】:
我在脚本 cmets 中描述了我的问题。函数 GraphicClassStructure 仅用于创建按钮和标签。但主要功能是plusButton_click。如果我点击第一个加号按钮,我需要它,所以我需要更改第一个添加标签的文本。
脚本:(问题在这里:plusButton_click,我将问题描述为案例)
class GraphicClassStructure : GraphicPosition
{
// Button
public Button plus;
public PictureBox classBackround = new PictureBox();
// Label
Label points;
public void CreateSpellsButton()
{
for (int j = 0; j < 3; j++)
{
for (int i = 0; i < 10; i++)
{
plus = new Button();
points = new Label();
switch (j)
{
case 0:
points.Location = Location[1][i];
points.Location = new Point(points.Location.X + 8, points.Location.Y + 45);
plus.Location = Location[2][i];
break;
case 1:
plus.Location = Location[2][i];
plus.Location = new Point(plus.Location.X + 205, plus.Location.Y);
points.Location = Location[1][i];
points.Location = new Point(points.Location.X + 213, points.Location.Y + 45);
break;
case 2:
plus.Location = Location[2][i];
plus.Location = new Point(plus.Location.X + 410, plus.Location.Y);
points.Location = Location[1][i];
points.Location = new Point(points.Location.X + 418, points.Location.Y + 45);
break;
}
// Labels for point
points.BackColor = Color.Transparent;
points.ForeColor = Color.FromArgb(((int)(((byte)(193)))), ((int)(((byte)(196)))), ((int)(((byte)(181)))));
points.BackgroundImageLayout = ImageLayout.Stretch;
points.FlatStyle = FlatStyle.Flat;
points.Name = "points";
points.Name = spells.Name + i.ToString() + "_" + j.ToString();
if (i >= 6)
points.Text = "0 / 2";
else
points.Text = "0 / 1";
points.VisibleChanged += new EventHandler(classUniqueButtons_VisibleChanged);
// Plus
plus.BackColor = Color.Transparent;
plus.BackgroundImage = BuildResource.plus;
plus.BackgroundImageLayout = ImageLayout.Stretch;
plus.FlatAppearance.BorderSize = 0;
plus.FlatAppearance.MouseDownBackColor = Color.Transparent;
plus.FlatAppearance.MouseOverBackColor = Color.Transparent;
plus.FlatStyle = FlatStyle.Flat;
plus.Name = "plus";
plus.Size = Size[0][9];
plus.UseVisualStyleBackColor = false;
plus.Name = plus.Name + i.ToString() + "_" + j.ToString();
plus.Click += new EventHandler(plusButton_click);
plus.VisibleChanged += new EventHandler(classUniqueButtons_VisibleChanged);
plus.MouseEnter += new EventHandler(this.classButton_MouseEnter);
plus.MouseLeave += new EventHandler(this.classButton_MouseLeave);
classBackround.Controls.Add(plus);
classBackround.Controls.Add(points);
}
}
}
private void plusButton_click(object sender, EventArgs e)
{
var currentButton = sender as Button;
var name = currentButton.Name;
switch (name)
{
// Ultimate
case "plus0_0":
// If i clicked on this button so i need change text for first added label
// I try this, but it changed only last added labe
points.Text = "test";
break;
case "plus0_1":
// If i clicked on this button so i need change text for second added label
break;
}
}
private void minusButton_click(object sender, EventArgs e)
{
var currentButton = sender as Button;
var name = currentButton.Name;
switch (name)
{
// Ultimate
case "minus0_0":
// If i clicked on this button so i need change text for first added label
// I try this, but it changed only last added labe
points.Text = "test";
break;
case "minus0_1":
// If i clicked on this button so i need change text for second added label
break;
}
}
}
【问题讨论】:
-
什么是咒语?它包含什么?