743 lines
		
	
	
		
			22 KiB
		
	
	
	
		
			C#
		
	
	
	
	
	
			
		
		
	
	
			743 lines
		
	
	
		
			22 KiB
		
	
	
	
		
			C#
		
	
	
	
	
	
| using System;
 | |
| using System.Collections;
 | |
| using System.Collections.Generic;
 | |
| using System.Linq;
 | |
| using System.Text;
 | |
| using System.Threading.Tasks;
 | |
| using System.Xml.Serialization;
 | |
| using System.ComponentModel;
 | |
| using System.Xml;
 | |
| using System.Xml.Schema;
 | |
| using System.IO;
 | |
| 
 | |
| namespace XMLConvert
 | |
| {
 | |
| 	/// <summary>
 | |
| 	/// Root Node
 | |
| 	/// </summary>
 | |
| 	[XmlRoot("html")]
 | |
| 	public class vlnhtml : VlnHtmlContainer
 | |
| 	{
 | |
| 	}
 | |
| 	[TypeConverter(typeof(ExpandableObjectConverter))]
 | |
| 	/// <summary>
 | |
| 	/// Part
 | |
| 	/// </summary>
 | |
| 	public class VlnHtmlPart
 | |
| 	{
 | |
| 			#region ID
 | |
| 			protected string _ID = string.Empty;
 | |
| 			[System.ComponentModel.DefaultValueAttribute("")]
 | |
| 			[XmlIgnore]
 | |
| 			public string ID
 | |
| 			{
 | |
| 				get { return _ID; }
 | |
| 				set { _ID = value; }
 | |
| 			}
 | |
| 			#endregion
 | |
| 			//#region Parent and Containing Svg
 | |
| 			//// ToDo: MyParent
 | |
| 			//private SvgPartGrouping _MyParent;
 | |
| 			//[XmlIgnore()]
 | |
| 			//public SvgPartGrouping MyParent
 | |
| 			//{
 | |
| 			//  get { return _MyParent; }
 | |
| 			//  set { _MyParent = value; }
 | |
| 			//}
 | |
| 			//// ToDo: MySvg
 | |
| 			//private Svg _MySvg;
 | |
| 			//public Svg MySvg
 | |
| 			//{
 | |
| 			//  get { return _MySvg; }
 | |
| 			//  set { _MySvg = value; }
 | |
| 			//}
 | |
| 			//internal void SetParent(SvgPartGrouping myParent)
 | |
| 			//{
 | |
| 			//  _MyParent = myParent;
 | |
| 			//  _MySvg = myParent.MySvg == null? MyParent : myParent.MySvg;
 | |
| 			//}
 | |
| 			//#endregion
 | |
| 		#region Dictionary of Parts
 | |
| 		internal virtual void AddLookup(Dictionary<string, VlnHtmlPart> lookUp)
 | |
| 		{
 | |
| 			if (_ID != string.Empty && !lookUp.ContainsKey(_ID))
 | |
| 				lookUp.Add(_ID, this);
 | |
| 		}
 | |
| 		#endregion
 | |
| 	}
 | |
| 	[Serializable()]
 | |
| 	[TypeConverter(typeof(VlnHtmlPartsConverter))]
 | |
| 	/// <summary>
 | |
| 	/// Parts
 | |
| 	/// </summary>
 | |
| 	public class VlnHtmlParts : CollectionBase, ICustomTypeDescriptor
 | |
| 	{
 | |
| 		/// <summary>Notifies when the collection has been modified.</summary>
 | |
| 		public event EventHandler OnItemsChanged;
 | |
| 
 | |
| 		/// <summary>Notifies that an item has been added.</summary>
 | |
| 		public event VlnHtmlPartHandler OnItemAdd;
 | |
| 
 | |
| 		/// <summary>Notifies that items have been added.</summary>
 | |
| 		public event VlnHtmlPartHandler OnItemsAdd;
 | |
| 
 | |
| 		/// <summary>Notifies that an item has been removed.</summary>
 | |
| 		public event VlnHtmlPartHandler OnItemRemove;
 | |
| 
 | |
| 		/// <summary>
 | |
| 		///	 <para>
 | |
| 		///	   Initializes a new instance of <see cref='VlnHtmlPart'/>.
 | |
| 		///	</para>
 | |
| 		/// </summary>
 | |
| 		public VlnHtmlParts()
 | |
| 		{
 | |
| 		}
 | |
| 
 | |
| 		/// <summary>
 | |
| 		///	 <para>
 | |
| 		///	   Initializes a new instance of <see cref='VlnHtmlPart'/> based on another <see cref='VlnHtmlPart'/>.
 | |
| 		///	</para>
 | |
| 		/// </summary>
 | |
| 		/// <param name='value'>
 | |
| 		///	   A <see cref='VlnHtmlPart'/> from which the contents are copied
 | |
| 		/// </param>
 | |
| 		public VlnHtmlParts(VlnHtmlParts value)
 | |
| 		{
 | |
| 			this.AddRange(value);
 | |
| 		}
 | |
| 
 | |
| 		/// <summary>
 | |
| 		///	 <para>
 | |
| 		///	   Initializes a new instance of <see cref='VlnHtmlPart'/> containing any array of <see cref='VlnHtmlPart'/> objects.
 | |
| 		///	</para>
 | |
| 		/// </summary>
 | |
| 		/// <param name='value'>
 | |
| 		///	   A array of <see cref='VlnHtmlPart'/> objects with which to intialize the collection
 | |
| 		/// </param>
 | |
| 		public VlnHtmlParts(VlnHtmlPart[] value)
 | |
| 		{
 | |
| 			this.AddRange(value);
 | |
| 		}
 | |
| 
 | |
| 		/// <summary>
 | |
| 		/// <para>Represents the entry at the specified index of the <see cref='VlnHtmlPart'/>.</para>
 | |
| 		/// </summary>
 | |
| 		/// <param name='index'><para>The zero-based index of the entry to locate in the collection.</para></param>
 | |
| 		/// <value>
 | |
| 		///	<para> The entry at the specified index of the collection.</para>
 | |
| 		/// </value>
 | |
| 		/// <exception cref='System.ArgumentOutOfRangeException'><paramref name='index'/> is outside the valid range of indexes for the collection.</exception>
 | |
| 		public VlnHtmlPart this[int index]
 | |
| 		{
 | |
| 			get { return ((VlnHtmlPart)(List[index])); }
 | |
| 			set { List[index] = value; }
 | |
| 		}
 | |
| 		//#region SetupInheritance
 | |
| 		//internal void SetupInheritance(SvgInheritedSettings myParentsSettings)
 | |
| 		//{
 | |
| 		//  foreach (vlnhtmlpart vlnhtmlpart in List)
 | |
| 		//    vlnhtmlpart.SetupInheritance(myParentsSettings);
 | |
| 		//}
 | |
| 		//#endregion
 | |
| 		#region Dictionary of Parts
 | |
| 		internal void AddLookup(Dictionary<string, VlnHtmlPart> lookUp)
 | |
| 		{
 | |
| 			foreach (VlnHtmlPart vlnhtmlpart in List)
 | |
| 				vlnhtmlpart.AddLookup(lookUp);
 | |
| 		}
 | |
| 		#endregion
 | |
| 		internal static void ShowException(Exception ex)
 | |
| 		{
 | |
| 			StringBuilder sb = new StringBuilder();
 | |
| 			string sep = "";
 | |
| 			for (Exception ex1 = ex; ex1 != null; ex1 = ex1.InnerException)
 | |
| 			{
 | |
| 				sb.Append(sep + string.Format("ShowException {0} - {1}", ex1.GetType().Name, ex1.Message));
 | |
| 				sep = "\r\n";
 | |
| 			}
 | |
| 			Console.WriteLine(sb);
 | |
| 		}
 | |
| 		/// <summary>
 | |
| 		///	<para>Adds a <see cref='VlnHtmlPart'/> with the specified value to the 
 | |
| 		///	<see cref='VlnHtmlPart'/> .</para>
 | |
| 		/// </summary>
 | |
| 		/// <param name='value'>The <see cref='VlnHtmlPart'/> to add.</param>
 | |
| 		/// <returns>
 | |
| 		///	<para>The index at which the new element was inserted.</para>
 | |
| 		/// </returns>
 | |
| 		/// <seealso cref='VlnHtmlParts.AddRange'/>
 | |
| 		public int Add(VlnHtmlPart value)
 | |
| 		{
 | |
| 			int ndx = List.Add(value);
 | |
| 			if (OnItemAdd != null) { OnItemAdd(this, new vlnhtmlpartArgs(value)); }
 | |
| 			if (OnItemsChanged != null) { OnItemsChanged(value, EventArgs.Empty); }
 | |
| 			return ndx;
 | |
| 		}
 | |
| 
 | |
| 		/// <summary>
 | |
| 		/// <para>Copies the elements of an array to the end of the <see cref='VlnHtmlPart'/>.</para>
 | |
| 		/// </summary>
 | |
| 		/// <param name='value'>
 | |
| 		///	An array of type <see cref='VlnHtmlPart'/> containing the objects to add to the collection.
 | |
| 		/// </param>
 | |
| 		/// <returns>
 | |
| 		///   <para>None.</para>
 | |
| 		/// </returns>
 | |
| 		/// <seealso cref='VlnHtmlParts.Add'/>
 | |
| 		public void AddRange(VlnHtmlPart[] value)
 | |
| 		{
 | |
| 			for (int i = 0; i < value.Length; i++)
 | |
| 			{
 | |
| 				this.Add(value[i]);
 | |
| 			}
 | |
| 			if (OnItemsAdd != null) { OnItemsAdd(this, new vlnhtmlpartArgs(value)); }
 | |
| 			if (OnItemsChanged != null) { OnItemsChanged(value, EventArgs.Empty); }
 | |
| 		}
 | |
| 
 | |
| 		/// <summary>
 | |
| 		///	 <para>
 | |
| 		///	   Adds the contents of another <see cref='VlnHtmlPart'/> to the end of the collection.
 | |
| 		///	</para>
 | |
| 		/// </summary>
 | |
| 		/// <param name='value'>
 | |
| 		///	A <see cref='VlnHtmlPart'/> containing the objects to add to the collection.
 | |
| 		/// </param>
 | |
| 		/// <returns>
 | |
| 		///   <para>None.</para>
 | |
| 		/// </returns>
 | |
| 		/// <seealso cref='VlnHtmlParts.Add'/>
 | |
| 		public void AddRange(VlnHtmlParts value)
 | |
| 		{
 | |
| 			for (int i = 0; i < value.Count; i++)
 | |
| 			{
 | |
| 				this.Add(value[i]);
 | |
| 			}
 | |
| 			if (OnItemsAdd != null) { OnItemsAdd(this, new vlnhtmlpartArgs(value)); }
 | |
| 			if (OnItemsChanged != null) { OnItemsChanged(value, EventArgs.Empty); }
 | |
| 		}
 | |
| 
 | |
| 		/// <summary>
 | |
| 		/// <para>Gets a value indicating whether the 
 | |
| 		///	<see cref='VlnHtmlPart'/> contains the specified <see cref='VlnHtmlPart'/>.</para>
 | |
| 		/// </summary>
 | |
| 		/// <param name='value'>The <see cref='VlnHtmlPart'/> to locate.</param>
 | |
| 		/// <returns>
 | |
| 		/// <para><see langword='true'/> if the <see cref='VlnHtmlPart'/> is contained in the collection; 
 | |
| 		///   otherwise, <see langword='false'/>.</para>
 | |
| 		/// </returns>
 | |
| 		/// <seealso cref='VlnHtmlParts.IndexOf'/>
 | |
| 		public bool Contains(VlnHtmlPart value)
 | |
| 		{
 | |
| 			return List.Contains(value);
 | |
| 		}
 | |
| 
 | |
| 		/// <summary>
 | |
| 		/// <para>Copies the <see cref='VlnHtmlPart'/> values to a one-dimensional <see cref='System.Array'/> instance at the 
 | |
| 		///	specified index.</para>
 | |
| 		/// </summary>
 | |
| 		/// <param name='array'><para>The one-dimensional <see cref='System.Array'/> that is the destination of the values copied from <see cref='VlnHtmlPart'/> .</para></param>
 | |
| 		/// <param name='index'>The index in <paramref name='array'/> where copying begins.</param>
 | |
| 		/// <returns>
 | |
| 		///   <para>None.</para>
 | |
| 		/// </returns>
 | |
| 		/// <exception cref='System.ArgumentException'><para><paramref name='array'/> is multidimensional.</para> <para>-or-</para> <para>The number of elements in the <see cref='VlnHtmlPart'/> is greater than the available space between <paramref name='arrayIndex'/> and the end of <paramref name='array'/>.</para></exception>
 | |
| 		/// <exception cref='System.ArgumentNullException'><paramref name='array'/> is <see langword='null'/>. </exception>
 | |
| 		/// <exception cref='System.ArgumentOutOfRangeException'><paramref name='arrayIndex'/> is less than <paramref name='array'/>'s lowbound. </exception>
 | |
| 		/// <seealso cref='System.Array'/>
 | |
| 		public void CopyTo(VlnHtmlPart[] array, int index)
 | |
| 		{
 | |
| 			List.CopyTo(array, index);
 | |
| 		}
 | |
| 
 | |
| 		/// <summary>
 | |
| 		///	<para>Returns the index of a <see cref='VlnHtmlPart'/> in 
 | |
| 		///	   the <see cref='VlnHtmlPart'/> .</para>
 | |
| 		/// </summary>
 | |
| 		/// <param name='value'>The <see cref='VlnHtmlPart'/> to locate.</param>
 | |
| 		/// <returns>
 | |
| 		/// <para>The index of the <see cref='VlnHtmlPart'/> of <paramref name='value'/> in the 
 | |
| 		/// <see cref='VlnHtmlPart'/>, if found; otherwise, -1.</para>
 | |
| 		/// </returns>
 | |
| 		/// <seealso cref='VlnHtmlParts.Contains'/>
 | |
| 		public int IndexOf(VlnHtmlPart value)
 | |
| 		{
 | |
| 			return List.IndexOf(value);
 | |
| 		}
 | |
| 
 | |
| 		/// <summary>
 | |
| 		/// <para>Inserts a <see cref='VlnHtmlPart'/> into the <see cref='VlnHtmlParts'/> at the specified index.</para>
 | |
| 		/// </summary>
 | |
| 		/// <param name='index'>The zero-based index where <paramref name='value'/> should be inserted.</param>
 | |
| 		/// <param name=' value'>The <see cref='VlnHtmlPart'/> to insert.</param>
 | |
| 		/// <returns><para>None.</para></returns>
 | |
| 		/// <seealso cref='VlnHtmlParts.Add'/>
 | |
| 		public void Insert(int index, VlnHtmlPart value)
 | |
| 		{
 | |
| 			List.Insert(index, value);
 | |
| 			if (OnItemAdd != null) { OnItemAdd(this, new vlnhtmlpartArgs(value)); }
 | |
| 			if (OnItemsChanged != null) { OnItemsChanged(value, EventArgs.Empty); }
 | |
| 		}
 | |
| 
 | |
| 		/// <summary>
 | |
| 		///	<para> Removes a specific <see cref='VlnHtmlPart'/> from the 
 | |
| 		///	<see cref='VlnHtmlParts'/> .</para>
 | |
| 		/// </summary>
 | |
| 		/// <param name='value'>The <see cref='VlnHtmlPart'/> to remove from the <see cref='VlnHtmlParts'/> .</param>
 | |
| 		/// <returns><para>None.</para></returns>
 | |
| 		/// <exception cref='System.ArgumentException'><paramref name='value'/> is not found in the Collection. </exception>
 | |
| 		public void Remove(VlnHtmlPart value)
 | |
| 		{
 | |
| 			List.Remove(value);
 | |
| 			if (OnItemRemove != null) { OnItemRemove(this, new vlnhtmlpartArgs(value)); }
 | |
| 			if (OnItemsChanged != null) { OnItemsChanged(value, EventArgs.Empty); }
 | |
| 		}
 | |
| 		#region ICustomTypeDescriptor impl
 | |
| 		public String GetClassName()
 | |
| 		{ return TypeDescriptor.GetClassName(this, true); }
 | |
| 		public AttributeCollection GetAttributes()
 | |
| 		{ return TypeDescriptor.GetAttributes(this, true); }
 | |
| 		public String GetComponentName()
 | |
| 		{ return TypeDescriptor.GetComponentName(this, true); }
 | |
| 		public TypeConverter GetConverter()
 | |
| 		{ return TypeDescriptor.GetConverter(this, true); }
 | |
| 		public EventDescriptor GetDefaultEvent()
 | |
| 		{ return TypeDescriptor.GetDefaultEvent(this, true); }
 | |
| 		public PropertyDescriptor GetDefaultProperty()
 | |
| 		{ return TypeDescriptor.GetDefaultProperty(this, true); }
 | |
| 		public object GetEditor(Type editorBaseType)
 | |
| 		{ return TypeDescriptor.GetEditor(this, editorBaseType, true); }
 | |
| 		public EventDescriptorCollection GetEvents(System.Attribute[] attributes)
 | |
| 		{ return TypeDescriptor.GetEvents(this, attributes, true); }
 | |
| 		public EventDescriptorCollection GetEvents()
 | |
| 		{ return TypeDescriptor.GetEvents(this, true); }
 | |
| 		public object GetPropertyOwner(PropertyDescriptor pd)
 | |
| 		{ return this; }
 | |
| 		/// <summary>
 | |
| 		/// Called to get the properties of this type. Returns properties with certain
 | |
| 		/// attributes. this restriction is not implemented here.
 | |
| 		/// </summary>
 | |
| 		/// <param name="attributes"></param>
 | |
| 		/// <returns></returns>
 | |
| 		public PropertyDescriptorCollection GetProperties(System.Attribute[] attributes)
 | |
| 		{ return GetProperties(); }
 | |
| 		/// <summary>
 | |
| 		/// Called to get the properties of this type.
 | |
| 		/// </summary>
 | |
| 		/// <returns></returns>
 | |
| 		public PropertyDescriptorCollection GetProperties()
 | |
| 		{
 | |
| 			// Create a collection object to hold property descriptors
 | |
| 			PropertyDescriptorCollection pds = new PropertyDescriptorCollection(null);
 | |
| 			// Iterate the list 
 | |
| 			for (int i = 0; i < this.Count; i++)
 | |
| 			{
 | |
| 				// Create a property descriptor for the item and add to the property descriptor collection
 | |
| 				vlnhtmlpartsPropertyDescriptor pd = new vlnhtmlpartsPropertyDescriptor(this, i);
 | |
| 				pds.Add(pd);
 | |
| 			}
 | |
| 			// return the property descriptor collection
 | |
| 			return pds;
 | |
| 		}
 | |
| 		#endregion
 | |
| 
 | |
| 		/// Event arguments for the vlnhtmlparts collection class.
 | |
| 		public class vlnhtmlpartArgs : EventArgs
 | |
| 		{
 | |
| 			private VlnHtmlParts t;
 | |
| 
 | |
| 			/// Default constructor.
 | |
| 			public vlnhtmlpartArgs()
 | |
| 			{
 | |
| 				t = new VlnHtmlParts();
 | |
| 			}
 | |
| 
 | |
| 			/// Initializes with a vlnhtmlpart.
 | |
| 			/// Data object.
 | |
| 			public vlnhtmlpartArgs(VlnHtmlPart t)
 | |
| 				: this()
 | |
| 			{
 | |
| 				this.t.Add(t);
 | |
| 			}
 | |
| 
 | |
| 			/// Initializes with a collection of vlnhtmlpart objects.
 | |
| 			/// Collection of data.
 | |
| 			public vlnhtmlpartArgs(VlnHtmlParts ts)
 | |
| 				: this()
 | |
| 			{
 | |
| 				this.t.AddRange(ts);
 | |
| 			}
 | |
| 
 | |
| 			/// Initializes with an array of vlnhtmlpart objects.
 | |
| 			/// Array of data.
 | |
| 			public vlnhtmlpartArgs(VlnHtmlPart[] ts)
 | |
| 				: this()
 | |
| 			{
 | |
| 				this.t.AddRange(ts);
 | |
| 			}
 | |
| 
 | |
| 			/// Gets or sets the data of this argument.
 | |
| 			public VlnHtmlParts vlnhtmlparts
 | |
| 			{
 | |
| 				get { return t; }
 | |
| 				set { t = value; }
 | |
| 			}
 | |
| 		}
 | |
| 
 | |
| 		/// vlnhtmlparts event handler.
 | |
| 		public delegate void VlnHtmlPartHandler(object sender, vlnhtmlpartArgs e);
 | |
| 		#region Property Descriptor
 | |
| 		/// <summary>
 | |
| 		/// Summary description for CollectionPropertyDescriptor.
 | |
| 		/// </summary>
 | |
| 		public partial class vlnhtmlpartsPropertyDescriptor : vlnListPropertyDescriptor
 | |
| 		{
 | |
| 			private VlnHtmlPart Item { get { return (VlnHtmlPart)_Item; } }
 | |
| 			public vlnhtmlpartsPropertyDescriptor(VlnHtmlParts collection, int index) : base(collection, index) { ;}
 | |
| 			public override string DisplayName
 | |
| 			{ get { return Item.GetType().Name; } }
 | |
| 		}
 | |
| 		#endregion
 | |
| 		[Serializable()]
 | |
| 		public partial class vlnListPropertyDescriptor : PropertyDescriptor
 | |
| 		{
 | |
| 			protected object _Item = null;
 | |
| 			public vlnListPropertyDescriptor(System.Collections.IList collection, int index)
 | |
| 				: base("#" + index.ToString(), null)
 | |
| 			{ _Item = collection[index]; }
 | |
| 			public override bool CanResetValue(object component)
 | |
| 			{ return true; }
 | |
| 			public override Type ComponentType
 | |
| 			{ get { return _Item.GetType(); } }
 | |
| 			public override object GetValue(object component)
 | |
| 			{ return _Item; }
 | |
| 			public override bool IsReadOnly
 | |
| 			{ get { return false; } }
 | |
| 			public override Type PropertyType
 | |
| 			{ get { return _Item.GetType(); } }
 | |
| 			public override void ResetValue(object component)
 | |
| 			{ ;}
 | |
| 			public override bool ShouldSerializeValue(object component)
 | |
| 			{ return true; }
 | |
| 			public override void SetValue(object component, object value)
 | |
| 			{ /*_Item = value*/;}
 | |
| 			//public override AttributeCollection Attributes
 | |
| 			//{ get { return new AttributeCollection(null); } }
 | |
| 			public override string DisplayName
 | |
| 			{ get { return _Item.ToString(); } }
 | |
| 			public override string Description
 | |
| 			{ get { return _Item.ToString(); } }
 | |
| 			public override string Name
 | |
| 			{ get { return _Item.ToString(); } }
 | |
| 
 | |
| 		} // Class
 | |
| 		#region Converter
 | |
| 		internal class VlnHtmlPartsConverter : ExpandableObjectConverter
 | |
| 		{
 | |
| 			public override object ConvertTo(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, Type destType)
 | |
| 			{
 | |
| 				if (destType == typeof(string) && value is VlnHtmlParts)
 | |
| 				{
 | |
| 					// Return department and department role separated by comma.
 | |
| 					return ((VlnHtmlParts)value).List.Count.ToString() + " SVG Drawing Parts";
 | |
| 				}
 | |
| 				return base.ConvertTo(context, culture, value, destType);
 | |
| 			}
 | |
| 		}
 | |
| 		#endregion
 | |
| 		/// SVGParts event handler.
 | |
| 		//public delegate void VlnHtmlPartHandler(object sender, VlnHtmlPartArgs e);
 | |
| 		//#region Property Descriptor
 | |
| 		///// <summary>
 | |
| 		///// Summary description for CollectionPropertyDescriptor.
 | |
| 		///// </summary>
 | |
| 		//public partial class VlnHtmlPartsPropertyDescriptor : vlnListPropertyDescriptor
 | |
| 		//{
 | |
| 		//	private VlnHtmlPart Item { get { return (VlnHtmlPart)_Item; } }
 | |
| 		//	public VlnHtmlPartsPropertyDescriptor(VlnHtmlParts collection, int index) : base(collection, index) { ;}
 | |
| 		//	public override string DisplayName
 | |
| 		//	{ get { return Item.GetType().Name; } }
 | |
| 		//}
 | |
| 		//#endregion
 | |
| 		//[Serializable()]
 | |
| 		//public partial class vlnListPropertyDescriptor : PropertyDescriptor
 | |
| 		//{
 | |
| 		//	protected object _Item = null;
 | |
| 		//	public vlnListPropertyDescriptor(System.Collections.IList collection, int index)
 | |
| 		//		: base("#" + index.ToString(), null)
 | |
| 		//	{ _Item = collection[index]; }
 | |
| 		//	public override bool CanResetValue(object component)
 | |
| 		//	{ return true; }
 | |
| 		//	public override Type ComponentType
 | |
| 		//	{ get { return _Item.GetType(); } }
 | |
| 		//	public override object GetValue(object component)
 | |
| 		//	{ return _Item; }
 | |
| 		//	public override bool IsReadOnly
 | |
| 		//	{ get { return false; } }
 | |
| 		//	public override Type PropertyType
 | |
| 		//	{ get { return _Item.GetType(); } }
 | |
| 		//	public override void ResetValue(object component)
 | |
| 		//	{ ;}
 | |
| 		//	public override bool ShouldSerializeValue(object component)
 | |
| 		//	{ return true; }
 | |
| 		//	public override void SetValue(object component, object value)
 | |
| 		//	{ /*_Item = value*/;}
 | |
| 		//	//public override AttributeCollection Attributes
 | |
| 		//	//{ get { return new AttributeCollection(null); } }
 | |
| 		//	public override string DisplayName
 | |
| 		//	{ get { return _Item.ToString(); } }
 | |
| 		//	public override string Description
 | |
| 		//	{ get { return _Item.ToString(); } }
 | |
| 		//	public override string Name
 | |
| 		//	{ get { return _Item.ToString(); } }
 | |
| 
 | |
| 		//} // Class
 | |
| 		//#region Converter
 | |
| 		//internal class VlnHtmlPartsConverter : ExpandableObjectConverter
 | |
| 		//{
 | |
| 		//	public override object ConvertTo(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, Type destType)
 | |
| 		//	{
 | |
| 		//		if (destType == typeof(string) && value is VlnHtmlParts)
 | |
| 		//		{
 | |
| 		//			// Return department and department role separated by comma.
 | |
| 		//			return ((VlnHtmlParts)value).List.Count.ToString() + " Vln Html Parts";
 | |
| 		//		}
 | |
| 		//		return base.ConvertTo(context, culture, value, destType);
 | |
| 		//	}
 | |
| 		//}
 | |
| 		//	}
 | |
| 		//#endregion
 | |
| 	}
 | |
| 
 | |
| 
 | |
| 	/// <summary>
 | |
| 	/// Hyperrlink
 | |
| 	/// </summary>
 | |
| 	public class vlnhtml_a
 | |
| 	{
 | |
| 		//url
 | |
| 	}
 | |
| 	public class vlnhtmlContent : VlnHtmlPart
 | |
| 	{
 | |
| 		string _text;
 | |
| 		[XmlText]
 | |
| 		public string Text
 | |
| 		{
 | |
| 			get { return _text; }
 | |
| 			set { _text = value; }
 | |
| 		}
 | |
| 		string _style;// -qt-block-indent:1or2
 | |
| 		[XmlAttribute("style")]
 | |
| 		public string Style
 | |
| 		{
 | |
| 			get { return _style; }
 | |
| 			set { _style = value; }
 | |
| 		}
 | |
| 		string _align;// Center Right Justify
 | |
| 		[XmlAttribute("align")]
 | |
| 		public string Align
 | |
| 		{
 | |
| 			get { return _align; }
 | |
| 			set { _align = value; }
 | |
| 		}
 | |
| 	}
 | |
| 	/// <summary>
 | |
| 	/// Paragraph
 | |
| 	/// </summary>
 | |
| 	public class vlnhtml_p : vlnhtmlContent
 | |
| 	{
 | |
| 	}
 | |
| 	/// <summary>
 | |
| 	/// Break
 | |
| 	/// </summary>
 | |
| 	public class vlnhtml_br : VlnHtmlPart
 | |
| 	{
 | |
| 	}
 | |
| 	/// <summary>
 | |
| 	/// Image
 | |
| 	/// </summary>
 | |
| 	public class vlnhtml_img : VlnHtmlPart
 | |
| 	{
 | |
| 		string _src;//filename and Path
 | |
| 		[XmlAttribute("src")]
 | |
| 		public string Src
 | |
| 		{
 | |
| 			get { return _src; }
 | |
| 			set { _src = value; }
 | |
| 		}
 | |
| 		int _width;
 | |
| 		[XmlAttribute("width")]
 | |
| 		public int Width
 | |
| 		{
 | |
| 			get { return _width; }
 | |
| 			set { _width = value; }
 | |
| 		}
 | |
| 	}
 | |
| 	/// <summary>
 | |
| 	/// Container
 | |
| 	/// </summary>
 | |
| 	public class VlnHtmlContainer : VlnHtmlPart
 | |
| 	{
 | |
| 		VlnHtmlParts _Children = new VlnHtmlParts();
 | |
| 		[XmlElement("ul", typeof(vlnhtml_ul))]
 | |
| 		[XmlElement("ol", typeof(vlnhtml_ol))]
 | |
| 		[XmlElement("li", typeof(vlnhtml_li))]
 | |
| 		[XmlElement("p", typeof(vlnhtml_p))]
 | |
| 		[XmlElement("a", typeof(vlnhtml_a))]
 | |
| 		[XmlElement("br", typeof(vlnhtml_br))]
 | |
| 		[XmlElement("img", typeof(vlnhtml_img))]
 | |
| 		[XmlElement("table", typeof(vlnhtml_table))]
 | |
| 		internal VlnHtmlParts Children
 | |
| 		{
 | |
| 			get
 | |
| 			{
 | |
| 				//if (_Children == null)
 | |
| 				//	_Children = new VlnHtmlParts();
 | |
| 				return _Children;
 | |
| 			}
 | |
| 			set { _Children = value; }
 | |
| 		}
 | |
| 	}
 | |
| 	/// <summary>
 | |
| 	/// Ordered List
 | |
| 	/// </summary>
 | |
| 	public class vlnhtml_ol : VlnHtmlContainer
 | |
| 	{
 | |
| 		string _style;// -qt-block-indent:1or2
 | |
| 		[XmlAttribute("style")]
 | |
| 		public string Style
 | |
| 		{
 | |
| 			get { return _style; }
 | |
| 			set { _style = value; }
 | |
| 		}
 | |
| 	}
 | |
| 	/// <summary>
 | |
| 	/// Unordered List
 | |
| 	/// </summary>
 | |
| 	public class vlnhtml_ul : VlnHtmlContainer
 | |
| 	{
 | |
| 		string _style;// -qt-block-indent:1or2
 | |
| 		[XmlAttribute("style")]
 | |
| 		public string Style
 | |
| 		{
 | |
| 			get { return _style; }
 | |
| 			set { _style = value; }
 | |
| 		}
 | |
| 	}
 | |
| 	/// <summary>
 | |
| 	/// List Item
 | |
| 	/// </summary>
 | |
| 	public class vlnhtml_li : vlnhtmlContent
 | |
| 	{
 | |
| 	}
 | |
| 	/// <summary>
 | |
| 	/// Table
 | |
| 	/// </summary>
 | |
| 	public class vlnhtml_table : VlnHtmlContainer
 | |
| 	{
 | |
| 		string _style;// -qt-block-indent:1or2
 | |
| 		[XmlAttribute("style")]
 | |
| 		public string Style
 | |
| 		{
 | |
| 			get { return _style; }
 | |
| 			set { _style = value; }
 | |
| 		}
 | |
| 		int _border;//
 | |
| 		int _cellspacing;
 | |
| 		int _cellpadding;
 | |
| 	}
 | |
| 	public class vlnhtml_tr : VlnHtmlContainer
 | |
| 	{
 | |
| 	}
 | |
| 	public class vlnhtml_td : VlnHtmlContainer
 | |
| 	{
 | |
| 	}
 | |
| 	public static class HtmlSerializer<T> where T : class
 | |
| 	{
 | |
| 		public static string StringSerialize(T t)
 | |
| 		{
 | |
| 			string strOutput = string.Empty;
 | |
| 			XmlSerializer xs = new XmlSerializer(typeof(T), "http://www.w3.org/2000/html");
 | |
| 			using (MemoryStream ms = new MemoryStream())
 | |
| 			{
 | |
| 				xs.Serialize(new NonXsiTextWriter(ms, Encoding.UTF8), t);
 | |
| 				//xs.Serialize(ms, t);
 | |
| 				ms.Position = 0;
 | |
| 				StreamReader sr = new StreamReader(ms);
 | |
| 				strOutput = sr.ReadToEnd();
 | |
| 				ms.Close();
 | |
| 			}
 | |
| 			return strOutput;
 | |
| 		}
 | |
| 		public static T StringDeserialize(string s)
 | |
| 		{
 | |
| 			T t;
 | |
| 			XmlSerializer xs = new XmlSerializer(typeof(T), "http://www.w3.org/2000/html");
 | |
| 			UTF8Encoding enc = new UTF8Encoding();
 | |
| 			Byte[] arrBytData = enc.GetBytes(s);
 | |
| 			using (MemoryStream ms = new MemoryStream(arrBytData))
 | |
| 			{
 | |
| 				t = (T)xs.Deserialize(ms);
 | |
| 			}
 | |
| 			return t;
 | |
| 		}
 | |
| 		public static void WriteFile(T t, string fileName)
 | |
| 		{
 | |
| 			string strOutput = string.Empty;
 | |
| 			XmlSerializer xs = new XmlSerializer(typeof(T), "http://www.w3.org/2000/html");
 | |
| 			using (FileStream fs = new FileStream(fileName, FileMode.Create))
 | |
| 			{
 | |
| 				xs.Serialize(new NonXsiTextWriter(fs, Encoding.UTF8), t);
 | |
| 				fs.Close();
 | |
| 			}
 | |
| 		}
 | |
| 		public static T ReadFile(string fileName)
 | |
| 		{
 | |
| 			T t;
 | |
| 			XmlSerializer xs = new XmlSerializer(typeof(T), "http://www.w3.org/2000/html");
 | |
| 			using (FileStream fs = new FileStream(fileName, FileMode.Open))
 | |
| 			{
 | |
| 				t = (T)xs.Deserialize(fs);
 | |
| 			}
 | |
| 			return t;
 | |
| 		}
 | |
| 	}
 | |
| 	public class NonXsiTextWriter : XmlTextWriter
 | |
| 	{
 | |
| 		public NonXsiTextWriter(TextWriter w) : base(w) { }
 | |
| 		public NonXsiTextWriter(Stream w, Encoding encoding)
 | |
| 			: base(w, encoding)
 | |
| 		{
 | |
| 			this.Formatting = Formatting.Indented;
 | |
| 		}
 | |
| 		public NonXsiTextWriter(string filename, Encoding encoding) : base(filename, encoding) { }
 | |
| 		bool _skip = false;
 | |
| 		public override void WriteStartAttribute(string prefix, string localName, string ns)
 | |
| 		{
 | |
| 			if ((prefix == "xmlns" && (localName == "xsd" || localName == "xsi")) || // Omits XSD and XSI declarations. 
 | |
| 				ns == XmlSchema.InstanceNamespace) // Omits all XSI attributes. 
 | |
| 			{
 | |
| 				_skip = true;
 | |
| 				return;
 | |
| 			}
 | |
| 			if (localName == "xlink_href")
 | |
| 				base.WriteStartAttribute(prefix, "xlink:href", ns);
 | |
| 			else
 | |
| 				base.WriteStartAttribute(prefix, localName, ns);
 | |
| 		}
 | |
| 		public override void WriteString(string text)
 | |
| 		{
 | |
| 			if (_skip) return;
 | |
| 			base.WriteString(text);
 | |
| 		}
 | |
| 		public override void WriteEndAttribute()
 | |
| 		{
 | |
| 			if (_skip)
 | |
| 			{ // Reset the flag, so we keep writing. 
 | |
| 				_skip = false;
 | |
| 				return;
 | |
| 			}
 | |
| 			base.WriteEndAttribute();
 | |
| 		}
 | |
| 	}
 | |
| }
 |