Example #1
0
 /// <summary>
 /// Get form settings from name
 /// </summary>
 /// <returns></returns>
 public FormSettings GetForm(string formName)
 {
     if (forms.ContainsKey(formName))
     {
         return(forms[formName]);
     }
     else
     {
         FormSettings form = new FormSettings(formName);
         forms.Add(formName, form);
         return(form);
     }
 }
        public string Title  = null;            // similar to a tool tip

        /// <summary>
        /// Constructor
        /// </summary>
        /// <param name="path">path is "form-name/label-text"</param>
        /// <param name="getValue">lambda expression to get value</param>
        /// <param name="setValue">lambda expression to set value</param>
        public InputBase(string path, GetValueDelegate getValue, SetValueDelegate setValue)
        {
            ++idCounter;
            UniqueID = "input" + idCounter.ToString();

            // split path from "form-name/label-text"
            int index = path.LastIndexOf('/');

            Debug.Assert(-1 != index);

            Label = path.Substring(index + 1);
            string formName = path.Substring(0, index);

            GetValue = getValue;
            SetValue = setValue;

            // make sure the manager knows about this input
            Form = Manager.Instance.GetForm(formName);
            Manager.Instance.AddInput(this);
        }
Example #3
0
        /// <summary>
        /// Get specified form
        /// </summary>
        /// <param name="formName">name of form</param>
        /// <returns>html</returns>
        private string GetFormPage(string formName)
        {
            HtmlBuilder b = new HtmlBuilder();

            b.open("html");
            b.open("head");
            b.open("title");
            b.append(b.text(formName));
            b.close("title");
            b.open("style", b.attr("type", "text/css"));
            b.append("th	{text-align: right;}\n");
            b.append("td	{padding-left: 1em; text-align: left;}\n");
            b.close("style");
            b.include_js("scripts/slider.js");
            b.include_css("styles/slider.css");
            b.open("script", b.attr("type", "text/javascript"));
            b.append("function doclick(sel){\n");
            b.append("  sel.value=\"True\";\n");
            b.append("  sel.form.submit();\n");
            b.append("}\n");
            b.close("script");
            b.close("head");
            b.open("body");
            b.open("h2");
            b.append(b.text(formName));
            b.close("h2");
            b.hr();
            b.open("form", b.attr("name", formName,
                                  "action", b.fmt("{0}.cgi", formName),
                                  "method", "post"));
            b.open("table");
            foreach (var pair in inputs)
            {
                InputBase input = pair.Value;
                if (input.Form.Name == formName)
                {
                    b.append(input.GetHtml());
                }
            }
            b.open("tr");
            b.open("th");
            b.close("th");
            b.open("td");

            FormSettings form = GetForm(formName);

            if (!form.AutoSubmit)
            {
                b.open("input", b.attr("type", "submit", "value", "SUBMIT"));
                b.close("input");
                b.open("input", b.attr("type", "reset", "value", "RESET"));
                b.close("input");
            }

            b.close("td");
            b.close("tr");
            b.close("table");
            b.close("form");

            // required "linkware" credits
            b.hr();
            //b.link("http://carpe.ambiprospect.com/slider/", "sliders by CARPE Design");

            return(b.ToString());
        }