} // Реализация создания вершин и рёбер private void linkLabel1_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e) { for (int i = 0; i < countVer; i++) { Controls.Remove(label[i]); } countVer = 0; countLine = 0; Pen pn = new Pen(Color.White, 2); Pen pnW = new Pen(Color.FromArgb(255, 229, 229, 229), 1); Graphics g = CreateGraphics(); SolidBrush br = new SolidBrush(Color.White); g.FillRectangle(br, 23, 23, 595, 555); g.DrawRectangle(pnW, labelEndString.Location.X - 1, labelEndString.Location.Y - 1, labelEndString.Width + 1, labelEndString.Height + 1); g.DrawRectangle(pnW, labelStepString.Location.X - 1, labelStepString.Location.Y - 1, labelStepString.Width + 1, labelStepString.Height + 1); labelEndString.Text = ""; labelStep.Text = ""; labelStepString.Text = ""; textBox2.Text = ""; textBox4.Text = ""; label6.Text = ""; q.Clear(); ender.Clear(); for (int i = 0; i < level.Length; i++) { level[i] = ""; } button5.Visible = false; button4.Visible = true; button6.Visible = false; button6.Text = "Стоп"; button7.Visible = false; button8.Visible = false; }
private void RemoveObstacle(PictureBox p) { Controls.Remove(p); p.Dispose(); }
// Generates a table for a turmite according to numbers of colors and states. protected void GenerateTableControls() { //clearing previously generated controls foreach (var item in generatedLabels) { Controls.Remove(item); } generatedLabels.Clear(); if (stateTable != null) { foreach (var item in stateTable) { Controls.Remove(item); } } if (colorTable != null) { foreach (var item in colorTable) { Controls.Remove(item); } } if (stepTable != null) { foreach (var item in stepTable) { Controls.Remove(item); } } if (turnTable != null) { foreach (var item in turnTable) { Controls.Remove(item); } } int states = (int)stateCounter.Value; int colors = (int)colorCounter.Value; stateTable = new NumericUpDown[states, colors]; colorTable = new NumericUpDown[states, colors]; stepTable = new NumericUpDown[states, colors]; turnTable = new ComboBox[states, colors]; // for each situation (state-color combination) the turmite can encounter... for (int state = 0; state < states; state++) { for (int color = 0; color < colors; color++) { // a set of two labels representing given situation // a label for current state Label label = new Label { Location = new Point(25, 94 + (state * colors + color) * 26), Name = "label1", Size = new Size(45, 26), TabIndex = 18, Text = state.ToString(), TextAlign = ContentAlignment.MiddleCenter }; Controls.Add(label); generatedLabels.Add(label); // a label for current color label = new Label { Location = new Point(73, 94 + (state * colors + color) * 26), Name = "label2", Size = new Size(45, 26), TabIndex = 19, Text = color.ToString(), TextAlign = ContentAlignment.MiddleCenter }; Controls.Add(label); generatedLabels.Add(label); // a box for the state to be transitioned into stateTable[state, color] = new NumericUpDown { Maximum = states - 1, Location = new System.Drawing.Point(127, 99 + (state * colors + color) * 26), Name = "numericUpDown4", Size = new System.Drawing.Size(72, 21), TabIndex = 15, TextAlign = System.Windows.Forms.HorizontalAlignment.Right }; Controls.Add(stateTable[state, color]); // a box for the color to paint the tile(pixel) colorTable[state, color] = new NumericUpDown { Maximum = colors - 1, Location = new System.Drawing.Point(198, 99 + (state * colors + color) * 26), Name = "numericUpDown3", Size = new System.Drawing.Size(82, 21), TabIndex = 14, TextAlign = System.Windows.Forms.HorizontalAlignment.Right }; Controls.Add(colorTable[state, color]); // a box for amount of steps to take stepTable[state, color] = new NumericUpDown { Location = new System.Drawing.Point(280, 99 + (state * colors + color) * 26), Name = "numericUpDown2", Size = new System.Drawing.Size(65, 21), TabIndex = 13, TextAlign = System.Windows.Forms.HorizontalAlignment.Right }; Controls.Add(stepTable[state, color]); // a box for the eventual tur to make turnTable[state, color] = new ComboBox { DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList, Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(238))), Location = new System.Drawing.Point(345, 98 + (state * colors + color) * 26), Name = "comboBox1", Size = new System.Drawing.Size(62, 21), TabIndex = 17 }; turnTable[state, color].Items.AddRange(new object[] { "Left", "None", "Right" }); // setting default chosen turn to 'None" turnTable[state, color].SelectedIndex = 1; Controls.Add(turnTable[state, color]); } } }
private void timer1_Tick(object sender, EventArgs e) { for (int i = tail_count; i > 0; i--) { foreach (PictureBox item in Controls.OfType <PictureBox>()) { /* * //šablona * if (item.Tag.ToString() == tail_count.ToString()) * { * item.Location = new Point(pictureBox1.Location.X,pictureBox1.Location.Y); * } */ if (item.Tag.ToString() == i.ToString()) { foreach (PictureBox item2 in Controls.OfType <PictureBox>()) { if (item2.Tag.ToString() == (i + 1).ToString()) { item2.Location = new Point(item.Location.X, item.Location.Y); } } } } } if (direction == 0) { if (pictureBox1.Location.X == 0) { pictureBox1.Location = new Point(pictureBox1.Location.X + 400, pictureBox1.Location.Y); } else { pictureBox1.Location = new Point(pictureBox1.Location.X - 25, pictureBox1.Location.Y); } } if (direction == 1) { if (pictureBox1.Location.Y == 400) { pictureBox1.Location = new Point(pictureBox1.Location.X, pictureBox1.Location.Y - 400); } else { pictureBox1.Location = new Point(pictureBox1.Location.X, pictureBox1.Location.Y + 25); } } if (direction == 2) { if (pictureBox1.Location.X == 400) { pictureBox1.Location = new Point(pictureBox1.Location.X - 400, pictureBox1.Location.Y); } else { pictureBox1.Location = new Point(pictureBox1.Location.X + 25, pictureBox1.Location.Y); } } if (direction == 3) { if (pictureBox1.Location.Y == 0) { pictureBox1.Location = new Point(pictureBox1.Location.X, pictureBox1.Location.Y + 400); } else { pictureBox1.Location = new Point(pictureBox1.Location.X, pictureBox1.Location.Y - 25); } } foreach (PictureBox item in Controls.OfType <PictureBox>()) { if (item.Tag != null && item.Tag.ToString() != "food" && item.Tag.ToString() != "1") { if (pictureBox1.Location == item.Location) { timer1.Stop(); MessageBox.Show("You Lost! Score " + tail_count + "!"); Application.Exit(); } } } foreach (PictureBox item in Controls.OfType <PictureBox>()) { if (item.Tag == "food") { if (item.Location == pictureBox1.Location) { add_tail(item.Location.X, item.Location.Y); Controls.Remove(item); spawn(); } } } can_use_keys = true; }