using System;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
namespace dwf.tool
{
public class PColumnMap : LayoutMap
{
[NonSerialized()]
protected PListInfo _info;
public PColumnMap()
{
base.Items.ListChanged += ItemsListChanged;
}
~PColumnMap()
{
base.Items.ListChanged -= ItemsListChanged;
}
private void ItemsListChanged(object sender, ListChangedEventArgs e)
{
if (((PColumnMap)TopMap).Info != null)
((PColumnMap)TopMap).Info.OnBoundChanged(EventArgs.Empty);
}
public PColumnMap(PListInfo info)
{
this._info = info;
}
public PListInfo Info
{
get { return _info; }
set { _info = value; }
}
public override float Scale
{
get { return _info == null ? base.Scale : _info.Scale; }
set { _info.Scale = value; }
}
public RectangleF GetBound(float max, CalcWidthDelegate wd, CalcHeightDelegate hd)
{
return LayoutMapTool.GetBound(this, new SizeF(max, 0), wd, hd);
}
public RectangleF GetBound(ILayoutMapItem column, RectangleF temp, CalcWidthDelegate wd, CalcHeightDelegate hd)
{
return LayoutMapTool.GetBound(this, column, temp, wd, hd);
}
//moving column to some side of other column
public void Move(ILayoutMapItem moved, ILayoutMapItem destination, LayoutAlignType anch, bool builGroup)
{
LayoutMapTool.Move(moved, destination, anch, builGroup);
((PColumnMap)TopMap).Info.OnBoundChanged(EventArgs.Empty);
}
public List<PColumn> GetDisplayed(RectangleF clip, RectangleF temp, CalcWidthDelegate wd, CalcHeightDelegate hd)
{
List<ILayoutMapItem> cols = LayoutMapTool.GetItems(this);
List<PColumn> buf = new List<PColumn>();
foreach (ILayoutMapItem col in cols)
{
if (col.Visible)
{
RectangleF rec = GetBound(col, temp, wd, hd);
rec.X += _info.HeaderWidth + 1;// leftPadding
rec.Width -= 1;
if (rec.Right > clip.Left && rec.Left < clip.Right)
buf.Add((PColumn)col);
}
}
return buf;
}
public void _Clear()
{
items.Clear();
}
public void Clear()
{
_Clear();
}
public void Replace(ILayoutMapItem oldColumn, ILayoutMapItem newColumn)
{
LayoutMapTool.Replace(oldColumn, newColumn);
}
public PColumn Add(string property, float width = 100, int row = 0, int col = 0)
{
PColumn column = new PColumn();
column.Name = property;
column.Width = width;
column.Row = row;
column.Col = col;
Add(column);
return column;
}
public void Add(ILayoutMapItem column)
{
LayoutMapTool.Add(this, column);
}
public void Insert(ILayoutMapItem column, bool inserRow)
{
LayoutMapTool.Insert(this, column, inserRow);
}
public void InsertAfter(ILayoutMapItem column, ILayoutMapItem excolumn)
{
column.Row = excolumn.Row;
column.Col = excolumn.Col + 1;
Insert(column, false);
}
public bool Remove(ILayoutMapItem column)
{
return LayoutMapTool.Remove(column);
}
public void Reset()
{
LayoutMapTool.Reset(this);
}
public List<ILayoutMapItem> GetVisible()
{
List<ILayoutMapItem> list = LayoutMapTool.GetVisibleItems(this);
return list;
}
public void InsertWith(PColumn newvalue, PColumn oldvalue, bool p)
{
throw new NotImplementedException();
}
}
}