Exemplo n.º 1
0
                public void Destroy(object obj)
                {
                    // release references to our UI objects
                    if (ChildControls != null)
                    {
                        foreach (IUIControl uiControl in ChildControls)
                        {
                            uiControl.RemoveFromView(obj);
                        }

                        // and clear our UI list
                        ChildControls.Clear( );
                    }

                    if (UserNoteControls != null)
                    {
                        // remove (but don't destroy) the notes
                        foreach (IUIControl uiControl in UserNoteControls)
                        {
                            uiControl.RemoveFromView(obj);
                        }

                        UserNoteControls.Clear();
                    }

                    NoteXml = null;
                }
Exemplo n.º 2
0
                // Takes a string and replaces the content of the paragraph with it.
                private void SetText(string text, string activeUrl)
                {
                    foreach (IUIControl control in ChildControls)
                    {
                        control.RemoveFromView(ParentEditingCanvas);
                    }
                    ChildControls.Clear( );

                    // give the text a style that doesn't include things it shouldn't inherit
                    Styles.Style textStyle = mStyle;
                    textStyle.mBorderColor  = null;
                    textStyle.mBorderRadius = null;
                    textStyle.mBorderWidth  = null;

                    // now break it into words so we can do word wrapping
                    string[] words = text.Split(' ');

                    foreach (string word in words)
                    {
                        // create labels out of each one
                        if (string.IsNullOrEmpty(word) == false)
                        {
                            // if the last thing we added was a special control like a reveal box, we
                            // need the first label after that to have a leading space so it doesn't bunch up against
                            // the control
                            string   nextWord  = word;
                            NoteText wordLabel = Parser.CreateNoteText(new CreateParams(this, Frame.Width, Frame.Height, ref textStyle), nextWord + " ");

                            ChildControls.Add(wordLabel);
                        }
                    }

                    if (activeUrl.Trim( ) != EditableConfig.sPlaceholderUrlText && string.IsNullOrWhiteSpace(activeUrl) == false)
                    {
                        // help them out by adding 'https://' if it isn't there.
                        if (activeUrl.StartsWith("https") == false && BibleRenderer.IsBiblePrefix(activeUrl) == false)
                        {
                            activeUrl = activeUrl.Insert(0, "https://");
                        }

                        ActiveUrl = activeUrl;
                    }
                    else
                    {
                        ActiveUrl = null;
                    }

                    TryAddUrlGlyph(Frame.Width, Frame.Height);
                }
Exemplo n.º 3
0
                public void SetStyleValue(EditStyling.Style style, object value)
                {
                    switch (style)
                    {
                    case EditStyling.Style.BoldParagraph:
                    {
                        // force all children to bold
                        foreach (IUIControl child in ChildControls)
                        {
                            IEditableUIControl editableChild = child as IEditableUIControl;
                            if (editableChild != null)
                            {
                                editableChild.SetStyleValue(EditStyling.Style.FontName, EditableParagraph.sDefaultBoldFontName);
                            }
                        }
                        break;
                    }

                    case EditStyling.Style.BoldItalicizeParagraph:
                    {
                        // force all children to bold
                        foreach (IUIControl child in ChildControls)
                        {
                            IEditableUIControl editableChild = child as IEditableUIControl;
                            if (editableChild != null)
                            {
                                editableChild.SetStyleValue(EditStyling.Style.FontName, EditableParagraph.sDefaultBoldItalicFontName);
                            }
                        }
                        break;
                    }

                    case EditStyling.Style.ItalicizeParagraph:
                    {
                        // force all children to bold
                        foreach (IUIControl child in ChildControls)
                        {
                            IEditableUIControl editableChild = child as IEditableUIControl;
                            if (editableChild != null)
                            {
                                editableChild.SetStyleValue(EditStyling.Style.FontName, EditableParagraph.sDefaultItalicFontName);
                            }
                        }
                        break;
                    }

                    case EditStyling.Style.BulletParagraph:
                    {
                        // create a noteText with the bullet, and then insert it
                        XmlTextReader reader = new XmlTextReader(new StringReader("<NT>" + sBulletChar + "</NT>"));
                        reader.Read( );

                        IUIControl bulletText = Parser.TryParseControl(new CreateParams(this, ParentSize.Width, ParentSize.Height, ref mStyle), reader);

                        ChildControls.Insert(0, bulletText);

                        SetPosition(Frame.Left, Frame.Top);

                        bulletText.AddToView(ParentEditingCanvas);

                        break;
                    }

                    case EditStyling.Style.UnderlineParagraph:
                    {
                        // to underline the whole thing, we need to make it one big NoteText.
                        // we'll gather all the text, convert it to a single NoteText with Underlined Attribute,
                        // remove the existing children, and replace them with the new single underlined one.

                        // get the full text. we can use the build HTML stream code to do this.
                        string htmlStream = string.Empty;
                        string textStream = string.Empty;
                        BuildHTMLContent(ref htmlStream, ref textStream, new List <IUIControl>( ));

                        // if the last character is a URL glyph, remove it
                        textStream = textStream.Trim(new char[] { ' ', PrivateNoteConfig.CitationUrl_Icon[0] });

                        XmlTextReader reader = new XmlTextReader(new StringReader("<NT Underlined=\"True\">" + textStream + "</NT>"));
                        reader.Read( );

                        IUIControl noteText = Parser.TryParseControl(new CreateParams(this, ParentSize.Width, ParentSize.Height, ref mStyle), reader);

                        foreach (IUIControl control in ChildControls)
                        {
                            control.RemoveFromView(ParentEditingCanvas);
                        }
                        ChildControls.Clear( );


                        ChildControls.Add(noteText);

                        SetPosition(Frame.Left, Frame.Top);

                        noteText.AddToView(ParentEditingCanvas);

                        break;
                    }
                    }
                }