Ejemplo n.º 1
0
        /////////////////////////////////////////////////////////////////////////////////////////////////////
        // NON-PUBLIC PROCEDURES
        /////////////////////////////////////////////////////////////////////////////////////////////////////

        /// <summary>
        /// Adds an adornment.
        /// </summary>
        /// <param name="offset">The offset.</param>
        private void AddAdornment(int offset)
        {
            // Get the tagger that was created by the language and has been persisted in the document's properties
            //   while the language is active on the document
            IntraLineViewportTagger tagger = null;

            if (editor.ActiveView.Properties.TryGetValue(typeof(IntraLineViewportTagger), out tagger))
            {
                // Create a version range
                ITextVersionRange versionRange = new TextSnapshotRange(editor.ActiveView.CurrentSnapshot, offset).ToVersionRange(TextRangeTrackingModes.Default);

                // Create a tag that will be used to reserve space between view lines...
                //   Since the tags in this sample are persisted in a collection while active,
                //   we can use the tag itself as the key... the key is used to retrieve
                //   the bounds of the spacer later on so adornments can be rendered in it, thus is must be unique
                IntraLineViewportTag tag = new IntraLineViewportTag();
                tag.UpdateBottomMargin(editor.ActiveView);
                tag.Key = tag;

                // Add the tag to the tagger
                tagger.Add(new TagVersionRange <IIntraLineSpacerTag>(versionRange, tag));
            }

            // Focus the editor
            editor.Focus();
        }
        /////////////////////////////////////////////////////////////////////////////////////////////////////
        // NON-PUBLIC PROCEDURES
        /////////////////////////////////////////////////////////////////////////////////////////////////////

        /// <summary>
        /// Occurs when a tab is closing.
        /// </summary>
        /// <param name="sender">The sender of the event.</param>
        /// <param name="e">A <see cref="AdvancedTabItemEventArgs"/> that contains the event data.</param>
        private void OnTabControlTabClosing(object sender, AdvancedTabItemEventArgs e)
        {
            var view = VisualTreeHelperExtended.GetAncestor <EditorView>(this);

            if (view == null)
            {
                return;
            }

            var tag = this.Tag as IntraLineViewportTag;

            if (tag == null)
            {
                return;
            }

            // Remove the tag
            IntraLineViewportTagger tagger = null;

            if (view.Properties.TryGetValue(typeof(IntraLineViewportTagger), out tagger))
            {
                tagger.Remove(tag);
            }
        }