Exemplo n.º 1
0
        // add push button box field for fields of the PDF document
        // with common parameters and default names.
        //
        public static PdfPushButton RenderPushButton(C1PdfDocument pdf, string text, Font font, Rect rc, Color back, Color fore, string toolTip, Image image, ButtonLayout layout)
        {
            // create
            string        name       = string.Format("ACFPB{0}", _pushButtonCount + 1);
            PdfPushButton pushButton = new PdfPushButton();

            // parameters
            pushButton.Name         = name;
            pushButton.DefaultValue = text;
            pushButton.Value        = text;
            pushButton.Font         = font;
            pushButton.ToolTip      = string.IsNullOrEmpty(toolTip) ? string.Format("{0} ({1})", text, name) : toolTip;
            if (back != Colors.Transparent)
            {
                pushButton.BackColor = back;
            }
            if (fore != Colors.Transparent)
            {
                pushButton.ForeColor = fore;
            }

            // icon
            if (image != null)
            {
                //    pushButton.Image = image;
                //    pushButton.Layout = layout;
            }

            // add
            pdf.AddField(pushButton, rc);
            _pushButtonCount++;

            // done
            return(pushButton);
        }
Exemplo n.º 2
0
        // add list box field for fields of the PDF document
        // with common parameters and default names.
        //
        static PdfListBox RenderListBox(C1PdfDocument pdf, string[] list, int activeIndex, Font font, Rect rc, Color back, string toolTip)
        {
            // create
            string     name    = string.Format("ACFLB{0}", _listBoxCount + 1);
            PdfListBox listBox = new PdfListBox();

            // default border
            listBox.BorderWidth = FieldBorderWidth.Thin;
            listBox.BorderStyle = FieldBorderStyle.Solid;
            listBox.BorderColor = Colors.DarkGray;

            // array
            foreach (string text in list)
            {
                listBox.Items.Add(text);
            }

            // parameters
            listBox.Font         = font;
            listBox.Name         = name;
            listBox.DefaultValue = activeIndex;
            listBox.Value        = activeIndex;
            listBox.ToolTip      = string.IsNullOrEmpty(toolTip) ? string.Format("{0} ({1})", string.Format("Count = {0}", listBox.Items.Count), name) : toolTip;
            if (back != Colors.Transparent)
            {
                listBox.BackColor = back;
            }

            // add
            pdf.AddField(listBox, rc);
            _listBoxCount++;

            // done
            return(listBox);
        }
Exemplo n.º 3
0
        // add radio button box field for fields of the PDF document
        // with common parameters and default names.
        //
        public static PdfRadioButton RenderRadioButton(C1PdfDocument pdf, bool value, string group, string text, Font font, Rect rc, Color back, string toolTip)
        {
            // create
            string         name        = string.IsNullOrEmpty(group) ? "ACFRGR" : group;
            PdfRadioButton radioButton = new PdfRadioButton();

            // parameters
            radioButton.Name         = name;
            radioButton.DefaultValue = value;
            radioButton.Value        = value;
            radioButton.ToolTip      = string.IsNullOrEmpty(toolTip) ? string.Format("{0} ({1})", text, name) : toolTip;
            if (back != Colors.Transparent)
            {
                radioButton.BackColor = back;
            }

            // add
            var radioSize = font.Size;
            var radioTop  = rc.Top + (rc.Height - radioSize) / 2;

            pdf.AddField(radioButton, new Rect(rc.Left, radioTop, radioSize, radioSize));
            _radioButtonCount++;

            // text for radio button field
            var x = rc.Left + radioSize + 1.0f;
            var y = rc.Top + (rc.Height - radioSize - 1.0f) / 2;

            pdf.DrawString(text, new Font(font.Name, radioSize, font.Style), Colors.Black, new Point(x, y));

            // done
            return(radioButton);
        }
Exemplo n.º 4
0
        // add text box field for fields of the PDF document
        // with common parameters and default names.
        //
        static PdfTextBox RenderTextBox(C1PdfDocument pdf, string text, Font font, Rect rc, Color back, string toolTip)
        {
            // create
            string     name    = string.Format("ACFTB{0}", _textBoxCount + 1);
            PdfTextBox textBox = new PdfTextBox();

            // default border
            //textBox.BorderWidth = 3f / 4;
            textBox.BorderStyle = FieldBorderStyle.Solid;
            textBox.BorderColor = Colors.DarkGray;

            // parameters
            textBox.Font        = font;
            textBox.Name        = name;
            textBox.DefaultText = text;
            textBox.Text        = text;
            textBox.ToolTip     = string.IsNullOrEmpty(toolTip) ? string.Format("{0} ({1})", text, name) : toolTip;
            if (back != Colors.Transparent)
            {
                textBox.BackColor = back;
            }

            // add
            pdf.AddField(textBox, rc);
            _textBoxCount++;

            // done
            return(textBox);
        }
Exemplo n.º 5
0
        // add check box field for fields of the PDF document
        // with common parameters and default names.
        //
        static PdfCheckBox RenderCheckBox(C1PdfDocument pdf, bool value, string text, Font font, Rect rc, Color back, string toolTip)
        {
            // create
            string      name     = string.Format("ACFCB{0}", _checkBoxCount + 1);
            PdfCheckBox checkBox = new PdfCheckBox();

            // default border
            checkBox.BorderWidth = FieldBorderWidth.Thin;
            checkBox.BorderStyle = FieldBorderStyle.Solid;
            checkBox.BorderColor = Colors.DarkGray;

            // parameters
            checkBox.Name         = name;
            checkBox.DefaultValue = value;
            checkBox.Value        = value;
            checkBox.ToolTip      = string.IsNullOrEmpty(toolTip) ? string.Format("{0} ({1})", text, name) : toolTip;
            if (back != Colors.Transparent)
            {
                checkBox.BackColor = back;
            }

            // add
            var checkBoxSize = font.Size;
            var checkBoxTop  = rc.Top + (rc.Height - checkBoxSize) / 2;

            pdf.AddField(checkBox, new Rect(rc.Left, checkBoxTop, checkBoxSize, checkBoxSize));
            _checkBoxCount++;

            // text for check box field
            var x = rc.Left + checkBoxSize + 1.0f;
            var y = rc.Top + (rc.Height - checkBoxSize - 1.0f) / 2;

            pdf.DrawString(text, new Font(font.Name, checkBoxSize, font.Style), Colors.Black, new Point(x, y));

            // done
            return(checkBox);
        }