Example #1
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));
            }
        }
Example #2
0
        public NotePreviewPane()
        {
            InitializeComponent();

            // Initialize the security context
            _ctxRestricted              = WebSecurityContext.Restricted;
            _ctxRestricted.WorkOffline  = false; // Enable downloading of the referenced content
            _ctxRestricted.ShowPictures = true;
        }
Example #3
0
        public TaskDisplayPane()
        {
            InitializeComponent();

            // Initialize the security context
            _ctxRestricted              = WebSecurityContext.Trusted;
            _ctxRestricted.WorkOffline  = false; // Enable downloading of the referenced content
            _ctxRestricted.ShowPictures = true;

            _headerPane.Visible = false;
        }
Example #4
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) {}
 }
Example #5
0
        public ArticlePreviewPane()
        {
            InitializeComponent();

            // Initialize the security context
            _ctxRestricted             = WebSecurityContext.Restricted;
            _ctxRestricted.WorkOffline = false;                 // Enable downloading of the referenced content

            ReadNewsarticleFontAttributes();

            Core.UIManager.AddOptionsChangesListener("Internet", "Newsgroups", ReadNewsarticleFontAttributesHandler);
            Core.UIManager.AddOptionsChangesListener("Omea", "General", ReadNewsarticleFontAttributesHandler);
        }
Example #6
0
        public FragmentEditPane()
        {
            _ctxDisplayClipping                        = WebSecurityContext.Restricted;
            _ctxDisplayClipping.WorkOffline            = false;
            _ctxDisplayClipping.AllowInPlaceNavigation = false;

            // This call is required by the Windows.Forms Form Designer.
            InitializeComponent();
            _richTextBox.ContextProvider   = this;
            _edtAnnotation.ContextProvider = this;

            // Some custom init (to be not affected by the forms designer)
            InitializeBrowserComponent();
        }
Example #7
0
        public RSSItemView()
        {
            // This call is required by the Windows.Forms Form Designer.
            InitializeComponent();

            // Initialize the security context
            _ctxRestricted             = WebSecurityContext.Restricted;
            _ctxRestricted.WorkOffline = false; // Enable downloading of the referenced content

            ReadRssItemFontAttributes();
            ReadItemFormattingOption();

            Core.UIManager.AddOptionsChangesListener("Internet", "Feeds", ReadRssItemFontAttributesHandler);
            Core.UIManager.AddOptionsChangesListener("Omea", "General", ReadRssItemFontAttributesHandler);
        }
Example #8
0
        public ContactDisplayPane()
        {
            InitializeComponent();

            // Initialize the security context
            _ctxRestricted              = WebSecurityContext.Trusted;
            _ctxRestricted.WorkOffline  = false; // Enable downloading of the referenced content
            _ctxRestricted.ShowPictures = true;

            _leftBlocks  = new ArrayList();
            _rightBlocks = new ArrayList();

            ContactService.GetInstance().CreateContactBlocks(this);

            _headerPane.Visible = false;
        }
Example #9
0
        public MailBodyView()
        {
            // This call is required by the Windows.Forms Form Designer.
            InitializeComponent();
            _panel2.Visible = false;
            _panel1.Visible = false;

            // Initialize the contexts
            // • Without images — work offline, show pictures that come from the file system of browser's cache only
            _ctxRestrictedWoImages              = WebSecurityContext.Restricted;
            _ctxRestrictedWoImages.WorkOffline  = true;
            _ctxRestrictedWoImages.ShowPictures = Core.SettingStore.ReadBool("General", "MailShowCachedPictures", false);

            // • With images — work online, show pictures that come from the file system or are downloaded from the Internet
            _ctxRestrictedWithImages              = WebSecurityContext.Restricted;
            _ctxRestrictedWithImages.WorkOffline  = false;
            _ctxRestrictedWithImages.ShowPictures = true;

            ReadMailFontAttributes();

            Core.UIManager.AddOptionsChangesListener("MS Outlook", "Outlook General", ReadMailFontAttributesHandler);
            Core.UIManager.AddOptionsChangesListener("Omea", "General", ReadMailFontAttributesHandler);
        }
Example #10
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
 }
Example #11
0
        private void ShowMessageItem(IResource res, MailMessage messageItem)
        {
            #region Preconditions
            CheckDisposed();
            Guard.NullArgument(messageItem, "messageItem");
            #endregion Preconditions

            int loadingResourceId = _lastResourceId;

            // this performs an asynchronous operation for loading the body;
            // during this operation, the form may be disposed or may switch
            // to a different message (#6012)
            BodyType messageBodyType = messageItem.BodyType;

            if (_disposed || _lastResourceId != loadingResourceId)
            {
                return;
            }

            bool hidePictures = _panel1.Visible = !res.HasProp(PROP.ShowPictures) &&
                                                  !Settings.ShowEmbedPics && messageItem.HasPictures;
            int attchmCount            = res.GetLinksOfType(null, PROP.Attachment).Count;
            WebSecurityContext context = (attchmCount > 0) ? WebSecurityContext.Trusted :
                                         (hidePictures ? _ctxRestrictedWoImages : _ctxRestrictedWithImages);
            if (messageBodyType == BodyType.HTML)
            {
                string body = Core.MessageFormatter.GetFormattedHtmlBody(res, messageItem.Body, ref _wordsToHighlight);
                body = InlineAttachments(res, body);
                body = ReplaceContentID(res, body);
                ShowHtml(body, context, _wordsToHighlight);

                _wordsToHighlight = null;
                // Control whether we allow downloading pictures or not
            }
            else
            if (messageBodyType == BodyType.RTF)
            {
                ShowRtf(messageItem.Body, _wordsToHighlight);
                InsertOLEObjects(res);
            }
            else
            {
                if (!res.HasProp(PROP.NoFormat))
                {
                    IResource origMsg  = res.GetLinkProp("Reply");
                    string    origBody = (origMsg != null) ? MailMessage.Get(origMsg).Body : null;

                    // Apply formatting to the plaintext item to present it in a fancy way. Also, remap the offsets if needed
                    string body = Core.MessageFormatter.GetFormattedBody(res, messageItem.Body, origBody,
                                                                         ref _wordsToHighlight, _font, _fontSize);
                    body = InlineAttachments(res, body);

                    ShowHtml(body, WebSecurityContext.Trusted, _wordsToHighlight);
                    _wordsToHighlight = null;
                }
                else
                {
                    string body = Core.MessageFormatter.GetFormattedBody(res, messageItem.Body, null, ref _wordsToHighlight);
                    ShowHtml(body, WebSecurityContext.Trusted, _wordsToHighlight);
                }
            }
        }