public O2Form(HTMLFormElementClass _htmlForm)
 {
     htmlForm = _htmlForm;
     //populateFieldsFromHtmlElementData(heForm);
 }
 public O2Form(HTMLFormElementClass _htmlForm)
 {
     htmlForm = _htmlForm;
     //populateFieldsFromHtmlElementData(heForm);
 }
        /// <summary>
        /// Converts a HTMLFormElementClass to a GB HtmlFormTag.
        /// </summary>
        /// <param name="formElement"> The HTMLFormElementClass to convert.</param>
        /// <param name="currentUri"> The current uri.</param>
        /// <returns> A HtmlFormTag.</returns>
        public HtmlFormTag ConvertToHtmlFormTag(HTMLFormElementClass formElement, Uri currentUri)
        {
            IHTMLElement el = (IHTMLElement)formElement.elements;
            ArrayList elements = new ArrayList();
            // Converts the element tag to an array list
            elements = ParseTags(elements,(IHTMLElementCollection)el.children);

            HtmlFormTag formTag = new HtmlFormTag();

            #region Set Form Properties
            if ( formElement.action == null )
            {
                formTag.Action = currentUri.Scheme + "://" + currentUri.Authority + currentUri.AbsolutePath;
            }
            else
            {
                formTag.Action = formElement.action;
            }

            formTag.Class = formElement.className;

            if ( formElement.method == null )
            {
                formTag.Method = "GET";
            } else {
                formTag.Method = formElement.method;
            }
            if ( formElement.encoding == null )
            {
                formTag.Enctype = "";
            }
            else
            {
                formTag.Enctype = formElement.encoding;
            }

            // formTag.FormIndex = formElement.
            formTag.Id = formElement.id;

            if ( formElement.name != null )
            {
                formTag.Name = formElement.name;
            }
            else
            {
                if ( formElement.id != null )
                {
                    formTag.Name = formElement.id;
                }
                else
                {
                    formTag.Name = formElement.uniqueID;
                    formTag.Id = formElement.uniqueID;
                }
            }
            formTag.OnSubmit = string.Empty;
            formTag.Style = string.Empty;
            formTag.Title = formElement.title;
            #endregion
            #region Add Tags
            foreach (object obj in elements)
            {
                // The last check is the most significant type

                #region Button Element
                if (obj is mshtml.HTMLInputButtonElementClass)
                {
                    HtmlButtonTag button = CreateHtmlButtonTag((HTMLInputButtonElementClass)obj);

                    if ( formTag.ContainsKey(button.Name) )
                    {
                        // just add the value
                        HtmlTagBaseList array = ((HtmlTagBaseList)formTag[button.Name]);
                        array.Add(button);
                    }
                    else
                    {
                        HtmlTagBaseList list = new HtmlTagBaseList();
                        list.Add(button);
                        formTag.Add(button.Name,list);
                    }
                    continue;
                }
                #endregion

                #region Select Element
                if (obj is mshtml.HTMLSelectElementClass)
                {
                    HtmlSelectTag select = CreateHtmlSelectTag((HTMLSelectElementClass)obj);

                    if ( formTag.ContainsKey(select.Name) )
                    {
                        // just add the value
                        HtmlTagBaseList array = ((HtmlTagBaseList)formTag[select.Name]);
                        array.Add(select);
                    }
                    else
                    {
                        HtmlTagBaseList list = new HtmlTagBaseList();
                        list.Add(select);
                        formTag.Add(select.Name,list);
                    }
                    continue;
                }
                #endregion

                #region Textarea Element
                if (obj is mshtml.HTMLTextAreaElementClass)
                {
                    HtmlTextAreaTag textarea=CreateHtmlTextAreaTag((HTMLTextAreaElementClass)obj);
                    if ( formTag.ContainsKey(textarea.Name) )
                    {
                        // just add the value
                        HtmlTagBaseList array = ((HtmlTagBaseList)formTag[textarea.Name]);
                        array.Add(textarea);
                    }
                    else
                    {
                        HtmlTagBaseList list = new HtmlTagBaseList();
                        list.Add(textarea);
                        formTag.Add(textarea.Name,list);
                    }
                    continue;
                }
                #endregion

                #region Input Element
                if (obj is mshtml.HTMLInputElementClass)
                {
                    HtmlInputTag input = CreateHtmlInputTag((HTMLInputElementClass)obj);
                    if ( formTag.ContainsKey(input.Name) )
                    {
                        // just add the value
                        HtmlTagBaseList array = ((HtmlTagBaseList)formTag[input.Name]);
                        array.Add(input);
                    }
                    else
                    {
                        HtmlTagBaseList list = new HtmlTagBaseList();
                        list.Add(input);
                        formTag.Add(input.Name,list);
                    }
                    continue;
                }
                #endregion

            }
            #endregion

            return formTag;
        }
 /// <summary>
 /// Occurs when post data is called by javascript.
 /// </summary>
 /// <param name="form"></param>
 /// <param name="htmlDoc"></param>
 /// <param name="postData"></param>
 private void OnPost(HTMLFormElementClass form, IHTMLDocument2 htmlDoc, byte[] postData)
 {
     FormConvertionArgs args = new FormConvertionArgs();
     args.FormElement = form;
     args.SiteUri = new Uri(this.web.LocationURL);
     args.PostData = System.Text.Encoding.UTF8.GetString((byte[])postData);
     // MessageBox.Show(args.PostData);
     FormConvertionEvent(this, args);
 }