Thursday, April 26, 2007

I have decided to resolve the synchronization between the draw:control in the contents nodes and the appropriate form:form element in the following way:

A new auxiliary class AODL.Document.Forms.Controls.OOControlRef will be added; this is an internal AODL class that stands for draw:control tag. It will have such properties as ID, X,Y,Width,Height,AnchorType, AnchorPageNumber,StyleName,TextStyleName and others that reflect draw:control attributes. And, of course, it will have a set of common properties such as Node.

OOFormControl will be a basic class for all form controls. All specific controls such as Button will derive from it.OOFormControl will have an internal variable _controlRef (OOControlRef) that represents its reference; all the public properties of _controlRef will be accessible through public OOFormControl properties.

OOFormControl will have a constructor taking parent form, content container and ID string as obligatory parameters. Of course, there will be other handy overloaded constructors with more parameters.

OOForm's controls collection will have Inserted and Removed events to implement the synchronization:
private void ControlsCollection_Inserted(int index, object value)
{
OOFormControl ctrl = value as OOFormControl;
this._FNode.AppendChild(ctrl.Node);
ctrl._contentCollection.Add(ctrl._controlRef);
}

private void ControlsCollection_Removed(int index, object value)
{
OOFormControl ctrl = value as OOFormControl;
this._FNode.RemoveChild(ctrl.Node);
ctrl._contentCollection.Remove(ctrl._controlRef);
}

I'll also add appropriate deletion of control in form:form tag when the reference is deleted.

No comments: