Example #1
0
        public async Task <IEnumerable <QRData> > GetData(ParametersRequest parametersRequest, ShowText showText)
        {
            var lst = new List <QRData>();

            try
            {
                var sheet = _Package.Workbook.Worksheets[1];
                if (sheet.Dimension == null)
                {
                    return(lst);
                }
                var last = sheet.Dimension.End.Row;
                for (int i = FirstRow + (FirstIsHead ? 1 : 0); i <= last; i++)
                {
                    var data = new QRData();
                    foreach (var f in _Fields)
                    {
                        data.SimpleSetValue(f.Key, sheet.Cells[$"{f.Value}{i}"].Value);
                    }
                    lst.Add(data);
                }
                await Task.Yield();
            }
            catch (Exception e)
            {
                showText(e.Message);
                Helpers.ConsoleWrite(e.Message, ConsoleColor.Yellow);
            }
            return(lst);
        }
Example #2
0
    /// Initialization is just a matter of asking for permission, and then
    /// hooking up to the `QRCodeWatcher`'s events. `QRCodeWatcher.RequestAccessAsync`
    /// is an async call, so you could re-arrange this code to be non-blocking!
    ///
    /// You'll also notice there's some code here for filtering out QR codes.
    /// The default behavior for the QR code library is to provide all QR
    /// codes that it knows about, and that includes ones that were found
    /// before the session began. We don't need that, so we're ignoring those.
    public void Initialize()
    {
        // Ask for permission to use the QR code tracking system
        var status = QRCodeWatcher.RequestAccessAsync().Result;

        if (status != QRCodeWatcherAccessStatus.Allowed)
        {
            return;
        }

        // Set up the watcher, and listen for QR code events.
        watcherStart   = DateTime.Now;
        watcher        = new QRCodeWatcher();
        watcher.Added += (o, qr) => {
            // QRCodeWatcher will provide QR codes from before session start,
            // so we often want to filter those out.
            if (qr.Code.LastDetectedTime > watcherStart)
            {
                poses.Add(qr.Code.Id, QRData.FromCode(qr.Code));
            }
        };
        watcher.Updated += (o, qr) => poses[qr.Code.Id] = QRData.FromCode(qr.Code);
        watcher.Removed += (o, qr) => poses.Remove(qr.Code.Id);
        watcher.Start();
    }
Example #3
0
    void OnGUI()
    {
        // drawing the camera on screen
        GUI.DrawTexture(screenRect, camTexture, ScaleMode.ScaleAndCrop);
        // do the reading — you might want to attempt to read less often than you draw on the screen for performance sake
        try
        {
            // Decodes the current frame.
            IBarcodeReader barcodeReader = new BarcodeReader();
            var            result        = barcodeReader.Decode(camTexture.GetPixels32(), camTexture.width, camTexture.height);
            if (result != null)
            {
                // Decodes the QR code.
                Debug.Log("Decoded from QR: " + result.Text);
                QRData qrData = DecodeTextQR(result.Text);

                // Creates a debug string.
                String debugHeights = "Heights: ";
                String debugColors  = "Colors: ";
                for (int i = 0; i < 50; i++)
                {
                    debugHeights += qrData.heights[i] + " ";
                    debugColors  += qrData.colors[i] + " ";
                }
                Debug.Log(debugHeights);
                Debug.Log(debugColors);
            }
        }
        catch (Exception ex) { Debug.LogWarning(ex.Message); }
    }
Example #4
0
        QRData getNew()
        {
            var d = new QRData() as dynamic;

            d.Value  = "123";
            d.Value2 = "321";
            return(d);
        }
Example #5
0
        public static QRData FromCode(QRCode qr)
        {
            QRData result = new QRData();

            result.pose = Pose.FromSpatialNode(qr.SpatialGraphNodeId);
            result.size = qr.PhysicalSideLength;
            result.text = qr.Data == null ? "" : qr.Data;
            return(result);
        }
Example #6
0
        public static QRData FromCode(QRCode qr)
        {
            QRData result = new QRData();

            // It's not unusual for this to fail to find a pose, especially on
            // the first frame it's been seen.
            World.FromSpatialNode(qr.SpatialGraphNodeId, out result.pose);
            result.size = qr.PhysicalSideLength;
            result.text = qr.Data == null ? "" : qr.Data;
            return(result);
        }
Example #7
0
        public string EncodeLocationIdToBase64(int id)
        {
            var toEncode = new QRData()
            {
                location_id = id.ToString(),
                server_id   = "2"
            };

            string stringToEncode = JsonConvert.SerializeObject(toEncode);

            QRCodeGenerator qrGenerator = new QRCodeGenerator();
            QRCodeData      qrCodeData  = qrGenerator.CreateQrCode(stringToEncode, QRCodeGenerator.ECCLevel.Q);
            Base64QRCode    qrCode      = new Base64QRCode(qrCodeData);

            return(qrCode.GetGraphic(20, Color.Black, Color.White, (Bitmap)Bitmap.FromFile("wwwroot/images/CW.png")));
        }
Example #8
0
        public static System.Drawing.Bitmap MakeBmp(this QRData data, int ppm, string qrFormat, System.Drawing.Color qrFore, System.Drawing.Color qrBack, bool full, bool showText, string textFormat, System.Drawing.Color textFore, System.Drawing.Color textBack, int borderWidth, int textPercent)
        {
            string qrText = data.GenInfo(qrFormat);

            if (string.IsNullOrWhiteSpace(qrText))
            {
                return(null);
            }
            var text = showText ? data.GenInfo(textFormat) : null;

            if (string.IsNullOrWhiteSpace(text))
            {
                return(qrText.ToQRCode().GetGraphic(ppm, qrFore, qrBack, !full));
            }
            else
            {
                return(qrText.ToQRCode().GetGraphic(ppm, qrFore, qrBack, CreateBitmapImage(text, textFore, textBack), textPercent, borderWidth, !full));
            }
        }
Example #9
0
    private void ProcessQR(QRData _data)
    {
        _QR.CamStop();

        ws.Addr       = _data.IP;
        _LabelQR.text = "接続中です...";
        Canvas.ForceUpdateCanvases();

        var res = ws.RequestHTTP(Method.GET, "check");

        if (res == null)
        {
            // 接続不可
            _LabelQR.color    = Color.red;
            _LabelQR.fontSize = 32;
            _LabelQR.text     = "サーバに接続することができませんでした";
            _QR.CamStart();
            return;
        }
        else if (res != "authenticated" && _data.isPerformer)
        {
            // パフォーマーモード
            _LabelQR.text = "確認中です...";
            Canvas.ForceUpdateCanvases();
            var pin = _data.PIN;

            res = ws.RequestHTTP(Method.POST, "pin", pin);
            if (res != "ok")
            {
                // 不正なPIN
                _LabelQR.color    = Color.red;
                _LabelQR.fontSize = 32;
                _LabelQR.text     = "PINが正しくありません";
                _QR.CamStart();
                return;
            }
        }

        // キャリブレーション・接続待機画面へ
        TransitionView("Forward", CalibWaitView);
        ws.Connect(_data.isPerformer, res == "authenticated");
    }
Example #10
0
 public async Task <QRData> AddData(ParametersRequest parametersRequest, ShowText showText)
 {
     try
     {
         if (_Fields.Count == 0)
         {
             showText($"There is no fields.");
             return(null);
         }
         var dict = new List <IParametersRequestItem>();
         foreach (var f in _Fields.Keys)
         {
             dict.Add(new ParametersRequestItem()
             {
                 Title = f, Value = new StringValueItem(null)
             });
         }
         if (await parametersRequest(dict, "OpenXml: Добавление объекта"))
         {
             var data  = new QRData();
             var sheet = _Package.Workbook.Worksheets[1];
             var r     = sheet.Dimension.End.Row + 1;
             foreach (var prop in dict)
             {
                 data.SimpleSetValue(prop.Title, prop.Value.Value);
                 sheet.Cells[$"{_Fields[prop.Title]}{r}"].Value = prop.Value.Value;
             }
             return(data);
         }
     }
     catch (Exception e)
     {
         showText(e.Message);
         Helpers.ConsoleWrite(e.Message, ConsoleColor.Yellow);
     }
     return(null);
 }
Example #11
0
 public static string GenInfo(this QRData data, string format)
 {
     if (string.IsNullOrWhiteSpace(format))
     {
         return(string.Empty);
     }
     try
     {
         return(geRegex.Replace(format, m =>
         {
             object o;
             if (data.SimpleTryGetValue(m.Groups[1].Value, out o, true))
             {
                 return o?.ToString();
             }
             return string.Empty;
         }
                                ));
     }
     catch
     {
         return(string.Empty);
     }
 }
Example #12
0
 public static System.Drawing.Bitmap MakeBmp(this QRData data, int ppm, string qrFormat, string qrFore, string qrBack, bool full, bool showText, string textFormat, string textFore, string textBack, int borderWidth, int textPercent)
 {
     return(MakeBmp(data, ppm, qrFormat, qrFore.ToSDColor(), qrBack.ToSDColor(), full, showText, textFormat, textFore.ToSDColor(), textBack.ToSDColor(), borderWidth, textPercent));
 }