using System;
using System.Collections;
using System.Windows.Forms;
namespace YariSoft.DBCommander.Misc{
[Serializable]
public class GridStyleInfo
{
#region Local Variables
Hashtable styles = null;
#endregion
#region Properties
#endregion
#region Constructor/Destructor
public GridStyleInfo()
{
this.styles = new Hashtable();
}
#endregion
#region Public functions
public void Clear ()
{
this.styles.Clear();
}
public Hashtable Add ( DataGridTableStyle style )
{
Hashtable columnsStyle = new Hashtable();
foreach( DataGridColumnStyle columnStyle in style.GridColumnStyles ){
columnsStyle.Add( columnStyle.MappingName, columnStyle.Width );
}
this.styles.Add( style.MappingName, columnsStyle );
return columnsStyle;
}
public void Update ( DataGridTableStyle style )
{
Hashtable columnsStyle = ( Hashtable )this.styles[ style.MappingName ];
if( columnsStyle == null ){
columnsStyle = this.Add( style );
return;
}
foreach( DataGridColumnStyle columnStyle in style.GridColumnStyles ){
columnsStyle[ columnStyle.MappingName ] = columnStyle.Width;
}
}
public void Update ( GridTableStylesCollection styles )
{
foreach( DataGridTableStyle style in styles ){
this.Update( style );
}
}
public bool SetStyleToGrid ( DataGridTableStyle style )
{
Hashtable columnsStyle = ( Hashtable )this.styles[ style.MappingName ];
if( columnsStyle == null ){
return false;
}
foreach( DataGridColumnStyle columnStyle in style.GridColumnStyles ){
columnStyle.Width = ( int )columnsStyle[ columnStyle.MappingName ];
}
return true;
}
#endregion
}
}
|