Ejemplo n.º 1
0
        // make button to click image
        private void imageClick(object sender, EventArgs e)
        {
            pictures select = (pictures)sender;

            if (btnWall.Focused)
            {
                select.Image = wall;
                Save(savePictures, select.Row, select.Col, SaveType(wall));
            }
            if (btnRedBox.Focused)
            {
                select.Image = rb;
                Save(savePictures, select.Row, select.Col, SaveType(rb));
            }
            if (btnRedDoor.Focused)
            {
                select.Image = rd;
                Save(savePictures, select.Row, select.Col, SaveType(rd));
            }
            if (btnGreenBox.Focused)
            {
                select.Image = gb;
                Save(savePictures, select.Row, select.Col, SaveType(gb));
            }
            if (btnGreenDoor.Focused)
            {
                select.Image = gd;
                Save(savePictures, select.Row, select.Col, SaveType(gd));
            }
            if (btnNone.Focused)
            {
                select.Image = none;
                Save(savePictures, select.Row, select.Col, SaveType(none));
            }
        }
Ejemplo n.º 2
0
        // make button to generate
        private void btnGenerate_Click(object sender, EventArgs e)
        {
            if (!number.IsMatch(txtRow.Text) || !number.IsMatch(txtColums.Text))
            {
                MessageBox.Show("rows and colums must be integer");
            }
            else
            {
                row    = int.Parse(txtRow.Text);
                colums = int.Parse(txtColums.Text);
                int x = left;
                int y = top;

                for (int i = 0; i < row; i++)
                {
                    for (int j = 0; j < colums; j++)
                    {
                        picture       = new pictures(i, j);
                        picture.Image = JkimAssignment2.Properties.Resources.None;
                        picture.Left  = x;
                        picture.Top   = y;

                        this.Controls.Add(picture);
                        savePictures.Add(picture);

                        x             += width + hgap;
                        picture.Click += imageClick;
                    }
                    x  = left;
                    y += height + wgap;
                }
            }
        }
Ejemplo n.º 3
0
        // make stripmenu for loading item
        private void loadGameToolStripMenuItem_Click(object sender, EventArgs e)
        {
            loadImage.Clear();
            panelResult.Controls.Clear();
            txtMoves.Text = "0";
            txtBoxes.Text = "0";
            a             = 0;
            OpenFileDialog openFile = new OpenFileDialog();

            if (openFile.ShowDialog() == DialogResult.OK)
            {
                if (Path.GetExtension(openFile.FileName) == ".rtf")
                {
                    txtResult.LoadFile(openFile.FileName, RichTextBoxStreamType.RichText);
                }
                if (Path.GetExtension(openFile.FileName) == ".txt")
                {
                    txtResult.LoadFile(openFile.FileName, RichTextBoxStreamType.PlainText);
                }
                rowWidth  = Convert.ToInt32(txtResult.Lines[0]);
                colHeight = Convert.ToInt32(txtResult.Lines[1]);

                int[,] load = new int[rowWidth, colHeight];
                int[] type  = new int[rowWidth * colHeight];
                int   x     = left;
                int   y     = top;
                int   count = 0;


                for (int i = 0; i < rowWidth * colHeight; i++)
                {
                    type[i] = Convert.ToInt32(txtResult.Lines[4 + (3 * i)]);
                }
                txtResult.Clear();
                for (int i = 0; i < rowWidth; i++)
                {
                    for (int j = 0; j < colHeight; j++)
                    {
                        picture = new pictures(i, j, type[count]);
                        panelResult.Controls.Add(picture);
                        loadImage.Add(picture);
                        count++;

                        picture.Left = x;
                        picture.Top  = y;

                        x             += width + hgap;
                        picture.Click += imageClick;
                    }
                    x  = left;
                    y += height + wgap;
                }
                getType();
                if (getType() != null)
                {
                    txtBoxes.Text = getType().ToString();
                }
            }
        }
Ejemplo n.º 4
0
        //make leftbutton
        private void btnLeft_Click(object sender, EventArgs e)
        {
            if (picture.Type != 4 && picture.Type != 5)
            {
                MessageBox.Show("choose it first");
            }
            else
            {
                int row  = picture.Row;
                int col  = picture.Col;
                int type = picture.Type;
                txtMoves.Text = getNumber().ToString();

                if (type == 4)
                {
                    if (getTile(row, col - 1).Type == 3)
                    {
                        txtMoves.Text = loseNumber().ToString();
                        MessageBox.Show("Cant go left");
                    }
                }
                if (type == 5)
                {
                    if (getTile(row, col - 1).Type == 2)
                    {
                        txtMoves.Text = loseNumber().ToString();
                        MessageBox.Show("Cant go left");
                    }
                }
                if (getTile(row, col - 1).Type == 1 || getTile(row, col - 1).Type == 4 || getTile(row, col - 1).Type == 5)
                {
                    txtMoves.Text = loseNumber().ToString();
                    MessageBox.Show("Cant go left");
                }

                while (getTile(row, col - 1).Type == 0)
                {
                    col--;
                }

                picture.Image = none;
                picture.Type  = 0;

                picture      = getTile(row, col);
                picture.Type = type;
                for (int i = 0; i < 6; i++)
                {
                    if (type == 4)
                    {
                        picture.Image = rb;
                    }
                    if (type == 5)
                    {
                        picture.Image = gb;
                    }
                }
                ;
                if (type == 4)
                {
                    if (getTile(row, col - 1).Type == 2)
                    {
                        picture.Image = none;
                        picture.Type  = 0;
                    }
                }
                if (type == 5)
                {
                    if (getTile(row, col - 1).Type == 3)
                    {
                        picture.Image = none;
                        picture.Type  = 0;
                    }
                }
                int a = 0;
                foreach (var item in loadImage)
                {
                    if (item.Type == 4 || item.Type == 5)
                    {
                        a = 1;
                    }
                }
                if (getType() != null)
                {
                    txtBoxes.Text = getType().ToString();
                }
                if (a == 0)
                {
                    MessageBox.Show("Congrats!");
                    panelResult.Controls.Clear();
                }
            }
        }
Ejemplo n.º 5
0
 //make click method to check image
 private void imageClick(object sender, EventArgs e)
 {
     picture = (pictures)sender;
     SetFocus();
 }