Ejemplo n.º 1
0
        /// <summary>
        /// »ñÈ¡¶þάÂë×Ö·û´®
        /// </summary>
        /// <returns></returns>
        public string GetQRCodeString(Bitmap bmap)
        {
            if (bmap == null)
            {
                return(null);
            }

            string retString = null;

            try
            {
                Result results = _qrRead.Decode(bmap);
                if (results != null)
                {
                    retString = DeEncryString(results.Text);
                }
            }
            catch (Exception ex)
            {
                FrmQRResault.ShowError("½âÃÜ´íÎó£¬Çë¼ì²éÃÜÂëÊÇ·ñÕýÈ·");
                //MessageBox.Show(ex.Message, "´íÎó", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return(null);
            }

            return(retString);
        }
Ejemplo n.º 2
0
 void _formHotKey_OnHotKeyPress(Message msg)
 {
     if (!_isSys)
     {
         try
         {
             using (Bitmap bmap = _sc.CaptureActive() as Bitmap)
             {
                 if (bmap == null)
                 {
                     return;
                 }
                 string str = _qrcode.GetQRCodeString(bmap);
                 if (!string.IsNullOrEmpty(str))
                 {
                     FrmQRResault.ShowBox(str);
                 }
             }
         }
         catch (Exception ex)
         {
             ShowMessage(ex.Message, "错误", ToolTipIcon.Error, 3);
         }
     }
 }
Ejemplo n.º 3
0
        /// <summary>
        /// 显示结果框
        /// </summary>
        /// <param name="content"></param>
        public static void ShowError(string content)
        {
            FrmQRResault frm = Current;

            frm.Text                 = "解析二维码错误";
            frm.txtContent.Text      = content;
            frm.txtContent.ForeColor = Color.Red;
            ShowForm(frm);
        }
Ejemplo n.º 4
0
        /// <summary>
        /// 显示结果框
        /// </summary>
        /// <param name="content"></param>
        public static void ShowBox(string content)
        {
            FrmQRResault frm = Current;

            frm.Text                 = "二维码信息";
            frm.txtContent.Text      = content;
            frm.txtContent.ForeColor = Color.Black;
            ShowForm(frm);
        }
Ejemplo n.º 5
0
        /// <summary>
        /// 读取QR
        /// </summary>
        /// <param name="bmap"></param>
        private void ReadQR(Bitmap bmap)
        {
            string str = _qrcode.GetQRCodeString(bmap);

            if (!string.IsNullOrEmpty(str))
            {
                FrmQRResault.ShowBox(str);
            }
        }
Ejemplo n.º 6
0
        private void ReadBase64(string base64)
        {
            string str = _base64Unit.GetBaseString(base64);

            if (!string.IsNullOrEmpty(str))
            {
                FrmQRResault.ShowBox(str);
            }
        }
Ejemplo n.º 7
0
 void _listener_OnClipboardWrite(Message msg)
 {
     if (!_isSys)
     {
         string str = _qrcode.GetQRCodeString();
         if (!string.IsNullOrEmpty(str))
         {
             FrmQRResault.ShowBox(str);
         }
     }
 }
Ejemplo n.º 8
0
        /// <summary>
        /// ÏÔʾ½á¹û¿ò
        /// </summary>
        /// <param name="content"></param>
        public static void ShowBox(string content)
        {
            FrmQRResault frm = new FrmQRResault();

            frm.txtContent.Text = content;

            frm.Show();
            //Rectangle curRec=Screen.GetBounds(frm);
            int x = Cursor.Position.X - (frm.Width / 2);
            int y = Cursor.Position.Y;

            frm.Location = new Point(x, y);
            frm.TopMost  = true;
            frm.TopMost  = false;
        }
Ejemplo n.º 9
0
        private static void ShowForm(FrmQRResault frm)
        {
            frm.Show();
            Point  p         = Cursor.Position;
            Screen curScreen = Screen.FromPoint(p);
            //Rectangle curRec=Screen.GetBounds(frm);

            int maxWidth = curScreen.Bounds.X + curScreen.Bounds.Width - frm.Width;
            int x        = p.X - (frm.Width / 2);

            if (x > maxWidth)
            {
                x = maxWidth;
            }
            else if (x < curScreen.Bounds.X)
            {
                x = curScreen.Bounds.X;
            }

            int y         = p.Y - 50;
            int maxHeight = curScreen.Bounds.Y + curScreen.Bounds.Height - frm.Height;

            if (y > maxHeight)
            {
                y = p.Y - frm.Height + 50;
                if (y > maxHeight)
                {
                    y = maxHeight;
                }
            }
            else if (y < curScreen.Bounds.Y)
            {
                y = curScreen.Bounds.Y;
            }

            frm.Location = new Point(x, y);
            frm.TopMost  = true;
            //frm.TopMost = false;
        }
Ejemplo n.º 10
0
        /// <summary>
        /// 把字符串打成Base64字符串
        /// </summary>
        /// <returns></returns>
        public string ToBaseString(string str, bool isEncry)
        {
            string retString = null;

            try
            {
                byte[] resByte = QRCodeUnit.DefaultEncode.GetBytes(str);
                if (isEncry)
                {
                    ConfigSave config = Program.MainForm.Config;
                    byte[]     pwd    = config.EncryPassword;
                    resByte = PasswordHash.AESEncrypt(resByte, pwd);
                    return(QRCodeUnit.EncryHead + Convert.ToBase64String(resByte));
                }
                return(Convert.ToBase64String(resByte));
            }
            catch (Exception ex)
            {
                FrmQRResault.ShowError("解密错误,请检查密码是否正确");
                return(null);
            }

            return(retString);
        }
Ejemplo n.º 11
0
        /// <summary>
        /// 获取Base64字符串
        /// </summary>
        /// <returns></returns>
        public string GetBaseString(string str)
        {
            string retString = null;

            if (string.IsNullOrWhiteSpace(str))
            {
                return(null);
            }
            str = str.Trim();
            bool isEncry = false;

            if (str.StartsWith(QRCodeUnit.EncryHead))
            {
                str     = str.Substring(QRCodeUnit.EncryHead.Length);
                isEncry = true;
            }
            try
            {
                byte[] resByte = Convert.FromBase64String(str);

                if (isEncry)
                {
                    ConfigSave config = Program.MainForm.Config;
                    byte[]     pwd    = config.EncryPassword;
                    resByte = PasswordHash.AESDecrypt(resByte, pwd);
                }
                retString = QRCodeUnit.DefaultEncode.GetString(resByte);
            }
            catch (Exception ex)
            {
                FrmQRResault.ShowError("解析错误,请检查字符串或密码是否正确");
                return(null);
            }

            return(retString);
        }