Okay, my MindMasterColourForm class looks like this:
public partial class MindMasterColourForm : Form
{
UserControlGame ucg;
public MindMasterColourForm(UserControlGame ucgParam)
{
InitializeComponent();
ucg = ucgParam;
}
private void MindMasterColourForm_Load(object sender, EventArgs e)
{
}
private void button1_Click(object sender, EventArgs e)
{
ucg.SlotForm[1].FillColor = System.Drawing.Color.Red;
}
}
And more or less I understand what it does (maybe not in exact terms):UserControlGame ucg; will declare UserControlGame within this form. And then it will initialize the form with an parameter that will be defined in the UserControlGame class as MindMasterColourForm ColourForm = new MindMasterColourForm(this);; Unfortunately there we have the first problem. Visual Studio says that the keyword this can not be used in the context. (My VS2008 is in French, and the full error description is "Le mot clé 'this' n'est pas disponible dans le contexte actuel.")
Then I tried to use the public get set code snippet:
public Microsoft.VisualBasic.PowerPacks.OvalShape[] SlotForm
{
get
{
return myovalshape;
}
set
{
myovalshape = value;
}
}
But then VS2008 states two errata.
First, there is an ambiguity as I have definedMindMasterGUI.UserControlGame.SlotForm twice. And myovalshape doesn't exist in this context, as it has never been declared/created.
Btw, I tried several different forms, even though they did seem wrong all along:
public Microsoft.VisualBasic.PowerPacks.OvalShape[] SlotForm[]
public Microsoft.VisualBasic.PowerPacks.OvalShape SlotForm
public Microsoft.VisualBasic.PowerPacks.OvalShape SlotForm[]
and SlotForm, SlotForm[] and SlotForm[0] instead of myovalshape.
Useless to say that neither worked.
So, how can I join the two declaration of the SlotForm?
And what would be myovershape?
public partial class UserControlGame : UserControl
{
public UserControlGame()
{
InitializeComponent();
for (int i = 0; i < GlobalVariables.configsetup[0]; i++)
{
SlotField[i] = new System.Windows.Forms.Panel();
SlotContainer[i] = new Microsoft.VisualBasic.PowerPacks.ShapeContainer();
<strong>SlotForm</strong>[i] = new Microsoft.VisualBasic.PowerPacks.OvalShape();
flowLayoutPanel1.Controls.Add(SlotField[i]);
SlotField[i].Controls.Add(SlotContainer[i]);
SlotField[i].Margin = new System.Windows.Forms.Padding(5);
SlotField[i].Name = "SlotField" + (i + 1).ToString();
SlotField[i].Size = new System.Drawing.Size(50, 50);
SlotField[i].TabIndex = 0;
SlotField[i].TabStop = false;
SlotContainer[i].Location = new System.Drawing.Point(0, 0);
SlotContainer[i].Margin = new System.Windows.Forms.Padding(0);
SlotContainer[i].Name = "SlotContainer" + (i + 1).ToString();
SlotContainer[i].Shapes.AddRange(new Microsoft.VisualBasic.PowerPacks.Shape[] { SlotForm[i] });
SlotContainer[i].Size = new System.Drawing.Size(50, 50);
SlotContainer[i].TabIndex = 0;
SlotContainer[i].TabStop = false;
SlotForm[i].BorderColor = System.Drawing.Color.Black;
SlotForm[i].BorderWidth = 7;
SlotForm[i].Enabled = false;
SlotForm[i].FillColor = System.Drawing.Color.FromArgb(((int)(((byte)(40)))), ((int)(((byte)(40)))), ((int)(((byte)(40)))));
SlotForm[i].FillStyle = Microsoft.VisualBasic.PowerPacks.FillStyle.Solid;
SlotForm[i].Location = new System.Drawing.Point(5, 5);
SlotForm[i].Name = "SlotForm" + (i + 1).ToString();
SlotForm[i].Size = new System.Drawing.Size(33, 33);
}
}
MindMasterColourForm ColourForm = new MindMasterColourForm(<strong>this</strong>);
System.Windows.Forms.Panel[] SlotField = new System.Windows.Forms.Panel[GlobalVariables.configsetup[0]];
Microsoft.VisualBasic.PowerPacks.ShapeContainer[] SlotContainer = new Microsoft.VisualBasic.PowerPacks.ShapeContainer[GlobalVariables.configsetup[0]];
Microsoft.VisualBasic.PowerPacks.OvalShape[] SlotForm = new Microsoft.VisualBasic.PowerPacks.OvalShape[GlobalVariables.configsetup[0]];
public Microsoft.VisualBasic.PowerPacks.OvalShape[] SlotForm
{
get
{
return <strong>myovalshape</strong>;
}
set
{
<strong>myovalshape</strong> = value;
}
}
private void buttonSetUp_Click(object sender, EventArgs e)
{
Hide();
BasicFunctions.setuppage();
}
private void buttonQuit_Click(object sender, EventArgs e)
{
Hide();
ColourForm.Close();
BasicFunctions.startpage();
}
private void UserControlGame_Load(object sender, EventArgs e)
{
ColourForm.Location = new Point(this.Parent.Location.X + 521, this.Parent.Location.Y + 383);
ColourForm.Show();
}
}
P.S. I have put every bit of code marked with an error by VS2008 in red.
And finally I tried one change:
public Microsoft.VisualBasic.PowerPacks.OvalShape[] SlotForm = new Microsoft.VisualBasic.PowerPacks.OvalShape[GlobalVariables.configsetup[0]];
And no public/get/set declaration. The only error that remains is thethis in MindMasterColourForm ColourForm = new MindMasterColourForm(this); - so I can even try debugging the code.