AODL.Document.Export.Html.HTMLContentBuilder.GetODFControlAsHtml C# (CSharp) Метод

GetODFControlAsHtml() публичный Метод

Gets a ODFControlRef as HTML.
public GetODFControlAsHtml ( ODFControlRef reference ) : string
reference ODFControlRef
Результат string
		public string GetODFControlAsHtml(ODFControlRef reference)
		{
			if (reference.Document is TextDocument)
			{
				string html = "";
				try
				{
				
					if (reference == null) return "";
					TextDocument td = reference.Document as TextDocument;
					if (td == null)
						return "";

					ODFFormControl control = td.FindControlById(reference.DrawControl);
				
					if (control is ODFButton)
					{
						html	+= "<form ";
						ODFButton butt = control as ODFButton;
						if (butt.ParentForm.Method == Method.Post)
							html += "method='post' ";
						if (butt.ParentForm.Href != "")
							html +=String.Format("action='{0}' ", butt.ParentForm.Href);
						if (butt.ParentForm.Name != "")
							html +=String.Format("name='{0}'>\n", butt.ParentForm.Name);
					

						html +=String.Format("<input type='submit' style='float: left; width: {0}; height: {1};'", butt.Width, butt.Height);
						if (butt.Name!="")
							html +=String.Format("name='{0}' ", butt.Name);
						if (butt.Label!="")
							html +=String.Format("value='{0}' ", butt.Label);
						html +="/>\n</form>\n";
					}
				
					if (control is ODFCheckBox)
					{
						html	+= "<form ";
						ODFCheckBox cb = control as ODFCheckBox;
						if (cb.ParentForm.Method == Method.Post)
							html += "method='post' ";
						if (cb.ParentForm.Href != "")
							html +=String.Format("action='{0}' ", cb.ParentForm.Href);
						if (cb.ParentForm.Name != "")
							html +=String.Format("name='{0}'>\n", cb.ParentForm.Name);
					
						string is_checked = "";
						if (cb.CurrentState == State.Checked) is_checked = " checked ";
						html +=String.Format("<input type='checkbox' style='float: left; margin: 0px; width: {0}; height: {1};'", cb.Width, cb.Height);
						if (cb.Name!="")
							html +=String.Format("name='{0}' ", cb.Name);
						if (cb.Value!="")
							html +=String.Format("value='{0}' ", cb.Value);
						html +=is_checked;
						html +="/>\n</form>\n";
					}

					if (control is ODFListBox)
					{
						html	+= "<form ";
						ODFListBox lb = control as ODFListBox;
						if (lb.ParentForm.Method == Method.Post)
							html += "method='post' ";
						if (lb.ParentForm.Href != "")
							html +=String.Format("action='{0}' ", lb.ParentForm.Href);
						if (lb.ParentForm.Name != "")
							html +=String.Format("name='{0}'>\n", lb.ParentForm.Name);
					
						html +=String.Format("<select style='float: left; margin: 0px; width: {0}; height: {1};'", lb.Width, lb.Height);
						if (lb.Name!="")
							html +=String.Format("name='{0}' ", lb.Name);
						if (lb.Size!=0)
							html +=String.Format("size='{0}' ",lb.Size);
						html +="/>\n";
						foreach (ODFOption o in lb.Options)
						{
							string selected = "";
							if (o.Selected == XmlBoolean.True) selected = " selected";
							html += String.Format("<option{0}>{1}</option>", selected, o.Label);
						}
						
						html+="</form>\n";
					}

					if (control is ODFComboBox)
					{
						html	+= "<form ";
						ODFComboBox lb = control as ODFComboBox;
						if (lb.ParentForm.Method == Method.Post)
							html += "method='post' ";
						if (lb.ParentForm.Href != "")
							html +=String.Format("action='{0}' ", lb.ParentForm.Href);
						if (lb.ParentForm.Name != "")
							html +=String.Format("name='{0}'>\n", lb.ParentForm.Name);
					
						html +=String.Format("<select style='float: left; margin: 0px; width: {0}; height: {1};'", lb.Width, lb.Height);
						if (lb.Name!="")
							html +=String.Format("name='{0}' ", lb.Name);
						if (lb.Size!=0)
							html +=String.Format("size='{0}' ",lb.Size);
						html +="/>\n";
						foreach (ODFItem o in lb.Items)
						{
							string selected = "";
							if (o.Label == lb.CurrentValue) selected = " selected";
							html += String.Format("<option{0}>{1}</option>", selected, o.Label);
						}
						
						html+="</form>\n";
					}

					if (control is ODFFile)
					{
						html	+= "<form ";
						ODFFile file = control as ODFFile;
						if (file.ParentForm.Method == Method.Post)
							html += "method='post' ";
						if (file.ParentForm.Href != "")
							html +=String.Format("action='{0}' ", file.ParentForm.Href);
						if (file.ParentForm.Name != "")
							html +=String.Format("name='{0}'>\n", file.ParentForm.Name);
					

						html +=String.Format("<input type='file' style='float: left; width: {0}; height: {1};'", file.Width, file.Height);
						if (file.Name!="")
							html +=String.Format("name='{0}' ", file.Name);
						if (file.CurrentValue!="")
							html +=String.Format("value='{0}' ", file.CurrentValue);
						html +="/>\n</form>\n";
					}

					if (control is ODFHidden)
					{
						html	+= "<form ";
						ODFHidden hid = control as ODFHidden;
						if (hid.ParentForm.Method == Method.Post)
							html += "method='post' ";
						if (hid.ParentForm.Href != "")
							html +=String.Format("action='{0}' ", hid.ParentForm.Href);
						if (hid.ParentForm.Name != "")
							html +=String.Format("name='{0}'>\n", hid.ParentForm.Name);
					

						html +=String.Format("<input type='file' style='float: left; width: {0}; height: {1};'", hid.Width, hid.Height);
						if (hid.Name!="")
							html +=String.Format("name='{0}' ", hid.Name);
						if (hid.Value!="")
							html +=String.Format("value='{0}' ", hid.Value);
						html +="/>\n</form>\n";
					}

					if (control is ODFFormattedText)
					{
						html	+= "<form ";
						ODFFormattedText ft = control as ODFFormattedText;
						if (ft.ParentForm.Method == Method.Post)
							html += "method='post' ";
						if (ft.ParentForm.Href != "")
							html +=String.Format("action='{0}' ", ft.ParentForm.Href);
						if (ft.ParentForm.Name != "")
							html +=String.Format("name='{0}'>\n", ft.ParentForm.Name);
					

						html +=String.Format("<input type='text' style='float: left; width: {0}; height: {1};'", ft.Width, ft.Height);
						if (ft.Name!="")
							html +=String.Format("name='{0}' ", ft.Name);
						if (ft.CurrentValue!="")
							html +=String.Format("value='{0}' ", ft.CurrentValue);
						html +="/>\n</form>\n";
					}

					if (control is ODFTextArea)
					{
						html	+= "<form ";
						ODFTextArea ta = control as ODFTextArea;
						if (ta.ParentForm.Method == Method.Post)
							html += "method='post' ";
						if (ta.ParentForm.Href != "")
							html +=String.Format("action='{0}' ", ta.ParentForm.Href);
						if (ta.ParentForm.Name != "")
							html +=String.Format("name='{0}'>\n", ta.ParentForm.Name);
					

						html +=String.Format("<textarea style='float: left; width: {0}; height: {1};'", ta.Width, ta.Height);
						if (ta.Name!="")
							html +=String.Format("name='{0}' ", ta.Name);
						html +="/>";
						html+= ta.CurrentValue;
						html+= "\n</form>\n";
					}
		
				}

				catch(Exception ex)
				{
					throw new AODLException("Exception while trying to build a HTML string from an ODF Form.", ex);
				}
				return html;
			}
			else return "";
		}