コード例 #1
0
        private void PDFTextBox_Paint(object sender, PaintEventArgs e)
        {
            UpdateControl();

            // Draw TextBox Border.
            FormFieldControl.DrawBorder(e.Graphics, this, this.ClientSize, _focus);
        }
コード例 #2
0
        public static void SetControlBorder(FormFieldControl fieldControl, RasterColor borderColor, int borderWidth, int borderStyle)
        {
            fieldControl.BorderThickness = borderWidth;
            fieldControl.BorderColor     = Color.FromArgb(borderColor.A, borderColor.R, borderColor.G, borderColor.B);

            switch (borderStyle)
            {
            case PDFFormField.BorderStyleSolid:
                fieldControl.FieldBorderStyle = FieldBorderStyle.Solid;
                break;

            case PDFFormField.BorderStyleDashed:
                fieldControl.FieldBorderStyle = FieldBorderStyle.Dashed;
                break;

            case PDFFormField.BorderStyleBeveled:
                fieldControl.FieldBorderStyle = FieldBorderStyle.Beveled;
                break;

            case PDFFormField.BorderStyleInset:
                fieldControl.FieldBorderStyle = FieldBorderStyle.Inset;
                break;

            case PDFFormField.BorderStyleUnderline:
                fieldControl.FieldBorderStyle = FieldBorderStyle.Underlined;
                break;
            }
        }
コード例 #3
0
ファイル: MainForm.cs プロジェクト: sakpung/webstudy
        private void _propertiesToolStripMenuItem_Click(object sender, EventArgs e)
        {
            FormFieldControl formFieldControl = _formFieldContextMenu.SourceControl.Tag as FormFieldControl;

            if (formFieldControl != null)
            {
                using (PDFFormFieldPropertiesDailog pdfFormFieldPropertiesDailog = new PDFFormFieldPropertiesDailog(formFieldControl))
                    pdfFormFieldPropertiesDailog.ShowDialog();
            }
        }
コード例 #4
0
        public static void SetControlFont(FormFieldControl fieldControl, string fontName, int fontSize, RasterColor textColor)
        {
            fontName = string.IsNullOrEmpty(fontName) ? "Arial" : fontName;

            fieldControl.AutoFontResize = (fontSize == -1 || fontSize == 0);

            fieldControl.Font = new Font(fontName, fieldControl.AutoFontResize ? FormFieldControl.MaxFontSize : fontSize);

            fieldControl.ForeColor = Color.FromArgb(textColor.A, textColor.R, textColor.G, textColor.B);
        }
コード例 #5
0
        private void PDFListBox_Paint(object sender, PaintEventArgs e)
        {
            if (!_isBorderStyleUpdated)
            {
                this.FieldBorderStyle = _fieldBorderStyle;
                _isBorderStyleUpdated = true;
            }

            // Draw ListBox Border.
            FormFieldControl.DrawBorder(e.Graphics, this, this.ClientSize, _focus);
        }
コード例 #6
0
        public static void SetControlBounds(FormFieldControl fieldControl, PDFRect bounds, int docResolution)
        {
            double pdfResolutionFactor = docResolution / 72.0;

            LeadRect rect = new LeadRect(
                (int)(bounds.Left * pdfResolutionFactor),
                (int)(bounds.Top * pdfResolutionFactor),
                (int)(bounds.Width * pdfResolutionFactor),
                (int)(bounds.Height * pdfResolutionFactor));

            fieldControl.FiedlBounds = rect;
        }
コード例 #7
0
        public static void SetControlBackground(FormFieldControl fieldControl, RasterColor fillColor, int fillMode)
        {
            if (fillMode == PDFFormField.FillModeFilled)
            {
                fieldControl.BackgroundColor = Color.FromArgb(fillColor.A, fillColor.R, fillColor.G, fillColor.B);
            }
            else
            {
                fieldControl.BackgroundColor = Color.White;
            }

            fieldControl.BackColor = Color.White;
        }
コード例 #8
0
ファイル: CheckFormField.cs プロジェクト: sakpung/webstudy
        protected override void OnPaint(PaintEventArgs e)
        {
            e.Graphics.Clear(this.BackColor);

            Rectangle innerRect      = new Rectangle((_borderThickness), (_borderThickness), this.ClientSize.Width - (_borderThickness * 2), this.ClientSize.Height - (_borderThickness * 2));
            Rectangle backgroundRect = new Rectangle((_borderThickness), (_borderThickness), this.ClientSize.Width - (_borderThickness * 2), this.ClientSize.Height - (_borderThickness * 2));

            switch (_fieldBorderStyle)
            {
            case FieldBorderStyle.Beveled:
                backgroundRect.Inflate(-this._borderThickness, -this._borderThickness);
                break;

            case FieldBorderStyle.Inset:
                backgroundRect.Inflate(-this._borderThickness, -this._borderThickness);
                break;

            case FieldBorderStyle.Underlined:
                backgroundRect = new Rectangle(0, 0, this.ClientSize.Width, this.ClientSize.Height - _borderThickness);
                break;
            }

            backgroundRect.Width  = backgroundRect.Width == 0 ? 1 : backgroundRect.Width;
            backgroundRect.Height = backgroundRect.Height == 0 ? 1 : backgroundRect.Height;

            // Draw CheckBox Border.
            FormFieldControl.DrawBorder(e.Graphics, this, this.ClientSize, _focus);

            // Draw Check Box Background.
            e.Graphics.FillRectangle(new SolidBrush(_backgroundColor), backgroundRect);

            // Draw Check Mark.
            if (this.Checked)
            {
                int       checkMarkHeight = innerRect.Height >= innerRect.Width ? innerRect.Width : innerRect.Height;
                Point     checkMarkOffset = new Point(innerRect.X + ((innerRect.Width - checkMarkHeight) / 2), innerRect.Y + ((innerRect.Height - checkMarkHeight) / 2));
                Rectangle checkMarkRect   = new Rectangle(checkMarkOffset.X, checkMarkOffset.Y, checkMarkHeight, checkMarkHeight);

                Font font = new Font("Verdana", checkMarkRect.Height, FontStyle.Bold);

                font = FitTextToControlHeight(font, checkMarkRect.Height);

                TextRenderer.DrawText(e.Graphics, "✓", font, new Point(checkMarkRect.X, checkMarkRect.Y), Color.Black);
            }
        }
コード例 #9
0
        public PDFFormFieldPropertiesDailog(FormFieldControl control)
        {
            InitializeComponent();

            foreach (FontFamily font in System.Drawing.FontFamily.Families)
            {
                _appearanceFontFamilyComboBox.Items.Add(font.Name);
            }

            if (control != null)
            {
                _formFieldControl = control;

                InitPropertiesControls();
            }

            this.FormClosing += PDFFormFieldPropertiesDailog_FormClosing;

            UpdateControls();
        }
コード例 #10
0
        private static FormFieldControl CreateFieldControl(PDFFormField field, int docResolution)
        {
            FormFieldControl formFieldControl = null;

            switch (field.FieldType)
            {
            case PDFFormField.FieldTypeCheckBox:
                if (((field.FieldFlags & PDFFormField.FieldFlagsButtonRadio) == PDFFormField.FieldFlagsButtonRadio) ||
                    ((field.FieldFlags & PDFFormField.FieldFlagsButtonRadioInUnison) == PDFFormField.FieldFlagsButtonRadioInUnison) ||
                    field.GroupId > 0)
                {
                    formFieldControl = CreateRadioButton(field);
                }
                else
                {
                    formFieldControl = new CheckFormField();
                }
                break;

            case PDFFormField.FieldTypeRadioButton:
                formFieldControl = CreateRadioButton(field);
                break;

            case PDFFormField.FieldTypeComboBox:
                formFieldControl = new ComboFormField();
                break;

            case PDFFormField.FieldTypeListBox:
                formFieldControl = new ListFormField();
                break;

            case PDFFormField.FieldTypeTextBox:
                formFieldControl = new TextFormField();
                break;
            }

            formFieldControl.DocResolution = docResolution;
            formFieldControl.InitControl(field);

            return(formFieldControl);
        }
コード例 #11
0
ファイル: ComboFormField.cs プロジェクト: sakpung/webstudy
        protected override void OnPaint(PaintEventArgs e)
        {
            e.Graphics.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias;

            // Draw ComboBox Border.
            FormFieldControl.DrawBorder(e.Graphics, this, this.Parent.Size, _focus);

            Rectangle innerRect = GetInnerRect();

            using (e.Graphics.Clip = new Region(innerRect))
            {
                // Draw Background Rectangle
                using (SolidBrush brush = new SolidBrush(this.BackgroundColor))
                {
                    e.Graphics.FillRectangle(brush, innerRect);
                }

                // Draw Selected Item String
                using (SolidBrush brush = new SolidBrush(this.ForeColor))
                {
                    string selectetItem = this.SelectedItem == null ? "" : this.SelectedItem.ToString();

                    string text = string.IsNullOrEmpty(ContentText) ? selectetItem : this.ContentText;

                    SizeF textSize = e.Graphics.MeasureString(text, this.Font);

                    float centerY = innerRect.Y + (innerRect.Height - textSize.Height) / 2;

                    e.Graphics.DrawString(text, this.Font, brush, innerRect.X, centerY);
                }

                // Draw Combo Button
                Rectangle comboButtonRect = new Rectangle(innerRect.X + innerRect.Width - 15, innerRect.Y, 15, innerRect.Height);

                ControlPaint.DrawComboButton(e.Graphics, comboButtonRect, ButtonState.Normal);
            }
        }
コード例 #12
0
        public static void SetControlFlagsProperties(FormFieldControl fieldControl, long viewFlags, long fieldFlags)
        {
            bool Hidden   = (viewFlags & PDFFormField.ViewFlagsHidden) == PDFFormField.ViewFlagsHidden;
            bool NoView   = (viewFlags & PDFFormField.ViewFlagsNoView) == PDFFormField.ViewFlagsNoView;
            bool Print    = (viewFlags & PDFFormField.ViewFlagsPrint) == PDFFormField.ViewFlagsPrint;
            bool Locked   = (viewFlags & PDFFormField.ViewFlagsLocked) == PDFFormField.ViewFlagsLocked;
            bool NoRotate = (viewFlags & PDFFormField.ViewFlagsNoRotate) == PDFFormField.ViewFlagsNoRotate;
            bool ReadOnly = (fieldFlags & PDFFormField.FieldFlagsReadOnly) == PDFFormField.FieldFlagsReadOnly;

            if (Hidden)
            {
                fieldControl.IsFieldVisible   = false;
                fieldControl.IsFieldPrintable = false;
            }
            else
            {
                if (NoView)
                {
                    fieldControl.IsFieldVisible = false;
                }
                else
                {
                    fieldControl.IsFieldVisible = true;
                }

                if (Print)
                {
                    fieldControl.IsFieldPrintable = true;
                }
                else
                {
                    fieldControl.IsFieldPrintable = false;
                }
            }

            if (Locked)
            {
                fieldControl.IsFieldLocked = true;
            }
            else
            {
                fieldControl.IsFieldLocked = false;
            }

            if (ReadOnly)
            {
                fieldControl.IsReadOnly = true;
            }
            else
            {
                fieldControl.IsReadOnly = false;
            }

            if (NoRotate)
            {
                fieldControl.IsFieldRotatable = false;
            }
            else
            {
                fieldControl.IsFieldRotatable = true;
            }
        }