Exemplo n.º 1
0
                public string Export(RectangleF parentPadding, float currYPos)
                {
                    // start by setting our position to our global position, and then we'll translate.
                    float controlLeftPos = Frame.Left;
                    float controlTopPos  = Frame.Top;

                    // for vertical, it's relative to the control above it, so just make it relative to that
                    IUIControl logicalParent = ParentNote.GetLogicalVerticalParent(this);

                    if (logicalParent != null)
                    {
                        controlTopPos -= logicalParent.GetFrame( ).Bottom;
                    }
                    else
                    {
                        controlTopPos -= currYPos;
                    }

                    // for horizontal, it just needs to remove padding, since it'll be re-applied on load
                    controlLeftPos -= parentPadding.Left;

                    string xml = "<P ";

                    string attributes = "";

                    controlLeftPos /= (ParentSize.Width - parentPadding.Left - parentPadding.Right);
                    attributes     += string.Format("Left=\"{0:#0.00}%\"", controlLeftPos * 100);


                    attributes += string.Format(" Top=\"{0}\"", controlTopPos);

                    if (string.IsNullOrWhiteSpace(ActiveUrl) == false)
                    {
                        attributes += string.Format(" Url=\"{0}\"", HttpUtility.HtmlEncode(ActiveUrl));
                    }

                    xml += attributes + ">";

                    foreach (IUIControl child in ChildControls)
                    {
                        IEditableUIControl editableChild = child as IEditableUIControl;
                        if (editableChild != null)
                        {
                            // children of paragraphs cannot set their own position, so pass 0
                            xml += editableChild.Export(new RectangleF( ), 0);
                        }
                    }

                    xml += "</P>";

                    return(xml);
                }
Exemplo n.º 2
0
                public string Export( )
                {
                    string xmlExport = "<Note " + sDefaultNoteAttribs + ">";

                    // first, sort all controls by Y. That way, if something was created and then moved UP, it won't
                    // have a negative value
                    ChildControls.Sort(delegate(IUIControl a, IUIControl b)
                    {
                        if (a.GetFrame( ).Top < b.GetFrame( ).Top)
                        {
                            return(-1);
                        }
                        return(1);
                    });

                    foreach (IUIControl child in ChildControls)
                    {
                        IEditableUIControl editableChild = child as IEditableUIControl;
                        xmlExport += editableChild.Export(new RectangleF(Padding.Left, Padding.Top, 0, 0), 0);
                    }

                    xmlExport += "</Note>";
                    return(xmlExport);
                }