/// <summary>
 /// 工具栏点击了按钮
 /// </summary>
 /// <param name="btnType"></param>
 private void tbf_ToolbarBtnClickEvn(ToolbarBtnEnum btnType)
 {
     if (btnType == ToolbarBtnEnum.Save)
     {
         if (NoticeTaskEvn != null)
         {
             Rectangle rec = new Rectangle(this.PointToScreen(this.panel1.Location), this.panel1.Size);
             NoticeTaskEvn(rec, btnType);
         }
     }
     else if (btnType == ToolbarBtnEnum.OK)
     {
         if (NoticeTaskEvn != null)
         {
             Rectangle rec = new Rectangle(this.PointToScreen(this.panel1.Location), this.panel1.Size);
             NoticeTaskEvn(rec, btnType);
         }
         this.Close();
     }
     else if (btnType == ToolbarBtnEnum.Cancel)
     {
         if (NoticeTaskEvn != null)
         {
             Rectangle rec = default(Rectangle);
             NoticeTaskEvn(rec, btnType);
         }
         this.Close();
     }
 }
Example #2
0
        private void cr_NoticeTaskEvn(Rectangle rec, ToolbarBtnEnum btnType)
        {
            if (btnType == ToolbarBtnEnum.Cancel)
            {
                this.Close();
            }
            else if (btnType == ToolbarBtnEnum.Save)
            {
                SaveFileDialog sfd = new SaveFileDialog();
                sfd.AddExtension = true;
                sfd.DefaultExt   = "bmp";
                sfd.Filter       = "BMP图像|*.bmp|JPG图像|*.jpg|GIF图片|*.gif|PNG图片|*.png|TIFF传真格式|*.tif|所有文件|*.*";
                sfd.FilterIndex  = 0;
                sfd.Title        = "另存为";
                if (sfd.ShowDialog() == DialogResult.OK)
                {
                    string strFileName = sfd.FileName;
                    if (File.Exists(strFileName))
                    {
                        File.Delete(strFileName);
                    }
                    System.Drawing.Imaging.ImageFormat imageFormat = System.Drawing.Imaging.ImageFormat.Bmp;
                    switch (Path.GetExtension(strFileName))
                    {
                    case ".jpg": imageFormat = System.Drawing.Imaging.ImageFormat.Jpeg; break;

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

                    case ".gif": imageFormat = System.Drawing.Imaging.ImageFormat.Tiff; break;

                    case ".png": imageFormat = System.Drawing.Imaging.ImageFormat.Png; break;

                    case ".tif": imageFormat = System.Drawing.Imaging.ImageFormat.Tiff; break;
                    }

                    CropImage(rec).Save(strFileName, imageFormat);
                    MessageBox.Show("保存成功。", "提示");
                }
            }
            else if (btnType == ToolbarBtnEnum.OK)
            {
                ChoiceImage = CropImage(rec);

                this.Close();
            }
        }