public void TestComposite()
        {
            var form = new Form();

            form.AddElement(new InputElement());
            form.AddElement(new TextElement());

            var embeddedForm = new Form();

            embeddedForm.AddElement(new InputElement());
            embeddedForm.AddElement(new TextElement());

            form.AddElement(embeddedForm);

            const string ExpectedOutput = "<form>\r\n" +
                                          "    <input type=\"text\" />\r\n" +
                                          "    Text element\r\n" +
                                          "    <form>\r\n" +
                                          "        <input type=\"text\" />\r\n" +
                                          "        Text element\r\n" +
                                          "    </form>\r\n" +
                                          "</form>\r\n";

            Assert.That(form.Render(), Is.EqualTo(ExpectedOutput));
        }
Beispiel #2
0
        public static DialogResult Show(string text)
        {
            Form form = new Form {Title = "Message", HasBorder = true, Width = 40, Height = 10};

            Label label = new Label {Text = text, Right = 0, Top = 0, Width = 38, Height = 6, Enabled = false};
            Button buttonOK = new Button("OK") {Right = 18, Top = 7};

            DialogResult result = DialogResult.None;

            buttonOK.ButtonClick += (sender, args) =>
            {
                result = DialogResult.OK;
                form.Dispose();
            };

            form.AddElement(label);
            form.AddElement(buttonOK);

            form.Init();
            form.Execute();

            return result;
        }
        /// <summary>
        /// Called by loadContents to load an input tag on the form.
        /// </summary>
        /// <param name="index">The index to begin loading at.</param>
        /// <param name="tag">The beginning tag.</param>
        protected void LoadInput(int index, Tag tag)
        {
            String type  = tag.GetAttributeValue("type");
            String name  = tag.GetAttributeValue("name");
            String value = tag.GetAttributeValue("value");

            var input = new Input(_page);

            input.Type  = type;
            input.Name  = name;
            input.Value = value;

            if (_lastForm != null)
            {
                _lastForm.AddElement(input);
            }
            else
            {
                _page.AddContent(input);
            }
        }