The object:
[Serializable]
public enum LiteType
{
Row,
Col,
Main
}
/// <summary>
/// Container for the dlo lite object
/// </summary>
[XmlRootAttribute("Lite", Namespace = "", IsNullable = false)]
public class cLite
{
#region private members
private cLite m_parentLite = null;
private cLites m_childLites;
private string m_Name = "";
private LiteType m_liteType;
private double m_Width = 0;
private double m_Height = 0;
private double m_SillOffset = 0;
#endregion
#region public members
// the parent lite or null if this is the root note
[XmlElementAttribute("parentLite", typeof(cLite))]
public cLite ParentLite
{
get { return m_parentLite; }
set { m_parentLite = value; }
}
// the name string
[XmlElementAttribute("Name")]
public string Name
{
get { return m_Name; }
set { m_Name = value; }
}
// the child lites collection
[XmlArray("childLites"),
XmlArrayItem("childLite", typeof(cLite))]
public cLites ChildLites
{
get { return m_childLites; }
set { m_childLites = value; }
}
[XmlElementAttribute("LiteType", typeof(LiteType))]
public LiteType liteType
{
get { return m_liteType; }
set { m_liteType = value; }
}
[XmlElementAttribute("Width")]
public double Width
{
get { return m_Width; }
set { m_Width = value; }
}
[XmlElementAttribute("Height")]
public double Height
{
get { return m_Height; }
set { m_Height = value; }
}
// the offset of the bottom of the lite - this is used so we can drop
// the jamb members for a door that would run down to the floor, ignoring
// any sill gap
// These would only be used in the vertical sense of the primary children
// basically the initial rows of the mark
[XmlElementAttribute("SillOffset")]
public double SillOffset
{
get { return m_SillOffset; }
set { m_SillOffset = value; }
}
#endregion
// default constructor
public cLite() :this("No Name", 0, 0, LiteType.Main)
{
// default constructor calls the other one
}
// constructor to use
public cLite(string name, double Width, double Height, LiteType lType)
{
m_Name = name;
m_Width = Width;
m_Height = Height;
m_liteType = lType;
m_childLites = new cLites(this);
}
}
The collection:
// this is basically the child lites collection
[Serializable]
public class cLites :CollectionBase
{
// constructor - when the collection is created, you need a parent lite
// to add to all of the children created from the add method
public cLites(cLite parent)
{
m_parentLite = parent;
}
#region private members
// parent lite
private cLite m_parentLite;
#endregion
#region public Members
[XmlElementAttribute("parentLite", typeof(cLite))]
public cLite ParentLite
{
get { return m_parentLite; }
set { m_parentLite = value; }
}
#endregion
// the collection stuff
public int Add(cLite child)
{
child.ParentLite = m_parentLite;
return List.Add(child);
}
public void Remove(cLite child)
{
List.Remove(child);
}
public void Insert(int index, cLite child)
{
List.Insert(index, child);
}
public cLite this[int index]
{
get { return (cLite)List[index]; }
set { List[index] = value; }
}
}
Good point on the framework - 2.0
No autocad required