예제 #1
0
        public ReceiveViewModel(string path, string ipAddress, int port, string token)
        {
            this.path      = path;
            this.ipAddress = ipAddress;
            this.port      = port;
            this.token     = token;

            Stop = ReactiveCommand.Create(() => { });

            UriPath = string.Format("http://{0}:{1}", ipAddress, port);
            URL     = string.Format("http://{0}:{1}/upload/", ipAddress, port, token);

            var bytes = QrHelper.GenPngByteFromUrl(URL);

            using (MemoryStream stream = new MemoryStream(bytes))
            {
                Bitmap = new Bitmap(stream);
            }
            Stop.Subscribe(_ =>
            {
                StopServer();
            });

            StartServer();
        }
예제 #2
0
 public ActionResult QrCode(string qrValue, int h = 250, int w = 250, int m = 0, bool download = false)
 {
     using (var bitmap = QrHelper.GetBitmap(qrValue, h, w, m))
     {
         using (var stream = new MemoryStream())
         {
             bitmap.Save(stream, ImageFormat.Gif);
             if (download)
             {
                 return(File(stream.ToArray(), "image/jpeg", DateTime.Now.Ticks + ".jpg"));
             }
             return(File(stream.ToArray(), "image/jpeg"));
         }
     }
 }
예제 #3
0
        // Send to Mobile Function
        private void bunifuFlatButton2_Click(object sender, EventArgs e)
        {
            var    qrCreator = new QrHelper(150, 150, 3, UserInfo.EventId.ToString() + "/" + UId);
            Bitmap qr        = qrCreator.GetQRCode();

            if (!Directory.Exists(Path.Combine(Directory.GetCurrentDirectory(), "temp")))
            {
                Directory.CreateDirectory(Path.Combine(Directory.GetCurrentDirectory(), "temp"));
            }
            qr.Save(Path.Combine(Directory.GetCurrentDirectory(), "temp/generated.jpg"));

            new BluetoothDeviceChooser().Show();
            //}
            //Redirect();
        }
예제 #4
0
        public JsonActionResult <string> GenerateQRCode(string url)
        {
            return(SafeExecute(() =>
            {
                var bmp = QrHelper.Create(url);

                var fileName = string.Concat(DateTime.Now.ToString("yyyyMMddHHmmssfff"), ".png");
                var targetDir = Path.Combine(AppContext.PathInfo.RootPath, "Pictures", "CouponTemplateDeliveryQrCode");
                if (!Directory.Exists(targetDir))
                {
                    Directory.CreateDirectory(targetDir);
                }
                string targetPath = Path.Combine(targetDir, fileName);

                bmp.Save(targetPath);
                var result = Path.Combine(AppContext.Settings.SiteDomain, "Pictures", "CouponTemplateDeliveryQrCode", fileName);
                return result;
            }));
        }
예제 #5
0
        public void Serialize(string attendeeId)
        {
            UId = attendeeId;
            var    qrCreator = new QrHelper(150, 150, 3, UserInfo.EventId.ToString() + "/" + attendeeId);
            Bitmap qr        = qrCreator.GetQRCode();
            var    Ticket    = new Bitmap(QR.Width, QR.Height);
            var    graphics  = Graphics.FromImage(Ticket);                                                                                                         // Ticket

            graphics.DrawRectangle(new Pen(Brushes.Black), new Rectangle(new Point(0, 0), new Size(QR.Width - 1, QR.Height - 1)));                                 // Outline
            graphics.DrawImage(Resources.bulsu_colored, new Rectangle(new Point(8, 8), new Size(70, 70)));
            graphics.DrawString("Bulacan State University", new Font("Times New Roman", 11F), Brushes.Black, new Point(90, 20));                                   // Authority Name
            graphics.DrawString("Malolos Bulacan, Philippines", new Font("Times New Roman", 11F), Brushes.Black, new Point(90, 35));                               // Authority Address
            graphics.DrawImage(qr, new PointF(75, 65));                                                                                                            // QR
            graphics.DrawString(UserInfo.EventName, new Font("Times New Roman", 11F, FontStyle.Regular), new SolidBrush(Color.DarkSlateGray), new Point(75, 220)); // Event Name
            graphics.DrawString("Ticket No: " + attendeeId, new Font("Times New Roman", 11F, FontStyle.Regular), Brushes.Black, new Point(20, 240));               // Ticket No
            graphics.DrawString(attendee, new Font("Times New Roman", 11F, FontStyle.Regular), Brushes.Black, new Point(20, 255));                                 // Owner Name
            graphics.DrawString(UserInfo.EventLocation, new Font("Times New Roman", 11F, FontStyle.Regular), Brushes.Black, new Point(20, 270));                   // Event Location
            QR.Image = Ticket;
        }