Exemplo n.º 1
0
        public static byte[] BuildQRCode(Credential credentialSelected)
        {
            if (credentialSelected != null)
            {
                string stringToShow = string.Empty;
                stringToShow += credentialSelected.Title.ToUpper();
                if (!string.IsNullOrEmpty(credentialSelected.Url))
                {
                    stringToShow += " (Url: " + credentialSelected.Url + ")";
                }
                stringToShow += Environment.NewLine;

                if (!string.IsNullOrEmpty(credentialSelected.Email))
                {
                    stringToShow += "Email: " + credentialSelected.Email;
                    stringToShow += Environment.NewLine;
                }
                if (!string.IsNullOrEmpty(credentialSelected.Username))
                {
                    stringToShow += "Username: "******"Password: " + credentialSelected.Password + Environment.NewLine;

                GeneratedBarcode qrCode = BarcodeWriter.CreateBarcode(stringToShow, BarcodeWriterEncoding.QRCode, 200, 200);
                qrCode.AddAnnotationTextBelowBarcode(credentialSelected.Title);
                return(qrCode.ToPngBinaryData());
            }

            return(null);
        }
Exemplo n.º 2
0
        private void generateBarcode(int ArtNr)
        {
            string ean = "400" + ArtNr.ToString() + "1234";

            ean = ean + _checksum_ean13(ean).ToString();
            GeneratedBarcode MyBarCode = IronBarCode.BarcodeWriter.CreateBarcode(ean, BarcodeWriterEncoding.Code128);

            MyBarCode.ResizeTo(500, 200).SetMargins(10);
            System.Drawing.Image BarCode = MyBarCode.Image;
            byte[] bytes = MyBarCode.ToPngBinaryData();
            //BitmapImage bild = ModulModell.Byte2Pic(bytes);
            BitmapImage bild = new BitmapImage();

            bild.BeginInit();
            bild.CacheOption  = BitmapCacheOption.OnLoad;
            bild.StreamSource = new System.IO.MemoryStream(bytes);
            bild.EndInit();


            _uiBarcode.Source = bild;
        }