//! \brief ctor
 public CManager(Microsoft.VisualStudio.Shell.Package package, DTE2 applicationObject)
 {
     _doxManger              = this;
     this._package           = package;
     this._applicationObject = applicationObject;
     this._options           = new COptions(package);
 }
 public override System.Windows.Controls.Image GetValidImage()
 {
     if (state_ != State.valid)
     {
         return(null);
     }
     return(CManager.LoadOrCreateBitmapImage(this.previewFilePath_));
 }
        //! \brief Add image preview to QuickInfo content
        void AddImage(IList <object> qiContent, string imagePath)
        {
            var img = CManager.LoadOrCreateBitmapImage(imagePath);

            if (img != null)
            {
                qiContent.Add(img);
            }

            // <img src="refl1_non.jpg" alt="refl1_non.jpg"/>

            //var web = new System.Windows.Controls.WebBrowser();
            //web.Width = bmp.Width;
            //web.Height = bmp.Height;
            //string webContent = "<body><p><b>Test</b></p></body>";
            //string webContent = "<object type = \"image/svg+xml\" data = \"" + "file:///" + imagePath + "\"></object>";
            //web.NavigateToString(webContent);
            //web.Source = new Uri("file:///" + imagePath);
            //web.Navigate("file:///" + imagePath);
            //qiContent.Add(web);
        }
Example #4
0
        public static List <DoxTokenTag> GenerateTags(IEnumerable <SnapshotSpan> spans)
        {
            List <DoxTokenTag> spanTags = new List <DoxTokenTag>();
            CManager           manager  = CManager.Manager;

            if (manager == null)
            {
                return(spanTags);
            }

            List <SnapshotSpan> identList = new List <SnapshotSpan>();

            foreach (var span in spans)
            {
                var newSpans = LexIdentifiers(span);
                identList.InsertRange(identList.Count, newSpans);
            }

            SortedSet <string> imageKinds = new SortedSet <string> {
                "html", "latex", "docbook", "rtf"
            };

            for (int i = 0; i < identList.Count(); ++i)
            {
                var identSpan = identList[i];
                var ident     = identSpan.GetText().ToLower();

                bool isDoxCommand = ident.Length > 0 && IsStartOfCommand(ident[0]);
                if (isDoxCommand)
                {
                    bool cmdIdentified   = false;
                    bool valide_cmd      = false;
                    int  file_name_inx   = 0;
                    int  sequnce_end_inx = 0;
                    var  cmdName         = ident.Substring(1);
                    if (cmdName == "ref")
                    {
                        cmdIdentified = true;
                        bool validRefDecl = i + 1 < identList.Count();
                        var  refText      = validRefDecl ? identList[i + 1].GetText() : "";
                        if (validRefDecl)
                        {
                            validRefDecl = refText.Length > 0 && char.IsLetter(refText[0]);
                        }
                        if (validRefDecl)
                        {
                            var refTextSpan     = identList[i + 1];
                            var refTextEndPoint = refTextSpan.End;
                            var dotPos          = refText.IndexOf('.');
                            if (dotPos >= 0)
                            {
                                refText         = refText.Substring(0, dotPos);
                                refTextEndPoint = refTextSpan.Start + dotPos;
                            }
                            var refSpan = new SnapshotSpan(identSpan.Start, refTextEndPoint);
                            var url     = manager.FindDoxygenLink(refText, false);
                            spanTags.Add(new DoxTokenTag(DoxTokenType.Ref, refSpan, refTextSpan, cmdName, url != "" ? url : refText, url != ""));
                            i++;
                        }
                        else
                        {
                            spanTags.Add(new DoxTokenTag(DoxTokenType.Cmd, identSpan, identSpan, cmdName, "", true));
                        }
                    }
                    else if (FindCmdFileRef(identList, "image", imageKinds, i, out valide_cmd, out file_name_inx, out sequnce_end_inx))
                    {
                        cmdIdentified = true;
                        if (valide_cmd)
                        {
                            var endSpan     = identList[sequnce_end_inx];
                            var imgNameSpan = identList[file_name_inx];
                            var imgName     = identList[file_name_inx].GetText();
                            var imgSpan     = new SnapshotSpan(identSpan.Start, endSpan.End);
                            var imgPath     = manager.FindImageFilePath(imgName);
                            spanTags.Add(new DoxTokenTag(DoxTokenType.Image, imgSpan, imgNameSpan, cmdName, imgPath != "" ? imgPath : imgName, imgPath != ""));
                        }
                        else
                        {
                            spanTags.Add(new DoxTokenTag(DoxTokenType.Image, identSpan, identSpan, cmdName, "", false));
                        }
                        i = sequnce_end_inx;
                    }
                    else if (FindCmdBlock(identList, "code", "endcode", i, out sequnce_end_inx))
                    {
                        cmdIdentified = true;
                        var endSpan        = identList[sequnce_end_inx];
                        var umlSpan        = new SnapshotSpan(identSpan.Start, endSpan.End);
                        var umlContentSpan = new SnapshotSpan(identSpan.End, endSpan.Start);
                        spanTags.Add(new DoxTokenTag(DoxTokenType.Code, umlSpan, umlContentSpan, cmdName, "", true));
                        i = sequnce_end_inx;
                    }
                    else if (FindCmdBlock(identList, "dot", "enddot", i, out sequnce_end_inx))
                    {
                        cmdIdentified = true;
                        var endSpan        = identList[sequnce_end_inx];
                        var umlSpan        = new SnapshotSpan(identSpan.Start, endSpan.End);
                        var umlContentSpan = new SnapshotSpan(identSpan.End, endSpan.Start);
                        spanTags.Add(new DoxTokenTag(DoxTokenType.Dot, umlSpan, umlContentSpan, cmdName, "", true));
                        i = sequnce_end_inx;
                    }
                    else if (FindCmdFileRef(identList, "dotfile", null, i, out valide_cmd, out file_name_inx, out sequnce_end_inx))
                    {
                        cmdIdentified = true;
                        if (valide_cmd)
                        {
                            var endSpan     = identList[sequnce_end_inx];
                            var dotNameSpan = identList[file_name_inx];
                            var dotName     = identList[file_name_inx].GetText();
                            var dotSpan     = new SnapshotSpan(identSpan.Start, endSpan.End);
                            var dotPath     = manager.FindDotFilePath(dotName);
                            spanTags.Add(new DoxTokenTag(DoxTokenType.DotFile, dotSpan, dotNameSpan, cmdName, dotPath != "" ? dotPath : dotName, dotPath != ""));
                        }
                        else
                        {
                            spanTags.Add(new DoxTokenTag(DoxTokenType.DotFile, identSpan, identSpan, cmdName, "", false));
                        }
                        i = sequnce_end_inx;
                    }
                    else if (FindCmdBlock(identList, "msc", "endmsc", i, out sequnce_end_inx))
                    {
                        cmdIdentified = true;
                        var endSpan        = identList[sequnce_end_inx];
                        var umlSpan        = new SnapshotSpan(identSpan.Start, endSpan.End);
                        var umlContentSpan = new SnapshotSpan(identSpan.End, endSpan.Start);
                        spanTags.Add(new DoxTokenTag(DoxTokenType.Msc, umlSpan, umlContentSpan, cmdName, "", true));
                        i = sequnce_end_inx;
                    }
                    else if (FindCmdFileRef(identList, "mscfile", null, i, out valide_cmd, out file_name_inx, out sequnce_end_inx))
                    {
                        cmdIdentified = true;
                        if (valide_cmd)
                        {
                            var endSpan     = identList[sequnce_end_inx];
                            var mscNameSpan = identList[file_name_inx];
                            var mscName     = identList[file_name_inx].GetText();
                            var mscSpan     = new SnapshotSpan(identSpan.Start, endSpan.End);
                            var mscPath     = manager.FindMscFilePath(mscName);
                            spanTags.Add(new DoxTokenTag(DoxTokenType.MscFile, mscSpan, mscNameSpan, cmdName, mscPath != "" ? mscPath : mscName, mscPath != ""));
                        }
                        else
                        {
                            spanTags.Add(new DoxTokenTag(DoxTokenType.MscFile, identSpan, identSpan, cmdName, "", false));
                        }
                        i = sequnce_end_inx;
                    }
                    else if (FindCmdFileRef(identList, "diafile", null, i, out valide_cmd, out file_name_inx, out sequnce_end_inx))
                    {
                        cmdIdentified = true;
                        if (valide_cmd)
                        {
                            var endSpan     = identList[sequnce_end_inx];
                            var diaNameSpan = identList[file_name_inx];
                            var diaName     = identList[file_name_inx].GetText();
                            var diaSpan     = new SnapshotSpan(identSpan.Start, endSpan.End);
                            var diaPath     = manager.FindDiaFilePath(diaName);
                            spanTags.Add(new DoxTokenTag(DoxTokenType.MscFile, diaSpan, diaNameSpan, cmdName, diaPath != "" ? diaPath : diaName, diaPath != ""));
                        }
                        else
                        {
                            spanTags.Add(new DoxTokenTag(DoxTokenType.MscFile, identSpan, identSpan, cmdName, "", false));
                        }
                        i = sequnce_end_inx;
                    }
                    else if (FindCmdBlock(identList, "startuml", "enduml", i, out sequnce_end_inx))
                    {
                        cmdIdentified = true;
                        var endSpan        = identList[sequnce_end_inx];
                        var umlSpan        = new SnapshotSpan(identSpan.Start, endSpan.End);
                        var umlContentSpan = new SnapshotSpan(identSpan.End, endSpan.Start);
                        spanTags.Add(new DoxTokenTag(DoxTokenType.Uml, umlSpan, umlContentSpan, cmdName, "", true));
                        i = sequnce_end_inx;
                    }
                    else if (FindCmdBlock(identList, "f$", "f$", i, out sequnce_end_inx) ||
                             FindCmdBlock(identList, "f[", "f]", i, out sequnce_end_inx))
                    {
                        cmdIdentified = true;
                        var endSpan        = identList[sequnce_end_inx];
                        var umlSpan        = new SnapshotSpan(identSpan.Start, endSpan.End);
                        var umlContentSpan = new SnapshotSpan(identSpan.End, endSpan.Start);
                        spanTags.Add(new DoxTokenTag(DoxTokenType.LatexFormula, umlSpan, umlContentSpan, cmdName, "", true));
                        i = sequnce_end_inx;
                    }

                    if (cmdIdentified == false)
                    {
                        spanTags.Add(new DoxTokenTag(DoxTokenType.Cmd, identSpan, identSpan, cmdName, "", DoxUtil.CManager.Manager.IsKnownCommand(ident)));
                    }
                }
            }
            return(spanTags);
        }