private string ExtractBitcoinAddress(BarCodeResult scannedCode) { if (scannedCode.Success == false) { return(string.Empty); } else if (scannedCode.Format != BarCodeFormat.QR_CODE) { return(string.Empty); } else { string code = scannedCode.Code; // first format: bitcoin:15Jph2EW9AqCUWj529VE7byzfWxu3ir2t7 // second format: bitcoin:17xa9wyK6oq9NySL6ejtjyWVrPhPZs6TPu?label=auspex.clevermining.ios // third format: bitcoin:1ALHfhe77VTzogkkBnQkTgH881VHhioczU?amount=0.01&label=auspex.clevermining.winphone&message=awesome if (code.Contains("?")) { // second or third format, strip everything after ? string[] codeParts = code.Split(new string[] { "?" }, StringSplitOptions.RemoveEmptyEntries); if (codeParts.Length > 0) { code = codeParts[0]; } } if (code.StartsWith("bitcoin:")) { // strip the bitcoin tag off code = code.Substring(8); } return(code); } }
void HandleBarCodes(VNRequest request, NSError error) { if (error != null) { _barcodeResult.SetException(new NSErrorException(error)); return; } var observations = request.GetResults <VNBarcodeObservation>(); var result = new VisionBarCodeResult(); result.Success = true; result.Timestamp = DateTime.Now.Ticks; foreach (var o in observations) { if (result.Results == null) { result.Results = new List <BarCodeResult>(); } var res = new BarCodeResult { Text = o.PayloadStringValue, X = o.TopLeft.X, Y = o.TopLeft.Y, Width = o.TopRight.X - o.TopLeft.X, Height = o.BottomLeft.Y - o.TopLeft.Y, }; result.Results.Add(res); Logger.Log($"Found bar code {res.Text} {res.X} {res.Y} {res.Width} {res.Height}"); } _barcodeResult.SetResult(result); }
void OnReadBarcode(BarCodeResult barcodeResult) { if (barcodeResult.Success) { ViewModel.BarcodeResult = barcodeResult.Code; } }
private void BegionProcess() { CopyFile CopyFileD = new CopyFile(SendCardAndCopyDate); IAsyncResult result = CopyFileD.BeginInvoke(BarCodeResult.ToString(), SerialNumber, null, null); progressBar1.Value = 2; new Thread(new ThreadStart(() => { while (!result.IsCompleted) { Thread.Sleep(50); ProgressVa++; this.Dispatcher.Invoke(() => { label2.Content = $"文件总数:1"; progressBar1.Maximum = 500; label3.Content = $"从:" + descfile; label4.Content = $"到:" + comfile; label1.Content = $"正在复制的文件:" + filename; label5.Content = $"当前时间:{ DateTime.Now.ToString(" HH:mm:ss")}"; progressBar1.Value = ProgressVa; if (ProgressVa == 500) { ProgressVa = 0; } }); } if (CopyFileD.EndInvoke(result)) { SendCardB = true; MessageBox.Show("发卡成功!"); } this.Dispatcher.Invoke(() => { this.Close(); }); })).Start(); }
public async Task <IHttpActionResult> Put() { // Check if the request contains multipart/form-data. if (!Request.Content.IsMimeMultipartContent()) { throw new HttpResponseException(HttpStatusCode.UnsupportedMediaType); } var provider = new MultipartFormDataStreamProvider(_appDataPath); var response = new BarCodeResult(); try { await Request.Content.ReadAsMultipartAsync(provider); string newPath = string.Empty; string originalFileName = string.Empty; foreach (MultipartFileData fileData in provider.FileData) { response.Id = CleanupFileName(fileData.Headers.ContentDisposition.FileName); if (string.IsNullOrEmpty(fileData.Headers.ContentDisposition.FileName)) { return(BadRequest("This request is not properly formatted")); } newPath = CreateNewUploadFilePath(fileData.Headers.ContentDisposition.FileName); File.Move(fileData.LocalFileName, newPath); break; } var counter = 0; while (!File.Exists(newPath) && counter < 100000) { counter++; } using (Bitmap barcodeBitmap = (Bitmap)Image.FromFile(newPath)) { var barcodeResult = await _reader.DecodeAsync(barcodeBitmap); if (barcodeResult != null) { response.Value = barcodeResult.Value; response.Format = barcodeResult.Format; } } return(Ok(response)); } catch (Exception e) { return(InternalServerError(e)); } }
public BarCodeVideoResult(BarCodeResult initialValues) { Format = initialValues.Format; Value = initialValues.Value; }
static BarCodeResult() { Fail = new BarCodeResult { Success = false }; }