//--------------------------------------------------------------------------------------------------------------------------------------------------- // // 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 AttributeNode { public static int colLocation = 16; public static int rowLocation = 16; public static int labelWidth = 100; public static int labelHeight = 16; public static int textWidth = 400; public static int textHeight = 20; public static int columnSpacer = 25; public static int rowWidth = 32; public static int topOfPage = 16; public TextBox textBox; public Label label; public XmlAttribute attribute; public int nodeType; /// /// Create and Position a standard Label /// /// Panel you are using /// The Text for the Label public AttributeNode(Panel panel, String labelText) { // Move cursor to next row down rowLocation += rowWidth; nodeType = 0; // Create Lable label = new Label(); label.Text = labelText; label.Location = new Point(colLocation, rowLocation); label.Size = new Size(labelWidth, labelHeight); // Style label.ForeColor = Color.LightGray; label.Font = new Font(label.Font, FontStyle.Bold); // Add to Panel panel.Controls.Add(label); } /// /// Convert an Xml Object into a Label and TextBox /// /// Panel you are using /// Attributes from the node public AttributeNode(Panel panel, XmlAttribute nodeAttribute) { // Move cursor to next row down rowLocation += rowWidth; nodeType = 1; attribute = nodeAttribute; // Create Label label = new Label(); label.Text = attribute.Name; label.Location = new Point(colLocation, rowLocation); label.Size = new Size(labelWidth, labelHeight); // Style label.ForeColor = Color.LightGray; // Create Textbox textBox = new TextBox(); textBox.Text = attribute.Value; textBox.Location = new Point(labelWidth + columnSpacer, rowLocation); textBox.Size = new Size(textWidth, textHeight); // Add to Panel panel.Controls.Add(label); panel.Controls.Add(textBox); } /// /// Clones the Label /// /// Panel you are using /// AttributeNode public AttributeNode Clone(Panel panel) { // Reset carriage return to top of page AttributeNode.rowLocation = AttributeNode.topOfPage; // Init Clone Node AttributeNode attrNode = new AttributeNode(panel, attribute); attrNode.nodeType = nodeType; // Clone Label attrNode.label = new Label(); attrNode.label.Text = label.Text; attrNode.label.Location = label.Location; attrNode.label.Size = label.Size; // Clone Textbox if (nodeType == 1) { attrNode.textBox.Text = textBox.Text; attrNode.textBox.Location = textBox.Location; attrNode.textBox.Size = textBox.Size; } return attrNode; } } }