示例#1
0
        public Store ReadQR(string name)
        {
            string imagePath = Utils.GetStoresPath() + name;
            Bitmap image     = new Bitmap(imagePath);

            var    data       = _QRdecoder.ImageDecoder(image);
            string jsonObject = QRCode.ByteArrayToStr(data[0]);

            QRStore qrStore = JsonConvert.DeserializeObject <QRStore>(jsonObject);

            Store store = new Store(qrStore.idStore, qrStore.storeName);

            store.products = ConvertProductListToStoreProductList(qrStore.products);
            image.Dispose();

            return(store);
        }
示例#2
0
        public void CreateQR(Store store)
        {
            string path = Utils.GetStoresPath() + store.storeName + ".png";
            string json = JsonConvert.SerializeObject(store);

            QRStore qrStore = new QRStore(store.idStore, store.storeName);

            qrStore.products = ConvertStoreProductListToProductList(store.products);

            _QRencoder.Encode(ErrorCorrection.H, json);
            Bitmap QRStore = QRCodeToBitmap.CreateBitmap(_QRencoder, 4, 8);

            FileStream FS = new FileStream(path, FileMode.Create);

            QRStore.Save(FS, ImageFormat.Png);
            FS.Close();
            Logger.Log(String.Format("Image succesfully created for store: {0}", qrStore.storeName));
        }