public void It_should_render_rounded_panels()
        {
            var renderer = new BitmapRenderer();

            var vbox = new HBox();

            var borders = new[]
            {
                new [] { "10 0 0 0", "0 10 0 0", "0 0 10 0", "0 0 0 10" },
                new [] { "10 10 0 0", "10 0 10 0", "10 0 0 10", "0 0 10 10" },
                new [] { "10 10 10 0", "10 0 10 10", "10 10 0 10", "10 10 10 10" }
            };

            foreach (var boxLine in borders)
            {
                var hbox = new HBox();
                foreach (var border in boxLine)
                {
                    hbox.AddComponent(new Panel
                    {
                        Margin          = new Spacer(1),
                        BackgroundColor = Color.Blue,
                        Width           = 22,
                        Height          = 22,
                        BorderRadius    = BorderRadius.Parse(border)
                    });
                }
                vbox.AddComponent(hbox);
            }

            var bmp = new Bitmap(300, 40);

            renderer.Render(new Form(vbox), bmp);
            BitmapComparer.CompareBitmaps("panels_rounded", bmp);
        }
Example #2
0
        /// <summary>
        /// uses the BarcodeWriterGeneric implementation and the <see cref="BitmapRenderer"/> class for decoding
        /// </summary>
        /// <param name="writer"></param>
        /// <param name="content"></param>
        /// <returns></returns>
        public static Bitmap WriteAsBitmap(this IBarcodeWriterGeneric writer, string content)
        {
            var bitmatrix = writer.Encode(content);
            var renderer  = new BitmapRenderer();

            return(renderer.Render(bitmatrix, writer.Format, content, writer.Options));
        }
Example #3
0
        public void It_should_render_text_with_different_line_heights()
        {
            var renderer = new BitmapRenderer();
            var content  = new HBox {
                Width = SizeUnit.Unlimited
            };

            content.AddComponent(new Panel
            {
                Width           = 100,
                Height          = SizeUnit.Unlimited,
                BackgroundColor = Color.Yellow,
                Margin          = new Spacer(1),
                Inner           = new Label
                {
                    TextColor  = Color.Red,
                    Font       = new FontInfo(TestFontFamily.Serif, 10, FontInfoStyle.Underline | FontInfoStyle.Italic),
                    Text       = "Hello my friend!\nIt's nice to see you!\n\nWhat is a nice and sunny day, is not it?",
                    LineHeight = 1.2f
                }
            });

            content.AddComponent(new Panel
            {
                Width           = 100,
                Height          = SizeUnit.Unlimited,
                BackgroundColor = Color.Yellow,
                Margin          = new Spacer(1),
                Inner           = new Label
                {
                    TextColor  = Color.Red,
                    Font       = new FontInfo(TestFontFamily.Serif, 10, FontInfoStyle.Underline | FontInfoStyle.Italic),
                    Text       = "Hello my friend!\nIt's nice to see you!\n\nWhat is a nice and sunny day, is not it?",
                    LineHeight = 2f
                }
            });

            content.AddComponent(new Panel
            {
                Width           = 100,
                Height          = SizeUnit.Unlimited,
                BackgroundColor = Color.Yellow,
                Margin          = new Spacer(1),
                Inner           = new Label
                {
                    TextColor  = Color.Red,
                    Font       = new FontInfo(TestFontFamily.Serif, 10, FontInfoStyle.Underline | FontInfoStyle.Italic),
                    Text       = "Hello my friend!\nIt's nice to see you!\n\nWhat is a nice and sunny day, is not it?",
                    LineHeight = 0.8f
                }
            });

            var form = new Form(content);

            var bmp = new Bitmap(300, 400);

            renderer.Render(form, bmp);
            BitmapComparer.CompareBitmaps("text_box_line_height", bmp);
        }
Example #4
0
        public void It_should_render_images()
        {
            var redBlue    = CreateBitmap(Brushes.Red, Brushes.Blue, 400, 400);
            var blueYellow = CreateBitmap(Brushes.Blue, Brushes.Yellow, 30, 30);

            var renderer = new BitmapRenderer();
            var vBox     = new VBox();
            var hBox     = new HBox();

            AddComponent(hBox, new Image {
                Src = redBlue, Width = 40, Height = 40, Scaling = ImageScaling.Uniform
            });
            AddComponent(hBox, new Image {
                Src = redBlue, Width = 40, Height = 30, Scaling = ImageScaling.Uniform, Alignment = Alignment.Center
            });
            AddComponent(hBox, new Image {
                Src = redBlue, Width = 40, Height = 30, Scaling = ImageScaling.Uniform, Alignment = Alignment.Parse("center left")
            });
            AddComponent(hBox, new Image {
                Src = redBlue, Width = 40, Height = 30, Scaling = ImageScaling.Uniform, Alignment = Alignment.Parse("center right")
            });
            vBox.AddComponent(hBox);
            hBox = new HBox();
            AddComponent(hBox, new Image {
                Src = redBlue, Width = 30, Height = 40, Scaling = ImageScaling.Uniform, Alignment = Alignment.Center
            });
            AddComponent(hBox, new Image {
                Src = redBlue, Width = 30, Height = 40, Scaling = ImageScaling.Uniform, Alignment = Alignment.Parse("top center")
            });
            AddComponent(hBox, new Image {
                Src = redBlue, Width = 30, Height = 40, Scaling = ImageScaling.Uniform, Alignment = Alignment.Parse("bottom center")
            });
            vBox.AddComponent(hBox);
            hBox = new HBox();
            AddComponent(hBox, new Image {
                Src = redBlue, Width = 10, Height = 20, Scaling = ImageScaling.Fill
            });
            AddComponent(hBox, new Image {
                Src = blueYellow, Scaling = ImageScaling.None
            });
            AddComponent(hBox, new Image {
                Src = blueYellow, Width = 20, Height = 20, Alignment = Alignment.Center, Scaling = ImageScaling.None
            });
            AddComponent(hBox, new Image {
                Src = blueYellow, Width = 20, Height = 20, Alignment = Alignment.Parse("top left"), Scaling = ImageScaling.None
            });
            AddComponent(hBox, new Image {
                Src = blueYellow, Width = 20, Height = 20, Alignment = Alignment.Parse("bottom right"), Scaling = ImageScaling.None
            });
            vBox.AddComponent(hBox);
            var form = new Form(vBox);

            var bmp = renderer.Render(form);

            BitmapComparer.CompareBitmaps("bitmaps", bmp);
        }
        private void eventCB_SelectedIndexChanged(object sender, EventArgs e)
        {
            var            eventQRCode   = eventList[eventCB.SelectedIndex].qrCodeString;
            var            barcodeWriter = new QRCodeWriter();
            BitMatrix      bm            = barcodeWriter.encode(eventQRCode, ZXing.BarcodeFormat.QR_CODE, 600, 600);
            BitmapRenderer bit           = new BitmapRenderer();
            Bitmap         image         = bit.Render(bm, ZXing.BarcodeFormat.QR_CODE, eventQRCode);

            qrCodePhoto.Image = image;
        }
Example #6
0
        private void PrintWalletInfo()
        {
            QRCodeWriter write = new QRCodeWriter();

            int size = 120;

            BitMatrix      matrix = write.encode("", ZXing.BarcodeFormat.QR_CODE, size, size, null);
            BitmapRenderer bit    = new BitmapRenderer();

            Android.Graphics.Bitmap bitmap = bit.Render(matrix, BarcodeFormat.QR_CODE, "");
        }
        private void GenerateQRCode()
        {
            var uuid = Intent.GetStringExtra("uuid");

            codeTextView.Text = uuid;
            QRCodeWriter   writer = new QRCodeWriter();
            BitMatrix      bm     = writer.encode(uuid, ZXing.BarcodeFormat.QR_CODE, 600, 600);
            BitmapRenderer bit    = new BitmapRenderer();
            Bitmap         image  = bit.Render(bm, ZXing.BarcodeFormat.QR_CODE, uuid);

            qrCodeImage.SetImageBitmap(image);
        }
Example #8
0
        public static Bitmap CreateQRCode(string address)
        {
            QRCodeWriter write = new QRCodeWriter();

            int size = 120;

            BitMatrix      matrix = write.encode(address, ZXing.BarcodeFormat.QR_CODE, size, size, null);
            BitmapRenderer bit    = new BitmapRenderer();
            Bitmap         bitmap = bit.Render(matrix, BarcodeFormat.QR_CODE, address);

            return(bitmap);
        }
Example #9
0
        private void RenderMaze()
        {
            using (var renderer = new BitmapRenderer(_configuration, _maze.Cells, TbCellWidth.NumValue, TbCellHeight.NumValue))
            {
                if (CbHighlightSolution.IsChecked.HasValue && CbHighlightSolution.IsChecked.Value)
                {
                    renderer.HighlightCells(_maze.Path.ToArray());
                }

                var bitmap = renderer.Render();
                MazeVisualization.Source = ConvertBitmapToImageSource(bitmap);
            }
        }
Example #10
0
        public async Task Compile(string name, string snippet)
        {
            var form = await _loader.LoadForm(new StringReader(snippet));

            WrapForm(form);
            var opt = new BitmapRendererOptions
            {
                ConfigureGraphics = g => { g.TextRenderingHint = TextRenderingHint.AntiAliasGridFit; }
            };

            using (var bmp = _renderer.Render(form, opt))
            {
                bmp.Save($"man\\assets\\{name}");
            }
        }
Example #11
0
        public void It_should_render_panels_and_hboxes()
        {
            var renderer = new BitmapRenderer();

            var hbox = new HBox {
                Alignment = Alignment.Center
            };

            hbox.AddComponent(new Panel
            {
                BackgroundColor = Color.Yellow,
                Padding         = new Spacer(5),
                Border          = new Border(3, Color.Red),
                Alignment       = new Alignment(VerticalAlignment.Bottom)
            });
            hbox.AddComponent(new Panel
            {
                BackgroundColor = Color.Green,
                Padding         = new Spacer(10, 5),
                Border          = new Border(2, Color.Red),
                Alignment       = new Alignment(VerticalAlignment.Center)
            });
            hbox.AddComponent(new Panel
            {
                BackgroundColor = Color.Blue,
                Padding         = new Spacer(15, 5),
                Border          = new Border(1, Color.Red)
            });
            var panel = new Panel
            {
                Width           = SizeUnit.Unlimited,
                Height          = SizeUnit.Unlimited,
                BackgroundColor = Color.LightSteelBlue,
                Padding         = new Spacer(2),
                Inner           = hbox,
            };
            var form = new Form(panel);

            var bmp = new Bitmap(50, 40);

            renderer.Render(form, bmp);
            BitmapComparer.CompareBitmaps("panels_hbox", bmp);
        }
Example #12
0
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();

            // Init
            var documents            = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments);
            var userInfoFileName     = Path.Combine(documents, "UserInfo.json");
            var medicalsInfoFileName = Path.Combine(documents, "MedicalsInfo.json");

            var user     = JsonConvert.DeserializeObject <user>(File.ReadAllText(userInfoFileName));
            var medicals = JsonConvert.DeserializeObject <Medical>(File.ReadAllText(medicalsInfoFileName));

            // QR Code
            var str = string.Format("http://blockchain.whisperq.ru/medical/Emergency?token={0}", user.token);

            Writer         writer         = new QRCodeWriter();
            BitMatrix      bitMatrix      = writer.encode(str, BarcodeFormat.QR_CODE, 340, 300);
            BitmapRenderer bitmapRenderer = new BitmapRenderer();
            UIImage        image          = bitmapRenderer.Render(bitMatrix, BarcodeFormat.QR_CODE, str);

            QrCodeImage.Image = image;
        }
Example #13
0
        static async Task Main(string[] args)
        {
            Quake3TileMap.SetRootDirectory(@"C:\quake3\baseq3\maps\");

            var w = 16;
            var h = 16;

            var m = new Wang.WangMazeMap(w, h, 5, 0, true);

            m.Generate();

            var themes = new[]
            {
                BitmapTheme.Wang,
                BitmapTheme.Bridge,
                BitmapTheme.Commune,
                BitmapTheme.Dungeon,
                BitmapTheme.Islands,
                BitmapTheme.Trench,
            };

            foreach (var t in themes)
            {
                var b = new BitmapRenderer(m, w, h, t);
                await b.Render(new BitmapRenderOptions());
            }

            var q = new Quake3Renderer(m, w, h);
            await q.Render(new Quake3RenderOptions
            {
                OutputFile = @"C:\quake3\baseq3\maps\wang.map"
            });

            Console.WriteLine("Done");
            Console.ReadKey();
        }
Example #14
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            //Xamarin.Essentials.Platform.Init(this, savedInstanceState);
            // Set our view from the "main" layout resource
            SetContentView(Resource.Layout.activity_main);
            SupportActionBar.Hide();
            CrossCurrentActivity.Current.Init(this, savedInstanceState);
            var Imagen       = FindViewById <ImageView>(Resource.Id.image);
            var btnAlmacenar = FindViewById <Button>(Resource.Id.btnalmacenar);
            var txtNombre    = FindViewById <EditText>(Resource.Id.txtnombre);
            var txtDomicilio = FindViewById <EditText>(Resource.Id.txtdomicilio);
            var txtCorreo    = FindViewById <EditText>(Resource.Id.txtcorreo);
            var txtEdad      = FindViewById <EditText>(Resource.Id.txtedad);
            var txtSaldo     = FindViewById <EditText>(Resource.Id.txtsaldo);

            txtNombre.RequestFocus();
            Imagen.Click += async delegate
            {
                await CrossMedia.Current.Initialize();

                var archivo = await CrossMedia.Current.TakePhotoAsync(new Plugin.Media.Abstractions.StoreCameraMediaOptions
                {
                    Directory          = "Imágenes",
                    Name               = txtNombre.Text,
                    SaveToAlbum        = true,
                    CompressionQuality = 30,
                    CustomPhotoSize    = 30,
                    PhotoSize          = Plugin.Media.Abstractions.PhotoSize.Medium,
                    DefaultCamera      = Plugin.Media.Abstractions.CameraDevice.Rear
                });

                if (archivo == null)
                {
                    return;
                }
                Bitmap bp = BitmapFactory.DecodeStream(archivo.GetStream());
                Archivo = System.IO.Path.Combine(System.IO.Path.Combine(System.Environment.GetFolderPath(System.Environment.SpecialFolder.Personal), txtNombre.Text + ".jpg"));
                var stream = new FileStream(Archivo, FileMode.Create);
                bp.Compress(Bitmap.CompressFormat.Jpeg, 30, stream);
                stream.Close();
                Imagen.SetImageBitmap(bp);
                long memoria1 = GC.GetTotalMemory(false);
                Toast.MakeText(this.ApplicationContext, memoria1.ToString(), ToastLength.Long).Show();
                GC.Collect();
                long memoria2 = GC.GetTotalMemory(false);
                Toast.MakeText(this.ApplicationContext, memoria2.ToString(), ToastLength.Long).Show();
            };
            btnAlmacenar.Click += async delegate
            {
                try
                {
                    var CuentadeAlmacenamiento = CloudStorageAccount.Parse("DefaultEndpointsProtocol=https;AccountName=enriqueaguilar;AccountKey=zvor3ixApqcKKWJj5nk2tDmrSNinlSk6W0stEnAeBRyZdZAVYpp9J/Ag/lAamkKBaJP0VK4GXt4/DnVN6CU4YQ==;EndpointSuffix=core.windows.net");
                    var ClienteBlob            = CuentadeAlmacenamiento.CreateCloudBlobClient();
                    var Carpeta      = ClienteBlob.GetContainerReference("imagenes");
                    var resourceBlob = Carpeta.GetBlockBlobReference(txtNombre.Text + ".jpg");
                    await resourceBlob.UploadFromFileAsync(Archivo.ToString());

                    Toast.MakeText(this.ApplicationContext, "Imagen almacenada en contenedor de Blobs", ToastLength.Long).Show();

                    rutablob = resourceBlob.StorageUri.PrimaryUri.ToString();
                    Writer         writer   = new QRCodeWriter();
                    BitMatrix      bm       = writer.encode(rutablob, BarcodeFormat.QR_CODE, 600, 600);
                    BitmapRenderer bit      = new BitmapRenderer();
                    var            imagenqr = bit.Render(bm, BarcodeFormat.QR_CODE, rutablob);
                    Imagen.SetImageBitmap(imagenqr);

                    var TablaNoSQL = CuentadeAlmacenamiento.CreateCloudTableClient();
                    var Coleccion  = TablaNoSQL.GetTableReference("Registros");
                    await Coleccion.CreateIfNotExistsAsync();

                    var clientes = new Clientes("Clientes con Imágenes", txtNombre.Text);
                    clientes.Correo     = txtCorreo.Text;
                    clientes.Saldo      = double.Parse(txtSaldo.Text);
                    clientes.Edad       = int.Parse(txtEdad.Text);
                    clientes.Domicilio  = txtDomicilio.Text;
                    clientes.ImagenBlob = txtNombre.Text + ".jpg";
                    var Almacena = TableOperation.Insert(clientes);
                    await Coleccion.ExecuteAsync(Almacena);

                    Toast.MakeText(this.ApplicationContext, "Datos almacenados en Tabla NoSQL", ToastLength.Long).Show();
                } catch (Exception ex)
                {
                    Toast.MakeText(this, ex.Message, ToastLength.Long).Show();
                }
            };
        }
Example #15
0
        private async Task <Bitmap> Generate()
        {
            var form = await _loader.LoadForm(new MemoryStream(_formInBytes));

            return(_renderer.Render(form));
        }
Example #16
0
 private void ButtonClicked(object sender, EventArgs e)
 {
     if ((sender as Button) == bGenerate)
     {
         try
         {
             string QRdata1 = null;
             string QRdata2 = null;
             //get the MatchData for the selected event
             List <MatchData> scoutList = eData.GetMatchDataForEvent(selectedEvent.eventID);
             for (int i = 0; i < scoutList.Count; i++)
             {
                 //split data into two
                 if (i < Math.Round((double)scoutList.Count / 2))
                 {
                     QRdata1 += scoutList[i].teamNumber.ToString() + "," +
                                scoutList[i].matchNumber.ToString() + "," +
                                scoutList[i].result.ToString() +
                                scoutList[i].position.ToString() +
                                Convert.ToByte(scoutList[i].isTable).ToString() +
                                scoutList[i].sandstormStartLevel.ToString() +
                                scoutList[i].sandstormMode.ToString() +
                                Convert.ToByte(scoutList[i].sandstormHatch).ToString() +
                                Convert.ToByte(scoutList[i].sandstormCargo).ToString() +
                                Convert.ToByte(scoutList[i].sandstormLine).ToString() +
                                Convert.ToByte(scoutList[i].cargo).ToString() +
                                Convert.ToByte(scoutList[i].cargoWell).ToString() +
                                Convert.ToByte(scoutList[i].cargoBarely).ToString() +
                                Convert.ToByte(scoutList[i].hatch).ToString() +
                                Convert.ToByte(scoutList[i].hatchWell).ToString() +
                                Convert.ToByte(scoutList[i].hatchBarely).ToString() +
                                scoutList[i].climb.ToString() +
                                Convert.ToByte(scoutList[i].goodDrivers).ToString() +
                                scoutList[i].wouldRecommend.ToString();
                 }
                 else
                 {
                     QRdata2 += scoutList[i].teamNumber.ToString() + "," +
                                scoutList[i].matchNumber.ToString() + "," +
                                scoutList[i].result.ToString() +
                                scoutList[i].position.ToString() +
                                Convert.ToByte(scoutList[i].isTable).ToString() +
                                scoutList[i].sandstormStartLevel.ToString() +
                                scoutList[i].sandstormMode.ToString() +
                                Convert.ToByte(scoutList[i].sandstormHatch).ToString() +
                                Convert.ToByte(scoutList[i].sandstormCargo).ToString() +
                                Convert.ToByte(scoutList[i].sandstormLine).ToString() +
                                Convert.ToByte(scoutList[i].cargo).ToString() +
                                Convert.ToByte(scoutList[i].cargoWell).ToString() +
                                Convert.ToByte(scoutList[i].cargoBarely).ToString() +
                                Convert.ToByte(scoutList[i].hatch).ToString() +
                                Convert.ToByte(scoutList[i].hatchWell).ToString() +
                                Convert.ToByte(scoutList[i].hatchBarely).ToString() +
                                scoutList[i].climb.ToString() +
                                Convert.ToByte(scoutList[i].goodDrivers).ToString() +
                                scoutList[i].wouldRecommend.ToString();
                 }
             }
             //get QR code writer
             Writer writer = new QRCodeWriter();
             int    width  = this.Resources.DisplayMetrics.WidthPixels;
             //create the QR codes
             try
             {
                 BitMatrix      bm1  = writer.encode(QRdata1, BarcodeFormat.QR_CODE, width, width);
                 BitmapRenderer bit1 = new BitmapRenderer();
                 QR1.SetImageBitmap(bit1.Render(bm1, BarcodeFormat.QR_CODE, QRdata1));
                 Popup.Single("Alert", "Data for Event: '" + selectedEvent.eventName + "' Event ID: " +
                              selectedEvent.eventID.ToString() + " Generated. Please make sure that the receiving " +
                              "device has the correct event selected and that the event ids match", "OK", this);
             }
             //exception thrown if QR data strings are empty
             catch
             {
                 Popup.Single("Alert", "No data for this match", "OK", this);
             }
             //try to generate a second QR code
             try
             {
                 BitMatrix      bm2  = writer.encode(QRdata2, BarcodeFormat.QR_CODE, width, width);
                 BitmapRenderer bit2 = new BitmapRenderer();
                 QR2.SetImageBitmap(bit2.Render(bm2, BarcodeFormat.QR_CODE, QRdata2));
             }
             //do nothing if there is not enough data for a second QR code
             catch
             {
             }
         }
         //if no event is selected, it throws an exception
         catch
         {
             Popup.Single("Alert", "Please select an event to generate data for", "OK", this);
         }
     }
 }
Example #17
0
        public void It_should_render_viewports()
        {
            var renderer = new BitmapRenderer();

            var stack = new Stack();

            stack.AddComponent(new Panel
            {
                Width           = 100,
                Height          = 100,
                Border          = Border.Parse("1 #808080"),
                BackgroundColor = Color.LightBlue,
                BorderRadius    = BorderRadius.Parse("25")
            });
            stack.AddComponent(new Viewport
            {
                Alignment = Alignment.Parse("center left"),
                Width     = 10,
                Inner     = new Panel
                {
                    Width           = 40,
                    Height          = 40,
                    Border          = Border.Parse("1 #808080"),
                    BackgroundColor = Color.White,
                    BorderRadius    = BorderRadius.Parse("20")
                },
                ContentAlignment = Alignment.Parse("center right")
            });
            stack.AddComponent(new Viewport
            {
                Alignment = Alignment.Parse("top center"),
                Height    = 10,
                Inner     = new Panel
                {
                    Width           = 40,
                    Height          = 40,
                    Border          = Border.Parse("1 #808080"),
                    BackgroundColor = Color.White,
                    BorderRadius    = BorderRadius.Parse("20")
                },
                ContentAlignment = Alignment.Parse("bottom center")
            });
            stack.AddComponent(new Viewport
            {
                Alignment = Alignment.Parse("center right"),
                Width     = 10,
                Inner     = new Panel
                {
                    Width           = 40,
                    Height          = 40,
                    Border          = Border.Parse("1 #808080"),
                    BackgroundColor = Color.White,
                    BorderRadius    = BorderRadius.Parse("20")
                },
                ContentAlignment = Alignment.Parse("center left")
            });
            stack.AddComponent(new Viewport
            {
                Alignment = Alignment.Parse("bottom center"),
                Height    = 10,
                Inner     = new Panel
                {
                    Width           = 40,
                    Height          = 40,
                    Border          = Border.Parse("1 #808080"),
                    BackgroundColor = Color.White,
                    BorderRadius    = BorderRadius.Parse("20")
                },
                ContentAlignment = Alignment.Parse("top center")
            });
            stack.AddComponent(new Viewport
            {
                Alignment  = Alignment.Parse("center center"),
                ClipMargin = Spacer.Parse("3 1"),
                Inner      = new Panel
                {
                    Width           = 40,
                    Height          = 40,
                    BackgroundColor = Color.White,
                    Border          = Border.Parse("1 #808080"),
                    BorderRadius    = BorderRadius.Parse("20")
                },
                ContentAlignment = Alignment.Parse("center center")
            });
            var form = new Form(stack);

            var bmp = renderer.Render(form);

            BitmapComparer.CompareBitmaps("viewport", bmp);
        }
 private void RenderFrame() => _renderer.Render(chbTerritory.IsChecked ?? true);
        protected override UIImage Convert(BitMatrix value, Type targetType, object parameter, CultureInfo culture)
        {
            var output = Renderer.Render(value, ZXing.BarcodeFormat.QR_CODE, string.Empty, RenderSettings);

            return(output);
        }
Example #20
0
        public void It_should_render_text_with_alignments()
        {
            var renderer = new BitmapRenderer();

            var labelBox = new HBox {
                Width = SizeUnit.Unlimited
            };

            foreach (var align in new[] { TextAlignment.Left, TextAlignment.Right, TextAlignment.Center, TextAlignment.Justify })
            {
                labelBox.AddComponent(new Panel
                {
                    Width           = 100,
                    Height          = SizeUnit.Unlimited,
                    BackgroundColor = Color.Yellow,
                    Margin          = new Spacer(1),
                    Border          = new Border(1, Color.White),
                    Padding         = new Spacer(2),
                    Inner           = new Label
                    {
                        Width         = SizeUnit.Unlimited,
                        TextColor     = Color.Red,
                        TextAlignment = align,
                        Font          = new FontInfo(TestFontFamily.Serif, 10, FontInfoStyle.Underline | FontInfoStyle.Italic),
                        Text          = "Hello my friend!\nIt's nice to see you!\n\nWhat is a nice and sunny day, is not it?"
                    }
                });
            }

            var areaBox = new HBox {
                Width = SizeUnit.Unlimited
            };

            foreach (var align in new[] { TextAlignment.Left, TextAlignment.Right, TextAlignment.Center, TextAlignment.Justify })
            {
                var textBox = new TextBox
                {
                    Width         = SizeUnit.Unlimited,
                    TextAlignment = align
                };
                textBox.AddComponent(new Label
                {
                    TextColor = Color.Red,
                    Text      = "Hi Bob!",
                    Font      = new FontInfo(TestFontFamily.Serif, 10, FontInfoStyle.Underline | FontInfoStyle.Italic)
                });

                textBox.AddComponent(new Link
                {
                    TextColor = Color.Black,
                    Text      = "Check out this: ",
                    Font      = new FontInfo(TestFontFamily.Serif, 12, FontInfoStyle.Regular)
                });
                textBox.AddComponent(new Link
                {
                    TextColor = Color.Purple,
                    Text      = "great link!!!",
                    Font      = new FontInfo(TestFontFamily.Serif, 8, FontInfoStyle.Underline),
                    Uri       = "http://google.com"
                });
                areaBox.AddComponent(new Panel
                {
                    Width           = 100,
                    Height          = SizeUnit.Unlimited,
                    BackgroundColor = Color.Green,
                    Margin          = new Spacer(1),
                    Border          = new Border(1, Color.White),
                    Padding         = new Spacer(2),
                    Inner           = textBox
                });
            }

            var content = new VBox {
                Width = SizeUnit.Unlimited
            };

            content.AddComponent(labelBox);
            content.AddComponent(areaBox);

            var form = new Form(content);

            var bmp = new Bitmap(400, 400);

            renderer.Render(form, bmp);
            BitmapComparer.CompareBitmaps("text_box_align", bmp);
        }
Example #21
0
        public void It_should_render_text()
        {
            var renderer = new BitmapRenderer();
            var content  = new HBox {
                Width = SizeUnit.Unlimited
            };

            content.AddComponent(new Panel
            {
                Width           = 100,
                Height          = SizeUnit.Unlimited,
                BackgroundColor = Color.Yellow,
                Margin          = new Spacer(1),
                Border          = new Border(1, Color.White),
                Padding         = new Spacer(2),
                Inner           = new Label
                {
                    TextColor = Color.Red,
                    Font      = new FontInfo(TestFontFamily.Serif, 10, FontInfoStyle.Underline | FontInfoStyle.Italic),
                    Text      = "Hello my friend!\nIt's nice to see you!\n\nWhat is a nice and sunny day, is not it?"
                }
            });

            content.AddComponent(new Panel
            {
                Width           = 100,
                Height          = SizeUnit.Unlimited,
                BackgroundColor = Color.DarkSeaGreen,
                Margin          = new Spacer(1),
                Border          = new Border(1, Color.White),
                Padding         = new Spacer(2),
                Inner           = new Link
                {
                    TextColor = Color.Blue,
                    Font      = new FontInfo(TestFontFamily.Serif, 14, FontInfoStyle.Bold),
                    Text      = "How are you doing today?",
                    Uri       = "http://google.com"
                }
            });

            var textBox = new TextBox();

            textBox.AddComponent(new Label {
                Text = "Hello!\n", TextColor = Color.Green, Font = new FontInfo(TestFontFamily.Monospace, 20, FontInfoStyle.Underline)
            });
            textBox.AddComponent(new Label {
                Text = "Hi Bob, nice to see you after", TextColor = Color.Black, Font = new FontInfo(TestFontFamily.SansSerif, 10)
            });
            textBox.AddComponent(new Label {
                Text = "20", TextColor = Color.Red, Font = new FontInfo(TestFontFamily.SansSerif, 10, FontInfoStyle.Bold)
            });
            textBox.AddComponent(new Label {
                Text = "years!\n", TextColor = Color.Black, Font = new FontInfo(TestFontFamily.SansSerif, 10)
            });
            textBox.AddComponent(new Label {
                Text = "I'm sure you'd love to see my new", TextColor = Color.Black, Font = new FontInfo(TestFontFamily.SansSerif, 10)
            });
            textBox.AddComponent(new Link {
                Text = "web", TextColor = Color.Blue, Font = new FontInfo(TestFontFamily.SansSerif, 12, FontInfoStyle.Italic), Uri = "http://google.com"
            });
            textBox.AddComponent(new Link {
                Text = "site", TextColor = Color.Green, TextContinuation = true, Font = new FontInfo(TestFontFamily.SansSerif, 12, FontInfoStyle.Italic), Uri = "http://google.com"
            });
            content.AddComponent(new Panel
            {
                Width           = SizeUnit.Unlimited,
                Height          = SizeUnit.Unlimited,
                BackgroundColor = Color.LightYellow,
                Margin          = new Spacer(1),
                Border          = new Border(1, Color.White),
                Padding         = new Spacer(2),
                Inner           = textBox
            });

            var form = new Form(content);

            var bmp = new Bitmap(320, 400);

            renderer.Render(form, bmp);
            BitmapComparer.CompareBitmaps("text_box", bmp);
        }