为什么当前上下文中不存在名称pictureBox1?
做一个图片编辑器,内容是选择图片,水平翻转,垂直翻转,但是显是当前上下文中不存在openFileDialog、pictureBox1加了//OpenFileDialog openFileDialogl = new OpenFileDialog();
//pictureBox pictureBox1=new pictureBox();
仍然不能用。
问题在哪?
代码
private void button1_Click(object sender, EventArgs e)
{
//OpenFileDialog openFileDialogl = new OpenFileDialog();
//pictureBox pictureBox1=new pictureBox();
openFileDialog.Filter ="*.jpg,*.jpeg,*.bmp,*.gif,*.ico,*.png,*.tif,*.wmf|*.jpg;*.jpeg;*.bmp;*.gif;*.ico;*.png;*.tif;*.wmf";
if(openFileDialog,ShowDialog()==DialogResult.OK);
{
Image myImage=System.Drawing.Image.FromFile (openFileDialog1.FileName);
pictureBox1.Image=myImage ;
pictureBox1.Height=myImage .Height ;
pictureBox1.Width=myImage .Width ;
}
}
//垂直翻转
private void button2_Click(object sender, EventArgs e)
{
Image myImage = pictureBox1.Image;
myImage.RotateFlip(RotateFlipType.Rotate180FlipNone);
pictureBox1.iMAGE = myImage;
}
//水平翻转
private void button1_Click_1(object sender, EventArgs e)
{
Image myImage = pictureBox1.Image;
myImage .RotateFlip(RotateFlipType.Rotate90FlipNone)//水平翻转
pictureBox1.Image=myImage ;
}