public Form1() { InitializeComponent(); this.pnSourcePicture.AutoScroll = true; this.pbSourcePicture.SizeMode = PictureBoxSizeMode.AutoSize; this.pnTileMapPic.AutoScroll = true; this.pbTileMapPic.SizeMode = PictureBoxSizeMode.AutoSize; this.progressbarCreateTile.Visible = true; this.progressbarCreateTile.Minimum = 0; this.progressbarCreateTile.Value = 0; this.progressbarCreateTile.Step = 1; _TileMap = null; }
private void button1_Click(object sender, EventArgs e) { OpenFileDialog openFileDialogSourcePicture = new OpenFileDialog(); openFileDialogSourcePicture.Filter = "PNG (*.png)|*.png| BMP (*.bmp)|*.bmp| All File (*.*)|*.*"; openFileDialogSourcePicture.FilterIndex = 3; openFileDialogSourcePicture.RestoreDirectory = true; if (openFileDialogSourcePicture.ShowDialog() == DialogResult.OK) { CTile.CountID = 0; this.progressbarCreateTile.Value = 0; Reset(); this.tbPathPicture.Text = openFileDialogSourcePicture.FileName; if (new Bitmap(this.tbPathPicture.Text).Width % 64 != 0 || new Bitmap(this.tbPathPicture.Text).Height % 64 != 0) { MessageBox.Show("Error!!!"); return; } if (new Bitmap(this.tbPathPicture.Text).Width >= 32 && new Bitmap(this.tbPathPicture.Text).Height >= 32) { this.pbSourcePicture.Image = new Bitmap(this.tbPathPicture.Text); _TileMap = new CMap(new Bitmap(this.tbPathPicture.Text)); } else { _TileMap = null; pbSourcePicture.Image = null; CTile.CountID = 0; this.progressbarCreateTile.Value = 0; Reset(); this.tbPathPicture.Text = ""; MessageBox.Show("Size of WidthMap >= 32 & HeighMap >= 32"); } } }