public Form1() { InitializeComponent(); panelGrid = new PicrossGrid[10, 10]; gridCountsY = new Label[10, 5]; gridCountsX = new Label[5, 10]; for (int i = 0; i < 10; i++) { for (int j = 0; j < 10; j++) { panelGrid[i, j] = new PicrossGrid(); // this loop creates and sets the positions of the panels in the editor panelGrid[i, j].panel.Parent = gameEditor; panelGrid[i, j].panel.Name = i.ToString() + " " + j.ToString(); int posX = (j * 16) + 60; int posY = (i * 16) + 60; panelGrid[i, j].panel.Location = new Point(posX, posY); panelGrid[i, j].panel.Size = new Size(15, 15); panelGrid[i, j].panel.BorderStyle = BorderStyle.FixedSingle; panelGrid[i, j].itX = j; panelGrid[i, j].itY = i; panelGrid[i, j].panel.BringToFront(); panelGrid[i, j].panel.Click += Panel_Click; panelGrid[i, j].panel.MouseMove += panel_MouseMove; //panelGrid[i, j].panel.MouseLeave += panel_MouseLeave; panelGrid[i, j].panel.MouseDown += delegate(object sender, MouseEventArgs e) { gameEditor_MouseDown(sender, e); }; panelGrid[i, j].panel.MouseUp += delegate(object sender, MouseEventArgs e) { gameEditor_MouseUp(sender, e); }; } for (int j = 0; j < 5; j++) { gridCountsY[i, j] = new Label(); // this loop creates the numbers used to count up the gridCountsY[i, j].Parent = gameEditor; gridCountsY[i, j].Text = "0"; int posY = (j * 12); int posX = (i * 16) + 57; gridCountsY[i, j].Location = new Point(posX, posY); gridCountsY[i, j].Width = 20; gridCountsY[i, j].Height = 12; gridCountsX[j, i] = new Label(); gridCountsX[j, i].Parent = gameEditor; gridCountsX[j, i].Text = "0"; posY = (i * 16) + 61; posX = (j * 10); gridCountsX[j, i].Location = new Point(posX, posY); gridCountsX[j, i].Width = 19; gridCountsX[j, i].Height = 12; gridCountsY[i, j].TextAlign = ContentAlignment.MiddleRight; gridCountsX[j, i].BringToFront(); gridCountsY[i, j].BringToFront(); } } for (int i = 0; i < 10; i++) { ClearColCount(i); ClearRowCount(i); } }
public TestPlay(PicrossGrid[,] grid, Label[,] xLabels, Label[,] yLabels, Form1 origin) { InitializeComponent(); original = origin; Location = original.Location; original.Hide(); otherGrid = grid; picrossGrid = new PicrossGrid[10, 10]; gridCountsX = new Label[5, 10]; gridCountsY = new Label[10, 5]; for (int i = 0; i < 10; i++) { for (int j = 0; j < 10; j++) { picrossGrid[i, j] = new PicrossGrid(); //picrossGrid[i, j].panel = new Panel(); picrossGrid[i, j].panel.Parent = this; int posX = (j * 16) + 80; int posY = (i * 16) + 60; picrossGrid[i, j].panel.Location = new Point(posX, posY); picrossGrid[i, j].panel.Size = new Size(15, 15); picrossGrid[i, j].panel.BorderStyle = BorderStyle.FixedSingle; crossed[i, j] = new Label(); crossed[i, j].Text = "x"; crossed[i, j].Parent = picrossGrid[i, j].panel; crossed[i, j].Visible = false; crossed[i, j].Click += Label_Click; picrossGrid[i, j].panel.Click += Panel_Click; picrossGrid[i, j].panel.MouseMove += panel_MouseMove; //panelGrid[i, j].panel.MouseLeave += panel_MouseLeave; picrossGrid[i, j].panel.MouseDown += delegate(object sender, MouseEventArgs e) { gameEditor_MouseDown(sender, e); }; picrossGrid[i, j].panel.MouseUp += delegate(object sender, MouseEventArgs e) { gameEditor_MouseUp(sender, e); }; } for (int j = 0; j < 5; j++) { gridCountsX[j, i] = new Label(); gridCountsX[j, i].Parent = this; int posY = (i * 16) + 61; int posX = (j * 15); gridCountsX[j, i].Location = new Point(posX, posY); gridCountsX[j, i].Width = 19; gridCountsX[j, i].Height = 12; gridCountsX[j, i].Text = xLabels[j, i].Text; gridCountsX[j, i].Visible = xLabels[j, i].Visible; if (gridCountsX[j, i].Text != "0") { gridCountsX[j, i].Visible = true; } gridCountsY[i, j] = new Label(); gridCountsY[i, j].Parent = this; posY = (j * 12); posX = (i * 16) + 77; gridCountsY[i, j].Location = new Point(posX, posY); gridCountsY[i, j].Width = 20; gridCountsY[i, j].Height = 12; gridCountsY[i, j].Text = yLabels[i, j].Text; gridCountsY[i, j].Visible = yLabels[i, j].Visible; if (gridCountsY[i, j].Text != "0") { gridCountsY[i, j].Visible = true; } } } }