//---------------------------------------------------------------------------------------------------------------------------------------------------
//
// Copyright (C)2007 DarkWynter Studios. All rights reserved.
//
//---------------------------------------------------------------------------------------------------------------------------------------------------
// {Contact : darkwynter.com for licensing information
//---------------------------------------------------------------------------------------------------------------------------------------------------
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Xml;
namespace DarkWynter.App
{
public class ContentPanel : Panel
{
// Init vars
public string panelName = "";
public XmlNode node;
public List attributeNodes = new List();
// Location and size of levelEditorPanel and contentPanels
public static Point location = new Point(285, 15);
public static Size size = new Size(700, 700);
///
///
///
public ContentPanel(){}
///
///
///
public ContentPanel(XmlNode contentNode, Point location, Size size)
{
// Save node
node = contentNode;
// Init Panel
this.Location = location;
this.Size = size;
this.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D;
this.AutoScroll = true;
// Reset carriage return to top of page
AttributeNode.rowLocation = AttributeNode.topOfPage;
// Save Parent Element Name
panelName = contentNode.Name;
// Create Label from Xml Element Name and Add to Panel
AttributeNode labelNode = new AttributeNode(this, panelName);
this.Controls.Add(labelNode.label);
// Create Property Boxes
for (int i = 0; i < contentNode.Attributes.Count; i++)
{
// Create a participle node
AttributeNode formNode = new AttributeNode(this, contentNode.Attributes[i]);
// Save to the List
attributeNodes.Add(formNode);
}
}
public ContentPanel Clone()
{
// Create new Panel and init
ContentPanel clonePanel = new ContentPanel();
clonePanel.panelName = this.panelName;
clonePanel.Location = this.Location;
clonePanel.Size = this.Size;
clonePanel.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D;
clonePanel.AutoScroll = true;
// Reset carriage return to top of page
AttributeNode.rowLocation = AttributeNode.topOfPage;
// Copy Attribute Nodes
for (int i = 0; i < attributeNodes.Count; i++)
{
// Clone existing attribute node and add to clonePanel
AttributeNode newNode = attributeNodes[i].Clone(clonePanel);
clonePanel.attributeNodes.Add(newNode);
}
return clonePanel;
}
public void ToXml(XmlTextWriter settingsFile )
{
settingsFile.WriteStartElement(panelName);
for (int i = 0; i < attributeNodes.Count; i++)
{
settingsFile.WriteAttributeString(
attributeNodes[i].label.Text,
attributeNodes[i].textBox.Text);
}
settingsFile.WriteEndElement();
}
}
}