コード例 #1
0
        void EditAnnotate(NSObject sender)
        {
            var    element    = (DomHtmlElement)ContentWebView.MainFrame.DomDocument.DocumentElement;
            string htmlString = element.OuterHTML;
            //string htmlText = element.OuterText;  //plainText:{1}
            //string range = ContentWebView.SelectedDomRange.Text;
            //Console.WriteLine ("htmlText:{0}", htmlString);

            string range        = ContentWebView.SelectedDomRange.Text;
            string markupString = string.Format("<span style='color: red; font-style: italic'>{0}</span>", range);

            ContentWebView.ReplaceSelectionWithMarkupString(markupString);
        }
コード例 #2
0
        void LegalDefine(NSObject sender)
        {
            DomRange range        = ContentWebView.SelectedDomRange;
            string   selectedText = range.Text;

            //ContentWebView.Editable = true;
            ContentWebView.ReplaceSelectionWithMarkupString("this");
            //ContentWebView.Editable = false;
//			NSString *markupString = [NSString stringWithFormat:
//				@"<span style='color: red; font-style: italic'>%@</span>",
//				@”SomeString”];
//			[webView replaceSelectionWithMarkupString:markupString];

            this.Invoke(() => {
                var popover      = new NSPopover();
                popover.Behavior = NSPopoverBehavior.Transient;
                popover.ContentViewController = new LegalDefinePopViewController(selectedText, this.TitleCountryCode);
                CGRect rect = new CGRect(menuLocation.X, menuLocation.Y - 60, 5, 5);
                popover.Show(rect, ContentWebView, NSRectEdge.MinYEdge);
            }, 0.0f);
        }