public override void AddChildControl(Control child) { base.AddChildControl(child); if (ChildControls.IndexOf(child) == menuItemIndex) { child.Theme = themeSelected; } }
public void HandleChildStyleChanged(EditStyling.Style style, IEditableUIControl childControl) { switch (style) { case EditStyling.Style.RevealBox: { // first, find the target in our list int targetIndex = 0; foreach (IUIControl child in ChildControls) { // when we find it if (child.Equals(childControl) == true) { // take its index, and remove it from the renderer and our list of children targetIndex = ChildControls.IndexOf(child); child.RemoveFromView(ParentEditingCanvas); ChildControls.RemoveAt(targetIndex); break; } } // if we received RevealBox, we're either upgrading a NoteText to BE a RevealBox, // or downgrading a RevealBox to be a normal NoteText. EditableNoteText editableNoteText = childControl as EditableNoteText; if (editableNoteText != null) { // create a new revealBox, but force the text to uppper-case and add the bold font (since this is typically what the Mobile App does) Style controlStyle = childControl.GetControlStyle( ); controlStyle.mFont = new FontParams( ); controlStyle.mFont.mName = sDefaultBoldFontName; RevealBox newRevealBox = Parser.CreateRevealBox(new CreateParams(this, Frame.Width, Frame.Height, ref controlStyle), editableNoteText.GetText( ).ToUpper( ).Trim( )); newRevealBox.AddToView(ParentEditingCanvas); // add the new revealBox into the same spot as what it's replacing ChildControls.Insert(targetIndex, newRevealBox); // make sure we add a space after the reveal box, as that's required. NoteText textLabel = Parser.CreateNoteText(new CreateParams(this, Frame.Width, Frame.Height, ref mStyle), " "); textLabel.AddToView(ParentEditingCanvas); ChildControls.Insert(targetIndex + 1, textLabel); } EditableRevealBox editableRevealBox = childControl as EditableRevealBox; if (editableRevealBox != null) { // create a new revealBox that has the styling and text of the noteText it's replacing. Style controlStyle = childControl.GetControlStyle( ); NoteText newNoteText = Parser.CreateNoteText(new CreateParams(this, Frame.Width, Frame.Height, ref controlStyle), editableRevealBox.GetText( ).Trim( )); newNoteText.AddToView(ParentEditingCanvas); // add the new revealBox into the same spot as what it's replacing ChildControls.Insert(targetIndex, newNoteText); } break; } } // for now, lets just redo our layout. SetPosition(Frame.Left, Frame.Top); }