Untitled

 avatar
unknown
csharp
2 years ago
801 B
2
Indexable
public void ExecuteFunctions(Button btn)
{
    if(btn.BackColor == Color.Silver)
    {
        btn.BackColor = Color.LightGreen;
        this.frm.Counter++;
    }
    else
    {
        btn.BackColor = Color.Silver;
        this.frm.Counter--;
    }

    ValidateActivateAbilities(btn);
}

private void ValidateActivateAbilities(Button btn)
{
    this.frm.lblHealth.Text = this.frm.Counter.ToString();
    if (frm.Counter >= 4)
    {
        if (btn.BackColor != Color.LightGreen)
            btn.Enabled = false;

    }
    else
    {
        foreach (var ActiveButtons in frm.panelPreparationMenu.Controls.OfType<Button>())
        {
            ActiveButtons.Enabled = true;
        }
    }
}

// inves de
new Form2().skillButton5();

// chamas isto
new Form2().ExecuteFunctions(this.skillButton5);
Editor is loading...