Exemplo n.º 1
0
 public void Draw(Graphics g, ICardSubject subject)
 {
     drawBackground(g);
     drawPhoto(g, subject);
     drawBarCode(g, subject);
     drawDivision(g, subject);
     drawDetails(g, subject);
     drawExpiry(g);
 }
Exemplo n.º 2
0
        private void drawBarCode(Graphics g, ICardSubject subject)
        {
            var barcodeFont = new Font("Free 3 of 9 Extended", 25f);
            var textFont = new Font("Arial", 9f, FontStyle.Bold);
            var textFormat = new StringFormat() { Alignment = StringAlignment.Center };
            var identifier = $"*{subject.Identifier}*";
            var barcodeRect = new RectangleF()
            {
                X = CardWidth - g.MeasureString(identifier, barcodeFont).Width - Padding.Right,
                Y = ImageHeight + Padding.Top + Padding.Top,
                Width = g.MeasureString(identifier, barcodeFont).Width,
                Height = g.MeasureString(identifier, barcodeFont).Height
            };
            var borderRect = RectangleF.Inflate(barcodeRect, 3, 3);
            var textRect = new RectangleF()
            {
                X = borderRect.X,
                Y = borderRect.Y + borderRect.Height - LineSpacing,
                Width = borderRect.Width,
                Height = g.MeasureString(subject.Identifier, textFont).Height
            };

            g.DrawRectangle(new Pen(Brushes.Black, 2f), Rectangle.Truncate(borderRect));
            g.DrawString(identifier, barcodeFont, Brushes.Black, barcodeRect);
            g.DrawString(subject.Identifier, textFont, Brushes.Black, textRect, textFormat);
        }
Exemplo n.º 3
0
 private void drawDivision(Graphics g, ICardSubject subject)
 {
     StringFormat format = new StringFormat() { Alignment = StringAlignment.Near };
     var font = new Font("Ariel", 7f, FontStyle.Bold);
     var division = subject.Division;
     Func<int, RectangleF> rectForLine = (lineNumber) =>
     {
         return new RectangleF()
         {
             X = Padding.Left,
             Y = Padding.Top + ImageHeight - LineHeight + lineNumber * (LineSpacing + LineHeight),
             Width = CardWidth,
             Height = LineHeight
         };
     };
     g.DrawString(division.Street, font, Brushes.Black, rectForLine(0), format);
     g.DrawString($"{division.City}, {division.Code}", font, Brushes.Black, rectForLine(1), format);
     g.DrawString("Tel: " + division.Telephone, font, Brushes.Black, rectForLine(2), format);
     g.DrawString("Fax: " + division.Fax, font, Brushes.Black, rectForLine(3), format);
     g.DrawString("Email: " + division.Email, font, Brushes.Black, rectForLine(4), format);
     g.DrawString("Website: " + Properties.Settings.Default.Website, font, Brushes.Black, rectForLine(5), format);
     g.DrawString("Branch: " + division.Name, font, Brushes.Black, rectForLine(6), format);
 }
Exemplo n.º 4
0
        private void drawPhoto(Graphics g, ICardSubject subject)
        {
            var black = Brushes.Black;
            var imageRect = new RectangleF()
            {
                X = (CardWidth - ImageWidth) - Padding.Right,
                Y = Padding.Top,
                Width = ImageWidth,
                Height = ImageHeight
            };
            var borderRect = Rectangle.Inflate(Rectangle.Truncate(imageRect), 1, 1);

            g.DrawImage(subject.Image, imageRect);
            //g.DrawRectangle(new Pen(Color.Black, 0.4f), borderRect);
        }
Exemplo n.º 5
0
 private void drawDetails(Graphics g, ICardSubject subject)
 {
     StringFormat format = new StringFormat() { Alignment = StringAlignment.Near };
     var font = new Font("Ariel", 7f, FontStyle.Bold);
     Func<int, RectangleF> rectForLine = (lineNumber) =>
     {
         return new RectangleF()
         {
             X = Padding.Left,
             Y = CardHeight - Padding.Bottom - LineHeight - lineNumber * (LineHeight),
             Width = CardWidth,
             Height = LineHeight
         };
     };
     g.DrawString("NAME: " + subject.Name, font, Brushes.Black, rectForLine(1), format);
     g.DrawString("ID NUMBER: " + subject.IDNumber, font, Brushes.Black, rectForLine(0), format);
 }