Represents a region of source code in the editor that has some tab stops in it.
示例#1
0
        /// <summary>
        /// Creates code snippet in the specified view.
        /// </summary>
        /// <param name="view">Editor view that contains snippet.</param>
        /// <param name="tabStops">Tab stops collection.</param>
        /// <param name="tabStopGroups">Groups the tab stop belongs to.</param>
        public static CodeSnippet CreateSnippetInView(ViewContext view, Span[] tabStops, int[] tabStopGroups)
        {
            var snapshot = view.CurrentBuffer.CurrentSnapshot;
            var tabStopTrackers = ConvertToTrackingSpans(view, tabStops);

            CodeSnippet retVal = new CodeSnippet();
            retVal._view = view;
            retVal._tabStops = tabStopTrackers;
            retVal._tabStopGroups = tabStopGroups;

            // Cleanup any existing snippets in this view.
            var viewProperties = view.WpfView.Properties;
            if (viewProperties.ContainsProperty(ViewPropertyName))
                viewProperties.RemoveProperty(ViewPropertyName);

            viewProperties.GetOrCreateSingletonProperty(ViewPropertyName, () => retVal);

            return retVal;
        }
示例#2
0
        /// <summary>
        /// Creates code snippet in the specified view.
        /// </summary>
        /// <param name="view">Editor view that contains snippet.</param>
        /// <param name="tabStops">Tab stops collection.</param>
        /// <param name="tabStopGroups">Groups the tab stop belongs to.</param>
        public static CodeSnippet CreateSnippetInView(ViewContext view, Span[] tabStops, int[] tabStopGroups)
        {
            var snapshot        = view.CurrentBuffer.CurrentSnapshot;
            var tabStopTrackers = ConvertToTrackingSpans(view, tabStops);

            CodeSnippet retVal = new CodeSnippet();

            retVal._view          = view;
            retVal._tabStops      = tabStopTrackers;
            retVal._tabStopGroups = tabStopGroups;

            // Cleanup any existing snippets in this view.
            var viewProperties = view.WpfView.Properties;

            if (viewProperties.ContainsProperty(ViewPropertyName))
            {
                viewProperties.RemoveProperty(ViewPropertyName);
            }

            viewProperties.GetOrCreateSingletonProperty(ViewPropertyName, () => retVal);

            return(retVal);
        }