コード例 #1
0
        /// <summary>
        /// Called when a OnSubmit event is raised.
        /// </summary>
        /// <param name="sender"> The sender object.</param>
        /// <param name="e"> The FormConvertionEventArgs.</param>
        private void navForm_FormConvertionEvent(object sender, FormConvertionArgs e)
        {
            FormConverter converter = new FormConverter();

            HtmlFormTag form = converter.ConvertToHtmlFormTag(e.FormElement, e.SiteUri);
            form = converter.AddPostDataValues(form, e.PostData);

            // Just post
            RequestPostEventArgs postArgs = new RequestPostEventArgs();
            postArgs.InspectorRequestAction = InspectorAction.WebBrowserPost;
            postArgs.Form = form;
            postArgs.Method = form.Method;
            postArgs.PostData = Encoding.UTF8.GetBytes(e.PostData);
            postArgs.CurrentUri = e.SiteUri;

            this.InspectorStartPostEvent(this, postArgs);

            // Add Quick Test options
            //this.RunQuickTests(postArgs);
        }
コード例 #2
0
        /// <summary>
        /// Transform each form element to a HtmlFormTag.
        /// </summary>
        /// <param name="htmlDoc"> The HTML DOM Document to process.</param>
        public static HtmlFormTagCollection TransformFormElements(IHTMLDocument2 htmlDoc, Uri currentUri)
        {
            // For each form, add in temp FormTags Collection
            FormConverter converter = new FormConverter();

            HtmlFormTagCollection formCollection = new HtmlFormTagCollection(htmlDoc.forms.length);

            try
            {
                foreach ( HTMLFormElementClass formElement in htmlDoc.forms )
                {
                    System.Windows.Forms.Application.DoEvents();

                    // Convert to HTML Form Tag
                    HtmlFormTag form = converter.ConvertToHtmlFormTag(formElement, currentUri);

                    if ( !formCollection.ContainsKey(form.Name) )
                    {
                        formCollection.Add(form.Name, form);
                    }
                }
            }
            catch (Exception ex)
            {
                System.Windows.Forms.MessageBox.Show(ex.ToString());
                Microsoft.ApplicationBlocks.ExceptionManagement.ExceptionManager.Publish(ex);
            }

            return formCollection;
        }