Пример #1
0
        private void pictureBox1_Paint(object sender, PaintEventArgs e)//可以删掉第一个刷新方法合并两种方法
        {
            try
            {
                //清屏
                e.Graphics.Clear(Color.White);

                //重绘
                switch (MyGlo.update_function)
                {
                case 0:    //全图显示刷新
                    Funcs.Update(e.Graphics, this.pictureBox1.Width, this.pictureBox1.Height);
                    Funcs.MouseClear();
                    break;

                case 1:    //移动刷新
                    Funcs.Update(e.Graphics, this.pictureBox1.Width, this.pictureBox1.Height, 1);
                    break;
                }

                //默认全图显示刷新
                MyGlo.update_function = 0;
            }
            catch
            {
                MessageBox.Show("绘制图像时出错");
            }
        }
Пример #2
0
        private void exportImageToolStripMenuItem_Click(object sender, EventArgs e)
        {//导出
            try
            {
                SaveFileDialog saveImageDialog = new SaveFileDialog();
                saveImageDialog.Title  = "Export image";
                saveImageDialog.Filter = @"jpeg|*.jpg|bmp|*.bmp";
                if (saveImageDialog.ShowDialog() == DialogResult.OK)
                {
                    string fileName = saveImageDialog.FileName.ToString();
                    if (fileName != "" && fileName != null)
                    {
                        string fileExtName = fileName.Substring(fileName.LastIndexOf(".") + 1).ToString();
                        System.Drawing.Imaging.ImageFormat imgformat = null;


                        if (fileExtName != "")
                        {
                            switch (fileExtName)
                            {
                            case "jpg":
                                imgformat = System.Drawing.Imaging.ImageFormat.Jpeg;
                                break;

                            case "bmp":
                                imgformat = System.Drawing.Imaging.ImageFormat.Bmp;
                                break;

                            default:
                                imgformat = System.Drawing.Imaging.ImageFormat.Jpeg;
                                break;
                            }
                            Bitmap   bmp = new Bitmap(this.pictureBox1.Width, this.pictureBox1.Height);
                            Graphics g   = Graphics.FromImage(bmp);
                            g.Clear(Color.White);
                            Funcs.Update(g, this.pictureBox1.Width, this.pictureBox1.Height);
                            this.pictureBox1.Image = bmp;
                            bmp.Save(fileName, imgformat);                                                   //保存
                            MessageBox.Show("Save successfully !                             ", "Reminder"); //提示保存成功
                                                                                                             //bmp.Dispose();Bitmap赋值给PictureBox后,误对其进行了Dispose()的操作,在PictureBox Size改变时,重绘时导致异常,出现红叉。
                        }//if
                    }//if
                }//if
            }
            catch
            {
                MessageBox.Show("导出错误");
            }
        }
Пример #3
0
        private void pictureBox1_Paint(object sender, PaintEventArgs e)
        {
            //清屏
            e.Graphics.Clear(Color.White);

            //重绘
            switch (MyGlo.update_function)
            {
            case 0:    //全图显示刷新
                Funcs.Update(e.Graphics, this.pictureBox1.Width, this.pictureBox1.Height);
                Funcs.MouseClear();
                break;

            case 1:    //移动刷新
                Funcs.Update(e.Graphics, this.pictureBox1.Width, this.pictureBox1.Height, 1);
                break;
            }

            //默认全图显示刷新
            MyGlo.update_function = 0;
        }