private void rightClick(object sender, MouseEventArgs e)
 {
     if (!locked && e.Button == MouseButtons.Right)
     {
         using (FormEditor_ChangeType form = new FormEditor_ChangeType())
         {
             form.StartPosition = FormStartPosition.Manual;
             form.Location = new System.Drawing.Point(Cursor.Position.X, Cursor.Position.Y);
             form.ShowDialog();
             if (form.DialogResult == DialogResult.Yes)
             {
                 switch (form.result)
                 {
                     case "Textbox":
                         CustomTextboxLabel textBox = new CustomTextboxLabel();
                         textBox.textBox.Multiline = false;
                         textBox.pdfAttribute = this.pdfAttribute;
                         textBox.label.Text = rememberName;
                         textBox.Draggable(true);
                         Parent.Controls.Add(textBox);
                         textBox.Location = this.Location;
                         textBox.Width = textBox.label.Width + textBox.textBox.Width;
                         Parent.Controls.Remove(this);
                         break;
                     case "BigTextbox":
                         CustomTextboxLabel multitextBox = new CustomTextboxLabel();
                         multitextBox.textBox.Multiline = true;
                         multitextBox.pdfAttribute = this.pdfAttribute;
                         multitextBox.label.Text = rememberName;
                         multitextBox.Height = 78;
                         multitextBox.Draggable(true);
                         Parent.Controls.Add(multitextBox);
                         multitextBox.Location = this.Location;
                         multitextBox.Width = multitextBox.label.Width + multitextBox.textBox.Width;
                         Parent.Controls.Remove(this);
                         break;
                     case "Combobox":
                         break;
                     case "Checkbox":
                         EditableCheckbox checkbox = new EditableCheckbox();
                         checkbox.Text = rememberName;
                         checkbox.pdfAttribute = this.pdfAttribute;
                         checkbox.Parent = this.Parent;
                         checkbox.Draggable(true);
                         Parent.Controls.Add(checkbox);
                         checkbox.Location = this.Location;
                         Parent.Controls.Remove(this);
                         break;
                     default:
                         break;
                 }
             }
         }
     }
 }
        private void loadForm()
        {
            query = "select FormID from forms where Path=\"" + Path.GetFileName(loadedPdf) + "\" and Hardcoded=0";
            String formID = database.SelectString(query);
            query = "select * from CustomForms where FormID=" + formID;
            form = database.GetTable(query);

            String[] bigDelimit = new String[] { "-&" };
            String[] delimits = new String[] { "-;" };

            // Labels
            String temp = form.Rows[0]["Labels"].ToString();
            String[] results = temp.Split(bigDelimit, StringSplitOptions.None);
            foreach (String s in results)
            {
                if (s != "")
                {
                    String[] subResults = s.Split(delimits, StringSplitOptions.None);
                    EditableLabel newLabel = new EditableLabel();
                    newLabel.Name = subResults[0];
                    newLabel.Text = subResults[1];
                    newLabel.Draggable(true);
                    Controls.Add(newLabel);
                    newLabel.Location = new Point(Convert.ToInt32(subResults[2]), Convert.ToInt32(subResults[3]));
                }
            }

            // Textboxes
            temp = form.Rows[0]["Textboxes"].ToString();
            results = temp.Split(bigDelimit, StringSplitOptions.None);
            foreach (String s in results)
            {
                if (s != "")
                {
                    String[] subResults = s.Split(delimits, StringSplitOptions.None);
                    CustomTextboxLabel newTextbox = new CustomTextboxLabel();
                    newTextbox.pdfAttribute = subResults[0];
                    newTextbox.Name = subResults[0];
                    newTextbox.label.Text = subResults[1];
                    if (subResults[2].Equals("True"))
                    {
                        newTextbox.textBox.Multiline = true;
                        newTextbox.Height = 78;
                    }
                    newTextbox.Draggable(true);
                    Controls.Add(newTextbox);
                    newTextbox.Width = newTextbox.label.Width + newTextbox.textBox.Width;
                    newTextbox.Location = new Point(Convert.ToInt32(subResults[3]), Convert.ToInt32(subResults[4]));
                }
            }

            // Comboboxes
            temp = form.Rows[0]["Comboboxes"].ToString();
            results = temp.Split(bigDelimit, StringSplitOptions.None);
            foreach (String s in results)
            {
                if (s != "")
                {
                    String[] subResults = s.Split(delimits, StringSplitOptions.None);
                    EditableCombobox newCombobox = new EditableCombobox();
                    newCombobox.pdfAttribute = subResults[0];
                    newCombobox.Name = subResults[0];
                    newCombobox.rememberName = subResults[0];

                    foreach (String line in subResults[3].Split(new string[] { "\r\n", "\n" }, StringSplitOptions.None))
                    {
                        newCombobox.combobox.Items.Add(line);
                    }
                    if (newCombobox.combobox.Items.Count > 0)
                        newCombobox.combobox.SelectedIndex = 0;
                    newCombobox.Draggable(true);
                    Controls.Add(newCombobox);
                    newCombobox.resizeBox();
                    newCombobox.Location = new Point(Convert.ToInt32(subResults[1]), Convert.ToInt32(subResults[2]));
                }
            }

            // Checkboxes
            temp = form.Rows[0]["Checkboxes"].ToString();
            results = temp.Split(bigDelimit, StringSplitOptions.None);
            foreach (String s in results)
            {
                if (s != "")
                {
                    String[] subResults = s.Split(delimits, StringSplitOptions.None);
                    EditableCheckbox newCheckbox = new EditableCheckbox();
                    newCheckbox.pdfAttribute = subResults[0];
                    newCheckbox.Name = subResults[0];
                    newCheckbox.checkbox.Text = subResults[1];
                    newCheckbox.Draggable(true);
                    Controls.Add(newCheckbox);
                    newCheckbox.Location = new Point(Convert.ToInt32(subResults[2]), Convert.ToInt32(subResults[3]));
                }
            }

            query = "select FormName, Panel from forms where FormID=" + formID;
            form = database.GetTable(query);

            IMPORTANTYESTitleBox.Text = form.Rows[0]["FormName"].ToString();
            IMPORTANTYESPanelChoiceBox.SelectedIndex = panelIndex;
        }
        private void loadPdf()
        {
            int rowModifier = 30;
            int column = 1;
            int middleColumn = Convert.ToInt32(0.4 * ClientRectangle.Width);
            IMPORTANTYESTitleBox.Text = Path.GetFileName(loadedPdf);

            if (preload)
            {
                if (loadedPdf.Contains(".pdf"))
                {
                    PdfReader pdfReader = new PdfReader(loadedPdf);

                    foreach (var field in pdfReader.AcroFields.Fields)
                    {
                        CustomTextboxLabel newField = new CustomTextboxLabel();
                        newField.attrName(field.Key);
                        newField.pdfAttribute = field.Key;
                        newField.Name = field.Key;
                        newField.Draggable(true);

                        Controls.Add(newField);
                        newField.Width = newField.label.Width + newField.textBox.Width;

                        switch (column)
                        {
                            case 1:
                                newField.Location = gridify(new Point(5, rowModifier));
                                column = 2;
                                break;
                            case 2:
                                newField.Location = gridify(new Point(middleColumn, rowModifier));
                                column = 3;
                                break;
                            case 3:
                                newField.Location = gridify(new Point(ClientRectangle.Width - newField.Width, rowModifier));
                                rowModifier += 50;
                                column = 1;
                                break;
                            default:
                                break;
                        }
                    }
                }
            }
        }
예제 #4
0
        private void grabForm(object sender, EventArgs e)
        {
            newFile = Convert.ToString(rng.Next(int.MaxValue)) + ".pdf";
            query = "select * from ClientInfo where ClientID=" + client;
            clientInfo = database.GetTable(query);

            query = "select Path from forms where FormID=" + loadFormID;
            templatePDF += database.SelectString(query);

            if (!File.Exists(templatePDF))
            {
                MessageBox.Show("There was an error finding " + form.Rows[0]["Path"].ToString() + "!");
                this.Close();
            }

            query = "select * from CustomForms where FormID=" + loadFormID;
            form = database.GetTable(query);

            String[] bigDelimit = new String[] { "-&" };
            String[] delimits = new String[] { "-;" };

            // Labels
            String temp = form.Rows[0]["Labels"].ToString();
            String[] results = temp.Split(bigDelimit, StringSplitOptions.None);
            foreach (String s in results)
            {
                if (s != "")
                {
                    String[] subResults = s.Split(delimits, StringSplitOptions.None);
                    EditableLabel newLabel = new EditableLabel();
                    newLabel.Name = subResults[0];
                    newLabel.Text = subResults[1];
                    newLabel.locked = true;
                    newLabel.Draggable(false);
                    Controls.Add(newLabel);
                    newLabel.Location = new Point(Convert.ToInt32(subResults[2]), Convert.ToInt32(subResults[3]));
                }
            }

            // Textboxes
            temp = form.Rows[0]["Textboxes"].ToString();
            results = temp.Split(bigDelimit, StringSplitOptions.None);
            foreach (String s in results)
            {
                if (s != "")
                {
                    String[] subResults = s.Split(delimits, StringSplitOptions.None);
                    CustomTextboxLabel newTextbox = new CustomTextboxLabel();
                    newTextbox.pdfAttribute = subResults[0];
                    newTextbox.Name = subResults[0];
                    newTextbox.locked = true;
                    newTextbox.label.Text = subResults[1];
                    if (subResults[2].Equals("True"))
                    {
                        newTextbox.textBox.Multiline = true;
                        newTextbox.Height = 78;
                    }
                    newTextbox.Draggable(false);
                    Controls.Add(newTextbox);
                    newTextbox.Width = newTextbox.label.Width + newTextbox.textBox.Width;
                    newTextbox.Location = new Point(Convert.ToInt32(subResults[3]), Convert.ToInt32(subResults[4]));
                }
            }

            // Comboboxes
            temp = form.Rows[0]["Comboboxes"].ToString();
            results = temp.Split(bigDelimit, StringSplitOptions.None);
            foreach (String s in results)
            {
                if (s != "")
                {
                    String[] subResults = s.Split(delimits, StringSplitOptions.None);
                    ComboBoxer newCombobox = new ComboBoxer();
                    newCombobox.pdfAttribute = subResults[0];
                    newCombobox.Name = subResults[0];
                    newCombobox.DropDownStyle = ComboBoxStyle.DropDownList;
                    foreach (String line in subResults[3].Split(new string[] { "\r\n", "\n" }, StringSplitOptions.None))
                    {
                        newCombobox.Items.Add(line);
                    }
                    if (newCombobox.Items.Count > 0)
                        newCombobox.SelectedIndex = 0;
                    newCombobox.Draggable(false);
                    Controls.Add(newCombobox);
                    newCombobox.resizeBox();
                    newCombobox.Location = new Point(Convert.ToInt32(subResults[1]), Convert.ToInt32(subResults[2]));
                }
            }

            // Checkboxes
            temp = form.Rows[0]["Checkboxes"].ToString();
            results = temp.Split(bigDelimit, StringSplitOptions.None);
            foreach (String s in results)
            {
                if (s != "")
                {
                    String[] subResults = s.Split(delimits, StringSplitOptions.None);
                    CheckBoxer newCheckbox = new CheckBoxer();
                    newCheckbox.pdfAttribute = subResults[0];
                    newCheckbox.Name = subResults[0];
                    newCheckbox.Text = subResults[1];
                    newCheckbox.Draggable(false);
                    Controls.Add(newCheckbox);
                    newCheckbox.Location = new Point(Convert.ToInt32(subResults[2]), Convert.ToInt32(subResults[3]));
                }
            }

            query = "select FormName, Panel from forms where FormID=" + loadFormID;
            form = database.GetTable(query);

            IMPORTANTYESTitleBox.Text = form.Rows[0]["FormName"].ToString();
            this.Text = IMPORTANTYESTitleBox.Text;
        }