Beispiel #1
0
 private void btnScreen_Click(object sender, EventArgs e)
 {
     try
     {
         Rectangle rectangle = Screen.PrimaryScreen.Bounds;
         rectangle.Width  = 1920;
         rectangle.Height = 1080;
         Image image = new Bitmap(rectangle.Width, rectangle.Height);
         using (Graphics graphics = Graphics.FromImage(image))
         {
             graphics.CopyFromScreen(0, 0, 0, 0, rectangle.Size);
         }
         using (ScreenForm screenForm = new ScreenForm(image))
         {
             screenForm.ShowDialog();
             if (screenForm.bSucceed == true)
             {
                 this.txtQRCodeText.Text = QRCodeCommon.ImageToText(Clipboard.GetImage());
             }
         }
     }
     catch (Exception ee)
     {
         MessageBox.Show(ee.Message, "错误");
     }
 }
Beispiel #2
0
 private void txtPicturePath_TextChanged(object sender, EventArgs e)
 {
     try
     {
         string path = this.txtPicturePath.Text.Trim();
         if (path == "")
         {
             return;
         }
         if (File.Exists(path))
         {
             using (Stream stream = File.Open(path, FileMode.Open))
             {
                 if (stream.Length == 0)
                 {
                     return;
                 }
                 this.picboxQRCodePicture.Image = Image.FromStream(stream);
             }
             this.txtQRCodeText.Text = QRCodeCommon.ImageToText(this.picboxQRCodePicture.Image);
         }
         else
         {
             this.picboxQRCodePicture.Image = this.picboxQRCodePicture.ErrorImage;
             this.txtQRCodeText.Text        = "";
         }
     }
     catch (Exception ee)
     {
         MessageBox.Show(ee.Message, "错误");
     }
 }