Beispiel #1
0
        private static Hyperlink CreateHyperlink(CrefEntryKey key, string name)
        {
            Hyperlink link = new Hyperlink(new Run(name));

            link.Tag    = key;
            link.Click += new System.Windows.RoutedEventHandler(LinkHelper.Resolve);
            return(link);
        }
Beispiel #2
0
        private static bool ResolveMember(string innerText, CRefPath path, AssemblyDef assembly, out CrefEntryKey key, out string displayName)
        {
            key         = new CrefEntryKey(assembly, path.ToString());
            displayName = innerText;

            // check if the member has been output by visual studio. If the cref is empty vs did not find it.
            // TODO: Return error text?
            if (path.PathType == CRefTypes.Error)
            {
                return(false);
            }

            TheBoxSoftware.Documentation.Entry relatedEntry = LiveDocumentorFile.Singleton.LiveDocument.Find(path);
            if (relatedEntry != null)
            {
                displayName = relatedEntry.Name;

                switch (path.PathType)
                {
                // these elements are named and the type of element will
                // not modify how it should be displayed
                case CRefTypes.Field:
                case CRefTypes.Property:
                case CRefTypes.Event:
                case CRefTypes.Namespace:
                    break;

                // these could be generic and so will need to modify to
                // a more appropriate display name
                case CRefTypes.Method:
                    MethodDef method = relatedEntry.Item as MethodDef;
                    if (method != null)
                    {
                        displayName = method.GetDisplayName(false);
                    }
                    break;

                case CRefTypes.Type:
                    TypeDef def = relatedEntry.Item as TypeDef;
                    if (def != null)
                    {
                        displayName = def.GetDisplayName(false);
                    }
                    break;
                }
            }

            return(relatedEntry != null);
        }
Beispiel #3
0
 /// <summary>
 /// Initialises a SeeAlso instance.
 /// </summary>
 /// <param name="key">The <see cref="CRefPath"/> to the type being refered to.</param>
 /// <param name="name">The display name of the SeeAlso referenced member</param>
 internal SeeAlso(CrefEntryKey key, string name) : base()
 {
     this.Resources.MergedDictionaries.Add(DocumentationResources.BaseResources);
     this.Name = name;
     this.Inlines.Add(new Run(name));
     if (key != null)
     {
         this.Tag    = key;
         this.Click += new System.Windows.RoutedEventHandler(LinkHelper.Resolve);
     }
     else
     {
         this.IsEnabled = false;
     }
 }
        /// <summary>
        /// Resolves a hyperlink to a treenode in the document map
        /// </summary>
        /// <param name="sender">The source of the event</param>
        /// <param name="e">The event arguments</param>
        public static void Resolve(object sender, System.Windows.RoutedEventArgs e)
        {
            if (e.Source is System.Windows.Documents.Hyperlink)
            {
                System.Windows.Documents.Hyperlink sourceLink = e.Source as System.Windows.Documents.Hyperlink;
                LiveDocument document = LiveDocumentorFile.Singleton.LiveDocument;
                Entry        entry    = null;
                sourceLink.Cursor = Cursors.Wait;

                EntryKey key = null;
                if (sourceLink.Tag is CrefEntryKey)
                {
                    CrefEntryKey crefEntryKey = (CrefEntryKey)sourceLink.Tag;
                    CRefPath     path         = CRefPath.Parse(crefEntryKey.CRef);
                    entry = document.Find(path);
                }
                else if (sourceLink.Tag is EntryKey)
                {
                    key = (EntryKey)sourceLink.Tag;
                    if (key != null)
                    {
                        entry = document.Find(key.Key, key.SubKey);

                        if (entry != null && entry.Parent != null)
                        {
                            entry.IsSelected        = true;
                            entry.Parent.IsExpanded = true;
                        }
                    }
                }

                if (entry != null && entry.Parent != null)
                {
                    entry.IsSelected        = true;
                    entry.Parent.IsExpanded = true;
                }

                sourceLink.Cursor = null;
            }
        }