private void GenQr(string text) { if (PictureQrCode.Visibility != Visibility.Visible) { return; } try { var h = Convert.ToInt32(MainGrid.ActualHeight); var w = Convert.ToInt32(MainGrid.ColumnDefinitions[2].ActualWidth - PictureQrCode.Margin.Left - PictureQrCode.Margin.Right); if (h <= 0 || w <= 0) { PictureQrCode.Source = null; } else { PictureQrCode.Source = text != string.Empty ? QrCodeUtils.GenQrCode(text, w, h) : QrCodeUtils.GenQrCode2(text, Math.Min(w, h)); } } catch { PictureQrCode.Source = null; } }
private void GenQr(string text) { try { var h = Convert.ToInt32(Grid1.RowDefinitions[1].ActualHeight); var w = Convert.ToInt32(Grid1.ActualWidth); PictureQrCode.Source = text != string.Empty ? QrCodeUtils.GenQrCode(text, w, h) : QrCodeUtils.GenQrCode2(text, Math.Min(w, h)); } catch { PictureQrCode.Source = null; } }
private void GenQr(string text) { try { var h = Convert.ToInt32(MainGrid.ActualHeight); var w = Convert.ToInt32(MainGrid.ColumnDefinitions[2].ActualWidth - PictureQrCode.Margin.Left - PictureQrCode.Margin.Right); PictureQrCode.Source = text != string.Empty ? QrCodeUtils.GenQrCode(text, w, h) : QrCodeUtils.GenQrCode2(text, Math.Min(w, h)); } catch { PictureQrCode.Source = null; } }
public string AnalysisCodeImage() { if (HttpContext.Request.Form.Files.Count <= 0) { return("没有选择文件"); } var imgFile = HttpContext.Request.Form.Files[0]; try { Image imagePic = Image.FromStream(imgFile.OpenReadStream()); return(QrCodeUtils.AnalysisCodeImage(imagePic)); } catch (Exception) { return("识别失败,请重新调整"); } }
public void Page_Load(object sender, EventArgs e) { _siteId = Convert.ToInt32(Request.QueryString["siteId"]); if (!Main.Instance.AdminApi.IsSiteAuthorized(_siteId)) { Response.Write("<h1>未授权访问</h1>"); Response.End(); return; } if (IsPostBack) { return; } var paymentApi = new PaymentApi(_siteId); if (!string.IsNullOrEmpty(Request.QueryString["alipayPc"])) { LtlScript.Text = paymentApi.ChargeByAlipayPc("测试", 0.01M, Utils.GetShortGuid(), "https://www.alipay.com"); } else if (!string.IsNullOrEmpty(Request.QueryString["alipayMobi"])) { LtlScript.Text = paymentApi.ChargeByAlipayMobi("测试", 0.01M, Utils.GetShortGuid(), "https://www.alipay.com"); } else if (!string.IsNullOrEmpty(Request.QueryString["weixin"])) { try { var url = HttpUtility.UrlEncode(paymentApi.ChargeByWeixin("测试", 0.01M, Utils.GetShortGuid(), "https://pay.weixin.qq.com")); LtlScript.Text = $@"<div style=""display: none""><img id=""weixin_test"" src=""{GetRedirectUrl(_siteId)}&qrcode={url}"" width=""200"" height=""200"" /></div><script>{Utils.SwalDom(Page, "微信支付测试", "weixin_test")}</script>"; } catch (Exception ex) { LtlScript.Text = $"<script>{Utils.SwalError(Page, "测试报错", ex.Message)}</script>"; } } else if (!string.IsNullOrEmpty(Request.QueryString["qrcode"])) { Response.BinaryWrite(QrCodeUtils.GetBuffer(Request.QueryString["qrcode"])); Response.End(); } else if (!string.IsNullOrEmpty(Request.QueryString["jdpay"])) { LtlScript.Text = paymentApi.ChargeByJdpay("测试", 0.01M, Utils.GetShortGuid(), "https://www.jdpay.com"); } var configInfo = Main.Instance.GetConfigInfo(_siteId); LtlAlipayPc.Text = configInfo.IsAlipayPc ? $@" <span class=""label label-primary"">已开通</span> <a class=""m-l-10"" href=""{GetRedirectUrl(_siteId)}&alipayPc=true"">测试</a>" : "未开通"; LtlAlipayMobi.Text = configInfo.IsAlipayMobi ? $@" <span class=""label label-primary"">已开通</span> <a class=""m-l-10"" href=""{GetRedirectUrl(_siteId)}&alipayMobi=true"">测试</a>" : "未开通"; LtlWeixin.Text = configInfo.IsWeixin ? $@" <span class=""label label-primary"">已开通</span> <a class=""m-l-10"" href=""{GetRedirectUrl(_siteId)}&weixin=true"">测试</a>" : "未开通"; LtlJdpay.Text = configInfo.IsJdpay ? $@" <span class=""label label-primary"">已开通</span> <a class=""m-l-10"" href=""{GetRedirectUrl(_siteId)}&jdpay=true"">测试</a>" : "未开通"; }