Esempio n. 1
0
                public void HandleDelete(bool notifyParent)
                {
                    // first, delete all our child controls
                    int i = 0;

                    for (i = ChildControls.Count - 1; i >= 0; i--)
                    {
                        // since we DO support child controls that are containers, call HandleDelete on all our children
                        IEditableUIControl editableControl = ChildControls[i] as IEditableUIControl;
                        if (editableControl != null)
                        {
                            // let them know not to inform their parent, since that's us.
                            editableControl.HandleDelete(false);
                        }
                        else
                        {
                            // if it's not editable, we need to remove it ourselves
                            ChildControls[i].RemoveFromView(ParentEditingCanvas);
                        }

                        ChildControls.Remove(ChildControls[i]);
                    }

                    // clean ourselves up
                    RemoveFromView(ParentEditingCanvas);

                    // notify our parent if we need to
                    if (notifyParent)
                    {
                        ParentNote.HandleChildDeleted(this);
                    }
                }
Esempio n. 2
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);
                }