コード例 #1
0
        public string GetFormattedBody(IResource res, string body, string replyToBody,
                                       ref WordPtr[] offsets, string fontFace, int fontSize)
        {
            string formattedText;
            string subject        = res.GetPropText(Core.Props.Subject);
            bool   needFormatting = res.HasProp("NoFormat");

            // If no offsets passed, default to the simple processing
            if ((offsets == null) || (offsets.Length == 0))
            {
                formattedText = GetFormattedText(needFormatting, body, replyToBody, subject, null, fontFace, fontSize);
            }
            else
            {
                // Save offsets, format text, retrieve offsets.
                using (MarkerInjector injector = new MarkerInjector())
                {
                    WordPtr[] modOffs = DocumentSection.RestrictResults(offsets, DocumentSection.BodySection);
                    body          = injector.InjectMarkers(body, modOffs);
                    formattedText = GetFormattedText(needFormatting, body, replyToBody, subject, injector, fontFace, fontSize);
                    formattedText = injector.CollectMarkers(formattedText, out modOffs);
                }
            }
            return(formattedText);
        }
コード例 #2
0
        public void DisplayResource(IResource resource, WordPtr[] wordsToHighlight)
        {
            _displayedResource = resource;
            if (resource.HasProp(Core.Props.LongBodyIsRTF))
            {
                _rtfDisplayPane.GetControl().Visible = true;
                Core.WebBrowser.Visible = false;
                _rtfDisplayPane.DisplayResource(resource);

                if (wordsToHighlight != null)
                {
                    HighlightWords(wordsToHighlight);
                }
            }
            else
            {
                // Ensure the Web browser is hosted on our pane
                _panel.Controls.Add(Core.WebBrowser);
                Core.WebBrowser.Dock            = DockStyle.Fill;
                Core.WebBrowser.Visible         = true;
                Core.WebBrowser.ContextProvider = this;
                _rtfDisplayPane.GetControl().Visible = false;
                WebSecurityContext context           = WebSecurityContext.Restricted;
                context.WorkOffline = false;
                Core.WebBrowser.ShowHtml(resource.GetPropText(Core.Props.LongBody), context,
                                         DocumentSection.RestrictResults(wordsToHighlight, DocumentSection.BodySection));
            }
        }
コード例 #3
0
        /**
         * This method is called by IEBrowserDisplayPane to display the specified resource
         * in the browser.
         */

        private void DisplayConversation(IResource resource, AbstractWebBrowser browser, WordPtr[] wordsToHighlight)
        {
            // Ask ConversationManager to format the conversation as HTML and
            // feed it into IEBrowser.
            string htmlString = _convManager.ToHtmlString(resource, _propNick);

            browser.ShowHtml(htmlString, WebSecurityContext.Restricted, DocumentSection.RestrictResults(wordsToHighlight, DocumentSection.BodySection));
        }
コード例 #4
0
        /**
         * Shows the text of the currently displayed conversation in IEBrowser.
         */

        private void DisplayCurrentConversation()
        {
            if (_currentConvList != null)
            {
                string htmlString = _convManager.ToHtmlString(_currentConvList[0], _propNickName);
                Core.WebBrowser.ShowHtml(htmlString, WebSecurityContext.Restricted, DocumentSection.RestrictResults(_wordsToHighlight, DocumentSection.BodySection));
            }
        }
コード例 #5
0
 protected void ShowSubject(string text, WordPtr[] toHighlight)
 {
     _editSubject.Text = text;
     if (toHighlight != null)
     {
         WordPtr[] restrictedWords = DocumentSection.RestrictResults(toHighlight, DocumentSection.SubjectSection);
         _editSubject.HighlightWords(restrictedWords);
     }
 }
コード例 #6
0
 private static void DisplayHTML(IResource resource, AbstractWebBrowser browser, WordPtr[] wordsToHighlight)
 {
     try
     {
         StreamReader reader = Core.FileResourceManager.GetStreamReader(resource);
         if (reader != null)
         {
             string sourceUrl = "";
             string htmlText  = Utils.StreamReaderReadToEnd(reader);
             reader.BaseStream.Close();
             IResource source = FileResourceManager.GetSource(resource);
             if (source != null)
             {
                 string url = string.Empty;
                 if (Core.ResourceStore.PropTypes.Exist("URL"))
                 {
                     url = source.GetPropText("URL");
                 }
                 if (url.Length > 0)
                 {
                     sourceUrl = url;
                     htmlText  = HtmlTools.FixRelativeLinks(htmlText, url);
                 }
                 else
                 {
                     string directory = source.GetPropText("Directory");
                     if (directory.Length > 0)
                     {
                         if ((!directory.EndsWith("/")) && (!directory.EndsWith("\\")))
                         {
                             directory += "/";
                         }
                         htmlText = HtmlTools.FixRelativeLinks(htmlText, directory);
                     }
                 }
             }
             try
             {
                 WebSecurityContext context = WebSecurityContext.Restricted;
                 context.WorkOffline = false;
                 browser.ShowHtml(htmlText, context,
                                  DocumentSection.RestrictResults(wordsToHighlight, DocumentSection.BodySection));
                 browser.CurrentUrl = sourceUrl;
             }
             catch (Exception e)
             {
                 Trace.WriteLine(e.ToString(), "Html.Plugin");
             }
         }
     }
     catch (ObjectDisposedException) {}
 }
コード例 #7
0
/*
 *      protected void ShowPlainTextAsRtf( string text, WordPtr[] wordsToHighlight )
 *      {
 *          _editRtfBody.Show();
 *          _ieBrowser.Hide();
 *          _editRtfBody.Select();
 *          _editRtfBody.Clear();
 *          _editRtfBody.Text = text;
 *          _editRtfBody.Font = new Font("Courier New", 10F, FontStyle.Regular, GraphicsUnit.Point, 204);
 *          if ( wordsToHighlight != null )
 *          {
 *              _editRtfBody.HighlightWords( DocumentSection.RestrictResults(wordsToHighlight, DocumentSection.BodySection ));
 *          }
 *      }
 *
 */
        public void HighlightWords(WordPtr[] wordsToHighlight)
        {
            Guard.NullArgument(wordsToHighlight, "wordsToHighlight");
            _editSubject.HighlightWords(DocumentSection.RestrictResults(wordsToHighlight, DocumentSection.SubjectSection));
            if (_ieBrowser.Visible)
            {
                _ieBrowser.HighlightWords(DocumentSection.RestrictResults(wordsToHighlight, DocumentSection.BodySection), 0);
            }
            else if (_editRtfBody.Visible)
            {
                _editRtfBody.HighlightWords(DocumentSection.RestrictResults(wordsToHighlight, DocumentSection.BodySection));
            }
        }
コード例 #8
0
 public void HighlightWords(WordPtr[] words)
 {
     words = DocumentSection.RestrictResults(words, DocumentSection.BodySection);
     if (_richTextBox.Visible)
     {
         _richTextBox.HighlightWords(words);
     }
     else
     {
         Core.WebBrowser.HighlightWords(words, 0);
         _wordsToHighlight = words;
     }
 }
コード例 #9
0
 protected void ShowRtf(string rtf, WordPtr[] wordsToHighlight)
 {
     _editRtfBody.Show();
     _ieBrowser.Hide();
     try
     {
         _editRtfBody.Rtf = rtf;
         if (wordsToHighlight != null)
         {
             _editRtfBody.HighlightWords(DocumentSection.RestrictResults(wordsToHighlight, DocumentSection.BodySection));
         }
     }
     catch (ArgumentException exc)
     {
         Core.ReportBackgroundException(exc);
         _editRtfBody.Text = "Cannot display this message. Error occured while reading RTF format.";
     }
 }
コード例 #10
0
        public string GetFormattedHtmlBody(IResource res, string body, ref WordPtr[] offsets)
        {
            string formattedText;
            string subject = res.GetPropText(Core.Props.Subject);

            // If no offsets passed, default to the simple processing
            if ((offsets == null) || (offsets.Length == 0))
            {
                formattedText = InsertHeaderWithStyle(body, subject);
            }
            else
            {
                // Save offsets, format text, retrieve offsets.
                using (MarkerInjector injector = new MarkerInjector())
                {
                    WordPtr[] modOffs = DocumentSection.RestrictResults(offsets, DocumentSection.BodySection);
                    body          = injector.InjectMarkers(body, modOffs);
                    formattedText = InsertHeaderWithStyle(body, subject);
                    formattedText = injector.CollectMarkers(formattedText, out modOffs);
                }
            }
            return(formattedText);
        }
コード例 #11
0
 /// <summary>
 /// Method shows html-formatted text in the browser. Offsets for highlighting are
 /// restricted to the <see cref="DocumentSection.BodySection">BodySection</see> section.
 /// </summary>
 protected void ShowHtml(string html, WebSecurityContext securityContext, WordPtr[] toHighlight)
 {
     AttachWebBrowser();
     WordPtr[] restrictedWords = DocumentSection.RestrictResults(toHighlight, DocumentSection.BodySection);
     _ieBrowser.ShowHtml(html, securityContext, restrictedWords);    // Use the updated offsets
 }
コード例 #12
0
ファイル: RTFDisplayPane.cs プロジェクト: mo5h/omeo
 public void HighlightWords(WordPtr[] words)
 {
     _richTextBox.HighlightWords(DocumentSection.RestrictResults(words, DocumentSection.BodySection));
 }
コード例 #13
0
ファイル: ICQPlugin.cs プロジェクト: mo5h/omeo
 /**
  * displays conversation as auto-generated html text
  */
 private void DisplayConversation(IResource resource, AbstractWebBrowser browser, WordPtr[] wordsToHighlight)
 {
     try
     {
         browser.ShowHtml(_conversationManager.ToHtmlString(resource, _propNickName), WebSecurityContext.Restricted, DocumentSection.RestrictResults(wordsToHighlight, DocumentSection.BodySection));
     }
     catch (Exception e)
     {
         Trace.WriteLine(e.ToString(), "ICQ.Plugin");
         return;
     }
     _displayedResource = resource.ToResourceListLive();
     _displayedResource.ResourceChanged += ConversationChangedHandler;
 }
コード例 #14
0
 public void DisplayResource(IResource resource, WordPtr[] wordsToHighlight)
 {
     _wordsToHighlight = DocumentSection.RestrictResults(wordsToHighlight, DocumentSection.BodySection);
     DisplayResource(resource);
 }
コード例 #15
0
 public void HighlightWords(WordPtr[] words)
 {
     words = DocumentSection.RestrictResults(words, DocumentSection.BodySection);
     Core.WebBrowser.HighlightWords(words, 0);
     _wordsToHighlight = words;
 }
コード例 #16
0
 internal void HighlightWords(WordPtr[] words)
 {
     _editSubject.HighlightWords(DocumentSection.RestrictResults(words, DocumentSection.SubjectSection));
 }