Example #1
0
        private void ShowSaveFileDialog()
        {
            //设置文件类型
            string         filter   = "PNG(*.png)|*.png|JPEG(*.jpg)|*.jpg|BMP(*.bmp)|*.bmp|Gif(*.gif)|*.gif|TIFF(*.tiff)|*.tiff|EXIF(*.exif)|*.exif";
            string         fileName = "screenshot" + DateTime.Now.ToString("yyyyMMddHHmmss") + ".png";
            SaveFileDialog sfd      = DialogKit.GetSaveFileDialog(fileName, filter);

            if (sfd != null)
            {
                string      localFilePath = sfd.FileName.ToString();         //获得文件路径
                string      fileNameExt   = Path.GetFileName(localFilePath); //获取文件名,不带路径
                int         selectIndex   = sfd.FilterIndex;
                ImageFormat format;
                switch (selectIndex)
                {
                case 1:
                    format = ImageFormat.Png;
                    break;

                case 2:
                    format = ImageFormat.Jpeg;
                    break;

                case 3:
                    format = ImageFormat.Bmp;
                    break;

                case 4:
                    format = ImageFormat.Gif;
                    break;

                case 5:
                    format = ImageFormat.Tiff;
                    break;

                case 6:
                    format = ImageFormat.Exif;
                    break;

                default:
                    format = ImageFormat.Png;
                    break;
                }
                this.pictureBox1.Image.Save(localFilePath, format);
            }
        }
        private void ShowSaveFileDialog()
        {
            string         filter   = "PNG(*.png)|*.png|JPEG(*.jpg)|*.jpg|BMP(*.bmp)|*.bmp|Gif(*.gif)|*.gif|TIFF(*.tiff)|*.tiff|EXIF(*.exif)|*.exif";
            string         fileName = "screenshot" + DateTime.Now.ToString("yyyyMMddHHmmss") + ".png";
            SaveFileDialog dialog   = DialogKit.GetSaveFileDialog(fileName, filter);

            if (dialog != null)
            {
                string      path        = dialog.FileName.ToString();
                int         selectIndex = dialog.FilterIndex;
                ImageFormat format;
                switch (selectIndex)
                {
                case 1:
                    format = ImageFormat.Png;
                    break;

                case 2:
                    format = ImageFormat.Jpeg;
                    break;

                case 3:
                    format = ImageFormat.Bmp;
                    break;

                case 4:
                    format = ImageFormat.Gif;
                    break;

                case 5:
                    format = ImageFormat.Tiff;
                    break;

                case 6:
                    format = ImageFormat.Exif;
                    break;

                default:
                    format = ImageFormat.Png;
                    break;
                }
                this.pictureBoxPreview.Image.Save(path, format);
            }
        }