コード例 #1
0
ファイル: StyleBar.cs プロジェクト: sqrg/RichTextEditor
        public StyleBar()
        {
            BarLayout = new StackLayout
            {
                Orientation = StackOrientation.Horizontal,
                Children    =
                {
                    BoldButton,
                    ItalicButton,
                    UnderlineButton
                }
            };
            Content = BarLayout;

            ItalicButton.Clicked += (sender, e) =>
            {
                System.Diagnostics.Debug.WriteLine("Italic Button Clicked!");
                var styleArg = new HtmlEditor.StyleArgs("italic");
                MessagingCenter.Send(ItalicButton, "styleClicked", styleArg);
            };

            BoldButton.Clicked += (sender, e) =>
            {
                System.Diagnostics.Debug.WriteLine("Bold Button Clicked!");
                var styleArg = new HtmlEditor.StyleArgs("bold");
                MessagingCenter.Send(BoldButton, "styleClicked", styleArg);
            };

            UnderlineButton.Clicked += (sender, e) =>
            {
                System.Diagnostics.Debug.WriteLine("Underline Button Clicked!");
                var styleArg = new HtmlEditor.StyleArgs("underline");
                MessagingCenter.Send(UnderlineButton, "styleClicked", styleArg);
            };
        }
コード例 #2
0
        private void OnStyleChangeRequested(object sender, HtmlEditor.StyleArgs e)
        {
            AttributedText = new NSMutableAttributedString(Control.AttributedText);
            if (Control.TypingAttributes != null)
            {
                CurrentTypingAttributes = new NSMutableDictionary(Control.TypingAttributes);
            }
            System.Diagnostics.Debug.WriteLine("Rendering Style Change: " + e.Style);

            if (e.Style == "bold")
            {
                var fontAttr = UIFontDescriptorSymbolicTraits.Bold;
                UpdateStyleAttributes(fontAttr);
            }
            else if (e.Style == "italic")
            {
                var fontAttr = UIFontDescriptorSymbolicTraits.Italic;
                UpdateStyleAttributes(fontAttr);
            }
            else if (e.Style == "underline")
            {
                var underlineAttr = UIStringAttributeKey.UnderlineStyle;
                UpdateUnderlineAttributes();
            }
            SaveChanges(Control.SelectedRange);
        }
コード例 #3
0
        private void OnStyleChangeRequested(object sender, HtmlEditor.StyleArgs e)
        {
            EditableText = Control.EditableText;
            Console.WriteLine("Style Change Requested!");

            if (e.Style == "bold")
            {
                var flag = TypefaceStyle.Bold;
                UpdateStyleSpans(flag);
            }
            else if (e.Style == "italic")
            {
                var flag = TypefaceStyle.Italic;
                UpdateStyleSpans(flag);
            }
            else if (e.Style == "underline")
            {
                UpdateUnderlineSpans();
            }
        }