public AcroFormComboBox(AcroFormChoice Parent) : base(Parent)
 {
     this.Options           = Parent.Options;
     this.MultiSelect       = Parent.MultiSelect;
     this.CanEdit           = Parent.CanEdit;
     this.CommitOnSelChange = Parent.CommitOnSelChange;
     this.DoNotSpellCheck   = Parent.DoNotSpellCheck;
     this.Sort  = Parent.Sort;
     this.Value = Parent.Value;
 }
 public AcroFormListBox(AcroFormChoice Parent) : base(Parent)
 {
 }
Esempio n. 3
0
        private static AcroForm[] ProcessForm(string sAcroFormsXml)
        {
            // new XML document to load the resulting XML
            XmlDocument xmlDocument;

            xmlDocument = new XmlDocument();
            xmlDocument.LoadXml(sAcroFormsXml);

            // create a new list of AcroForm elements
            List <AcroForm> lAcroForm = new List <AcroForm>();

            // loop through the XML and get all AcroForm nodes
            foreach (System.Xml.XmlElement xmlElement in
                     xmlDocument.DocumentElement.SelectNodes("AcroForms/AcroForm"))
            {
                // read the XML node
                XmlReader xmlReader = XmlReader.Create(new StringReader(xmlElement.OuterXml));

                // create an XML proxy class according to the XML node
                XmlSerializer s   = new XmlSerializer(typeof(XmlAcroForm), new XmlRootAttribute("AcroForm"));
                XmlAcroForm   obj = (XmlAcroForm)s.Deserialize(xmlReader);

                // create a new AcroForm object
                AcroForm newAcroForm = new AcroForm()
                {
                    AlternateFieldName = obj.AlternateFieldName,
                    FieldName          = obj.FieldName,
                    FieldRect          = obj.FieldRect,
                    FieldType          = obj.FieldType
                };

                // switch between field types
                switch (obj.FieldType)
                {
                case FieldType.Tx:

                    AcroFormTextField newAcroFormTextField = new AcroFormTextField(newAcroForm);
                    newAcroFormTextField.Value = obj.FieldValue;

                    lAcroForm.Add(newAcroFormTextField);

                    break;

                case FieldType.Btn:                                   // in case of a button

                    if (obj.ButtonFieldFlags.IsPushbutton == false && // Case CheckBox
                        obj.ButtonFieldFlags.IsRadio == false)
                    {
                        AcroFormCheckBox newAcroFormCheckBox = new AcroFormCheckBox(newAcroForm);
                        newAcroFormCheckBox.IsChecked = "Yes".Equals(obj.FieldValue);

                        lAcroForm.Add(newAcroFormCheckBox);
                    }
                    else if (obj.ButtonFieldFlags.IsPushbutton)     // Case PushButton
                    {
                        AcroFormButton newAcroFormButton = new AcroFormButton(newAcroForm);

                        lAcroForm.Add(newAcroFormButton);
                    }
                    else if (obj.ButtonFieldFlags.IsRadio)     // Case RadioButton
                    {
                        AcroFormRadioButton newAcroFormRadioButton = new AcroFormRadioButton(newAcroForm);
                        newAcroFormRadioButton.IsChecked = "Yes".Equals(obj.FieldValue);

                        lAcroForm.Add(newAcroFormRadioButton);
                    }

                    break;

                case FieldType.Ch:     // in case of a choice element

                    AcroFormChoice newAcroFormChoice = new AcroFormChoice(newAcroForm);

                    // set all properties 1:1
                    newAcroFormChoice.Options           = obj.ChoiceFieldOptions.ChoiceFieldElements;
                    newAcroFormChoice.Sort              = obj.ChoiceFieldFlags.Sort;
                    newAcroFormChoice.DoNotSpellCheck   = obj.ChoiceFieldFlags.DoNotSpellCheck;
                    newAcroFormChoice.CanEdit           = obj.ChoiceFieldFlags.CanEdit;
                    newAcroFormChoice.CommitOnSelChange = obj.ChoiceFieldFlags.CommitOnSelChange;
                    newAcroFormChoice.MultiSelect       = obj.ChoiceFieldFlags.MultiSelect;
                    newAcroFormChoice.Value             = obj.FieldValue;

                    if (obj.ChoiceFieldFlags.IsComboBox)     // Case ComboBox
                    {
                        AcroFormComboBox newAcroFormComboBox = new AcroFormComboBox(newAcroFormChoice);
                        lAcroForm.Add(newAcroFormComboBox);
                    }
                    else     // Case ListBox
                    {
                        AcroFormListBox newAcroFormListBox = new AcroFormListBox(newAcroFormChoice);
                        lAcroForm.Add(newAcroFormListBox);
                    }

                    break;
                }
            }

            // return the array of elements
            return(lAcroForm.ToArray());
        }