예제 #1
0
        /// <summary>
        /// Insert a link to a site map table of contents entry (HTML only)
        /// </summary>
        /// <param name="extension">The extension of the file in which the
        /// link is being inserted.</param>
        /// <param name="tocEntry">The TOC entry for which to create a link</param>
        /// <remarks>If dropped inside some selected text, the link will
        /// wrap the selected text.</remarks>
        private void InsertTocLink(string extension, TocEntry tocEntry)
        {
            TextArea textArea = editor.ActiveTextAreaControl.TextArea;
            int      offset   = textArea.Caret.Offset;
            string   selectedText;

            if (textArea.SelectionManager.HasSomethingSelected &&
                textArea.SelectionManager.SelectionCollection[0].ContainsOffset(offset))
            {
                selectedText = textArea.SelectionManager.SelectionCollection[0].SelectedText;
            }
            else
            {
                selectedText = String.Empty;
            }

            if (extension == ".htm" || extension == ".html")
            {
                ContentEditorControl.InsertString(textArea,
                                                  tocEntry.ToAnchor(selectedText));
            }
            else
            {
                ContentEditorControl.InsertString(textArea,
                                                  tocEntry.Title); // Not supported in MAML topics
            }
        }
예제 #2
0
        /// <summary>
        /// Get the text to copy as a link to the clipboard
        /// </summary>
        /// <returns>The string to copy to the clipboard or null if there is nothing to copy</returns>
        private string GetTextToCopy()
        {
            TocEntry t = tvContent.SelectedItem as TocEntry;
            string   textToCopy;

            if (t != null)
            {
                textToCopy = t.ToAnchor(!String.IsNullOrEmpty(t.Title) ? t.Title : "(No title)");
            }
            else
            {
                textToCopy = null;
            }

            return(textToCopy);
        }
        /// <summary>
        /// Get the text to copy or use for drag and drop operations
        /// </summary>
        /// <returns>The text to use or null if there is nothing to copy</returns>
        private string GetTextToCopy()
        {
            EntityReference r          = tvEntities.SelectedItem as EntityReference;
            string          textToCopy = null;

            if (r != null)
            {
                switch (r.EntityType)
                {
                case EntityType.File:
                    // Not useable
                    break;

                case EntityType.Token:
                    Token t = (Token)r.Tag;
                    textToCopy = t.ToToken();
                    break;

                case EntityType.Image:
                    ImageReference ir = (ImageReference)r.Tag;

                    if (rbMediaLink.IsChecked.Value)
                    {
                        textToCopy = ir.ToMediaLink();
                    }
                    else
                    if (rbMediaLinkInline.IsChecked.Value)
                    {
                        textToCopy = ir.ToMediaLinkInline();
                    }
                    else
                    if (rbExternalLink.IsChecked.Value)
                    {
                        textToCopy = ir.ToExternalLink();
                    }
                    else
                    {
                        textToCopy = ir.ToImageLink();
                    }
                    break;

                case EntityType.CodeSnippet:
                    CodeReference cr = (CodeReference)r.Tag;
                    textToCopy = cr.ToCodeReference();
                    break;

                case EntityType.TocEntry:
                    TocEntry toc = (TocEntry)r.Tag;

                    // MAML topic?
                    if (!String.IsNullOrEmpty(toc.Id))
                    {
                        if (rbMamlLink.IsChecked.Value)
                        {
                            textToCopy = String.Format(CultureInfo.InvariantCulture,
                                                       "<link xlink:href=\"{0}\" />", (toc.Id ?? "[Unknown ID]"));
                        }
                        else
                        if (rbConceptualLink.IsChecked.Value)
                        {
                            textToCopy = String.Format(CultureInfo.InvariantCulture,
                                                       "<conceptualLink target=\"{0}\" />", (toc.Id ?? "[Unknown ID]"));
                        }
                        else
                        {
                            textToCopy = String.Format(CultureInfo.InvariantCulture,
                                                       "<a href=\"html/{0}.htm\">{1}</a>", toc.Id, toc.Title);
                        }
                    }
                    else
                    {
                        textToCopy = toc.ToAnchor(toc.Title);
                    }
                    break;

                default:        // Code entity reference
                    CodeEntityReference ce = (CodeEntityReference)r.Tag;

                    if (rbCodeEntityRef.IsChecked.Value)
                    {
                        textToCopy = ce.ToCodeEntityReference();
                    }
                    else
                    {
                        textToCopy = ce.ToSee();
                    }
                    break;
                }
            }

            return(textToCopy);
        }
예제 #4
0
        /// <summary>
        /// Insert a link to a site map table of contents entry (HTML only)
        /// </summary>
        /// <param name="extension">The extension of the file in which the
        /// link is being inserted.</param>
        /// <param name="tocEntry">The TOC entry for which to create a link</param>
        /// <remarks>If dropped inside some selected text, the link will
        /// wrap the selected text.</remarks>
        private void InsertTocLink(string extension, TocEntry tocEntry)
        {
            TextArea textArea = editor.ActiveTextAreaControl.TextArea;
            int offset = textArea.Caret.Offset;
            string selectedText;

            if(textArea.SelectionManager.HasSomethingSelected &&
              textArea.SelectionManager.SelectionCollection[0].ContainsOffset(offset))
                selectedText = textArea.SelectionManager.SelectionCollection[0].SelectedText;
            else
                selectedText = String.Empty;

            if(extension == ".htm" || extension == ".html")
                ContentEditorControl.InsertString(textArea, tocEntry.ToAnchor(selectedText));
            else
                ContentEditorControl.InsertString(textArea, tocEntry.Title);    // Not supported in MAML topics
        }