Beispiel #1
0
 private void RemoveHTML(GlobalSettings settings,mshtml.IHTMLTxtRange range)
 {
     mshtml.IHTMLElement element = range.parentElement();
     if (settings.IsHightlightNonVisible)
     {
         if (settings.IsBold)
         {
             if (settings.IsItalic)
             {
                 RemoveBIS(element);
             }
             else
             {
                 RemoveBS(element);
             }
         }
         else
         {
             if (settings.IsItalic)
             {
                 RemoveIS(element);
             }
             else
             {
                 RemoveS(element);
             }
         }
     }
     else
     {
         if (element.offsetTop > Const.NotFound && element.offsetLeft > Const.NotFound && element.offsetHeight > Const.Ok && element.offsetWidth > Const.Ok)
         {
             if (settings.IsBold)
             {
                 if (settings.IsItalic)
                 {
                     RemoveBIS(element);
                 }
                 else
                 {
                     RemoveBS(element);
                 }
             }
             else
             {
                 if (settings.IsItalic)
                 {
                     RemoveIS(element);
                 }
                 else
                 {
                     RemoveS(element);
                 }
             }
         }
     }
     Marshal.ReleaseComObject(element);
 }
Beispiel #2
0
            private String BuildHTML(GlobalSettings settings,mshtml.IHTMLTxtRange range)
            {
                string background = settings.BackgroundColor.R.ToString("X2") + settings.BackgroundColor.G.ToString("X2") + settings.BackgroundColor.B.ToString("X2");
                string textColor = settings.TextColor.R.ToString("X2") + settings.TextColor.G.ToString("X2") + settings.TextColor.B.ToString("X2");
                bool isEmpty = false;
                StringBuilder builder = new StringBuilder();
                builder.Append("<span id=advanced_search style=\"background:#");
                builder.Append(background);
                builder.Append("; color:#");
                builder.Append(textColor);
                builder.Append("\">");

                if (settings.IsHightlightNonVisible)
                {
                    if (settings.IsItalic)
                    {
                        if (settings.IsBold)
                        {
                            builder.Append("<i><b>");
                            builder.Append(range.text);
                            builder.Append("</b></i></span>");
                        }
                        else
                        {
                            builder.Append("<i>");
                            builder.Append(range.text);
                            builder.Append("</i></span>");
                        }
                    }
                    else
                    {
                        if (settings.IsBold)
                        {
                            builder.Append("<b>");
                            builder.Append(range.text);
                            builder.Append("</b></span>");
                        }
                        else
                        {
                            builder.Append(range.text);
                            builder.Append("</span>");
                        }
                    }
                }
                else
                {
                    mshtml.IHTMLElement element = range.parentElement();
                    if (element.offsetTop > Const.NotFound && element.offsetLeft > Const.NotFound && element.offsetHeight > Const.Ok && element.offsetWidth > Const.Ok)
                    {
                        if (settings.IsItalic)
                        {
                            if (settings.IsBold)
                            {
                                builder.Append("<i><b>");
                                builder.Append(range.text);
                                builder.Append("</b></i></span>");
                            }
                            else
                            {
                                builder.Append("<i>");
                                builder.Append(range.text);
                                builder.Append("</i></span>");
                            }
                        }
                        else
                        {
                            if (settings.IsBold)
                            {
                                builder.Append("<b>");
                                builder.Append(range.text);
                                builder.Append("</b></span>");
                            }
                            else
                            {
                                builder.Append(range.text);
                                builder.Append("</span>");
                            }
                        }
                    }
                    else
                    {
                        isEmpty = true;
                    }
                    Marshal.ReleaseComObject(element);
                }
                if (isEmpty)
                {
                    return string.Empty;
                }
                else
                {
                    return builder.ToString();
                }
            }