i'm building a class named inxblock. here is the summary: i'm trying through this class to modelize a block on an Adobe InDesign document. this block is caracterize by its anchor point(x,y) coordinate the width and height of the block. but the block can be in a parent block or have itself children.
using
System;using
System.Collections.Generic;using
System.Collections.ObjectModel;using
System.ComponentModel;using
System.IO;using
System.Xml;namespace
Hot2Inx{
class InxBlock{
//the dimensions of the blocks: width, height and coordinates x,y of the anchor point. private double _x; private double _y; private double _width; private double _height; //private string self;//the self attribute //private string typeName; //the type of block public Collection <InxBlock> Children = new Collection<InxBlock>(); private InxBlock _parent ; //set the properties of the attributes public double X{
get { return _x; } set { _x = value; }}
// end property X public double Y{
get { return _y; } set { _y = value; }}
// end property Y public double Height{
get { return _height; } set { _height = value; }}
// end property Height public double Width{
get { return _width; } set { _width = value; }}
// end property Width //public string Self //{ // get { return self; } // set { bSelf = value; } //}// end property Self //public string TypeName //{ // get { return typeName; } // set { typeName = value; } //}// end property TypeName public InxBlock Parent{
get { return _parent; } set{
if (_parent != null){
_parent.Children.Remove(
this);}
//end if_parent.Children.Add(
this);}
}
// end property Parent public InxBlock(InxBlock inxParent){
if (inxParent != null){
this.Parent = inxParent;}
//end if}
// end InxBlock constructor ///{
//the coordinates of parent block double px = Parent._x; double py = Parent._y; double pw = Parent._width; double ph = Parent._height; //the child coordinates in the parent coordinate space double cx = _x - (px + pw / 2); double cy = _y - (py + ph / 2);}
//end LayoutBlockpublic XmlNode CreateInxNode()
{
XmlNode inxnode = null; string igeo = IGeometry.GetIGeometry(_x, _y, _width, _height);addAttribute(inxnode,
"IGeo", igeo); return inxnode;}
//end CreateInxNode ///{
XmlNode newAttribute; XmlNode cAttribute;cAttribute = node.Attributes.GetNamedItem(attributeName);
if (cAttribute == null){
newAttribute = node.OwnerDocument.CreateAttribute(attributeName);
newAttribute.InnerText = value;
node.Attributes.SetNamedItem(newAttribute);
}
else{
cAttribute.Value = value;
}
}
//end addAttribute
}
//end class InxBlock}
//end namespace Hot2Inx
Replies
Know the answer? Post it — somebody with the same question will find it here.