Esempio n. 1
0
        public void Draw(XGraphics gfx)
        {
            gfx.DrawRectangle(Pen, Brush, Rect);

            double yOffset = 5;

            //Print InputBox Title, Left Top corner
            if (!string.IsNullOrEmpty(Title))
            {
                var titleLabel = new Label(Rect.X + 5, Rect.Y, Title)
                    {
                        Brush = XBrushes.Black,
                        Font = new XFont(Font.FontFamily.Name, 8, XFontStyle.Bold, Font.PdfOptions),
                        Pen = XPens.Black
                    };
                titleLabel.Draw(gfx);
                yOffset = 15;
            }

            //Print InputBox Value
            if (!string.IsNullOrEmpty(Value))
            {
                var valLabel = new Label(new XRect(Rect.X + 10, Rect.Y + yOffset, Rect.Width, Rect.Height), Value)
                    {
                        Alignment = XParagraphAlignment.Left,
                        Brush = XBrushes.Black,
                        Font = new XFont(Font.FontFamily.Name, 12, XFontStyle.Regular, Font.PdfOptions),
                        Pen = XPens.Black,
                    };
                valLabel.Draw(gfx);
                yOffset += valLabel.Rect.Height;
            }
        }
Esempio n. 2
0
        public void DrawTest()
        {
            var rect = new XRect(0, 0, 10, 40);
            var alignment = new XParagraphAlignment(); 
            string content = "foo"; 
            var target = new Label(alignment, content){Rect = rect};
            PdfDocument pdf = new PdfDocument();
            var page = pdf.AddPage();
            XGraphics gfx = XGraphics.FromPdfPage(page);

            target.Draw(gfx);
            Assert.AreEqual(target.Rect, rect);
        }
Esempio n. 3
0
        public void Draw(XGraphics gfx)
        {
            gfx.DrawRectangle(Pen, Brush, Rect);

            const double yOffset = 5;

            if (!string.IsNullOrEmpty(Value))
            {
                var valLabel = new Label(new XRect(Rect.X, Rect.Y + yOffset, Rect.Width, Rect.Height), Value)
                    {
                        Alignment = XParagraphAlignment.Center,
                        Brush = XBrushes.Black,
                        Font = new XFont(Font.FontFamily.Name, 12, XFontStyle.Regular, Font.PdfOptions),
                        Pen = XPens.Black,
                    };
                valLabel.Draw(gfx);
            }
        }
Esempio n. 4
0
        private void Draw(XGraphics gfx, IEnumerable<IControl> controls)
        {
            gfx.DrawRectangle(Pen, Brush, Rect);

            if (!String.IsNullOrEmpty(Title))
            {
                var titleLabel = new Label(Rect.X + 5, Rect.Y, Title)
                    {Brush = XBrushes.Black, Font = Font, Pen = XPens.Black};
                titleLabel.Draw(gfx);
            }

            if (controls.Any())
            {
                Rect = new XRect(Rect.X, Rect.Y, Rect.Width, _currentY + MarginTop + MarginBottom);
                double maxWidth = Rect.X + Rect.Width;

                //Adding margin for every control in Controls List
                foreach (IControl control in Controls)
                {
                    double x = Rect.X + control.Rect.X + MarginLeft;
                    double y = Rect.Y + control.Rect.Y + MarginTop;
                    double width = x + control.Rect.Width > maxWidth ? maxWidth - x : control.Rect.Width;
                    double height = control.Rect.Height;

                    control.Rect = new XRect(x, y, width, height);
                    control.Draw(gfx);
                }
            }
        }
Esempio n. 5
0
 public void AddChildTest()
 {
     var rect = new XRect();
     var target = new GroupBox(rect);
     IControl control = new Label(0, 0, "foo");
     target.AddChild(control);
     Assert.AreEqual(target.Controls.Count, 1);
 }