예제 #1
0
 private void CutPic_KeyDown(object sender, KeyEventArgs e)
 {
     ///按Esc后取消截图
     if (e.KeyCode == Keys.Escape)
     {
         this.Close();
         NormalMain?.Invoke();
     }
 }
예제 #2
0
        private void CutPic_MouseDoubleClick(object sender, MouseEventArgs e)
        {
            //开始截图

            //设置窗体的透明度为0
            this.Opacity = 0;
            //构造图片
            Bitmap   bit = new Bitmap(this.Width, this.Height);
            Graphics g   = Graphics.FromImage(bit);

            //截取背景图
            g.CopyFromScreen(this.Location, new Point(0, 0), bit.Size);
            SaveFileDialog save = new SaveFileDialog();

            //打开保存
            save.ShowDialog();
            bit.Save(save.FileName + ".bmp", System.Drawing.Imaging.ImageFormat.Bmp);

            //截完图后,激活主窗体
            NormalMain?.Invoke();
            //关闭截图窗体
            this.Close();
        }