Esempio n. 1
0
        /// <summary>
        /// Adds a span indicator.
        /// </summary>
        /// <param name="layerKey">The key of the layer that will add the span indicator.</param>
        /// <param name="layerDisplayPriority">The display priority of the layer.</param>
        /// <param name="indicator">The <see cref="SpanIndicator"/> to add.</param>
        /// <param name="textRange">The text range over which to add the indicator.</param>
        private void AddSpanIndicator(
			ActiproSoftware.SyntaxEditor.SyntaxEditor editor,
			string layerKey,
			int layerDisplayPriority,
			ActiproSoftware.SyntaxEditor.SpanIndicator indicator,
			ActiproSoftware.SyntaxEditor.TextRange textRange)
        {
            // Ensure there is a selection
            if (textRange.AbsoluteLength == 0)
            {
                ActiproSoftware.SyntaxEditor.DefaultWordBreakFinder wbf = new ActiproSoftware.SyntaxEditor.DefaultWordBreakFinder();
                int startOffset = wbf.FindNextWordStart(editor.Document, textRange.StartOffset);
                int endOffset = wbf.FindCurrentWordEnd(editor.Document, startOffset);

                if (endOffset <= startOffset)
                    return;

                textRange = new TextRange(startOffset, endOffset);
                //MessageBox.Show("Please make a selection first.");
                //return;
            }
            // Ensure that a syntax error layer is created...
            ActiproSoftware.SyntaxEditor.SpanIndicatorLayer layer = editor.Document.SpanIndicatorLayers[layerKey];
            if (layer == null)
            {
                layer = new ActiproSoftware.SyntaxEditor.SpanIndicatorLayer(layerKey, layerDisplayPriority);
                editor.Document.SpanIndicatorLayers.Add(layer);
            }
            // Don't allow the indicator to overlap another one
            if (layer.OverlapsWith(textRange))
            {
                //MessageBox.Show("Span indicators within the same layer may not overlap.");
                return;
            }
            // Add the indicator
            layer.Add(indicator, textRange);
        }