示例#1
0
        public void SaveLoadTest()
        {
            //Create a new text document
            TextDocument document = new TextDocument();

            document.New();

            Paragraph p = new Paragraph(document);

            p.StyleName = "Standard";
            ODFForm main_form = new ODFForm(document, "mainform");

            main_form.Method = Method.Get;
            ODFFrame frm = new ODFFrame(main_form, p.Content, "frm", "5mm", "5mm", "5cm", "3cm");

            frm.Label = "Save and Load test";
            main_form.Controls.Add(frm);

            ODFButton butt = new ODFButton(main_form, p.Content, "butt", "1cm", "15mm", "4cm", "1cm");

            butt.Label = "A simple button :)";
            main_form.Controls.Add(butt);

            document.Forms.Add(main_form);
            document.Content.Add(p);

            document.SaveTo(AARunMeFirstAndOnce.outPutFolder + "saveload.odt");

            document.Load(AARunMeFirstAndOnce.outPutFolder + "saveload.odt");
            ODFButton bt = document.FindControlById("butt") as ODFButton;

            Assert.IsNotNull(bt, "Could not find control with >butt< ID");
            bt.Label = "This label has chanhed";
            document.SaveTo(AARunMeFirstAndOnce.outPutFolder + "saveload2.odt");
        }
示例#2
0
        public void NestedFormTest()
        {
            //Create a new text document
            TextDocument document = new TextDocument();

            document.New();

            // Create a main paragraph
            Paragraph p = new Paragraph(document);
            // Create a main form
            ODFForm main_form  = new ODFForm(document, "mainform");
            ODFForm child_form = new ODFForm(document, "childform");

            main_form.Method = Method.Get;
            main_form.Method = Method.Get;

            // Create a frame
            ODFFrame frm = new ODFFrame(main_form, p.Content, "frm", "5mm", "5mm", "5cm", "3cm");

            frm.Label = "Main form";
            // Add the frame to the form control list
            main_form.Controls.Add(frm);

            // Create a button
            ODFButton butt = new ODFButton(main_form, p.Content, "butt", "1cm", "15mm", "4cm", "1cm");

            butt.Label = "This is a main form";
            // Add the button to the form control list
            main_form.Controls.Add(butt);

            // Add the forms to the main form!
            document.Forms.Add(main_form);
            // Add the paragraph to the content list
            document.Content.Add(p);


            // adding controls to the nested form
            ODFFrame frm_child = new ODFFrame(child_form, p.Content, "frm_child", "5mm", "35mm", "5cm", "3cm");

            frm_child.Label = "Child form";
            child_form.Controls.Add(frm_child);

            ODFButton butt_child = new ODFButton(child_form, p.Content, "butt_child", "1cm", "45mm", "4cm", "1cm");

            butt_child.Label = "This is a child form";
            child_form.Controls.Add(butt_child);
            main_form.ChildForms.Add(child_form);

            ODFButton b = document.FindControlById("butt_child") as ODFButton;

            Assert.IsNotNull(b, "Error! could not find the specified control");
            b.Label = "Child form:)";


            // Add the forms to the main form!
            document.Forms.Add(main_form);
            // Add the paragraph to the content list
            document.Content.Add(p);

            document.SaveTo(AARunMeFirstAndOnce.outPutFolder + "nested_forms_test.odt");
            document.Load(AARunMeFirstAndOnce.outPutFolder + "nested_forms_test.odt");
            document.SaveTo(AARunMeFirstAndOnce.outPutFolder + "nested_forms_test2.odt");
        }
示例#3
0
        private void menuItem3_Click(object sender, System.EventArgs e)
        {
            if (openFileDialog1.ShowDialog() == DialogResult.OK)
            {
                textDocument.Load(openFileDialog1.FileName);

                ODFTextArea name = textDocument.FindControlById("name") as ODFTextArea;
                if (name != null)
                {
                    eName.Text = name.CurrentValue;
                }
                else
                {
                    MessageBox.Show("");
                }
                ODFTextArea surname = textDocument.FindControlById("surname") as ODFTextArea;
                if (surname != null)
                {
                    eSurname.Text = surname.CurrentValue;
                }

                ODFListBox gender = textDocument.FindControlById("gender") as ODFListBox;
                if (gender != null)
                {
                    ODFOption opt = gender.GetOptionByLabel("Male");
                    if (opt != null)
                    {
                        if (opt.CurrentSelected == XmlBoolean.True)
                        {
                            eGender.SelectedIndex = 0;
                        }
                    }

                    opt = gender.GetOptionByLabel("Female");
                    if (opt != null)
                    {
                        if (opt.CurrentSelected == XmlBoolean.True)
                        {
                            eGender.SelectedIndex = 1;
                        }
                    }
                }

                ODFFormattedText age = textDocument.FindControlById("age") as ODFFormattedText;
                if (age != null)
                {
                    eAge.Value = int.Parse(age.CurrentValue);
                }

                ODFTextArea addinfo = textDocument.FindControlById("addinfo") as ODFTextArea;
                if (addinfo != null)
                {
                    eAdditional.Text = addinfo.CurrentValue;
                }

                ODFCheckBox usesaodl = textDocument.FindControlById("usesaodl") as ODFCheckBox;
                if (usesaodl != null)
                {
                    eUsesAODL.Checked = (usesaodl.CurrentState == State.Checked);
                }

                lastOpenedFile = openFileDialog1.FileName;
            }
        }