csharp/Actipro/WPF-Controls/Samples/SampleBrowser/ProductSamples/SyntaxEditorSamples/QuickStart/IndicatorsCustom/CustomIndicatorTag.cs

CustomIndicatorTag.cs
using System;
using System.Windows;
using System.Windows.Media;
using ActiproSoftware.Text;
using ActiproSoftware.Text.Implementation;
using ActiproSoftware.Text.Tagging;
using ActiproSoftware.Text.Tagging.Implementation;
using ActiproSoftware.Windows.Controls.Rendering;
using ActiproSoftware.Windows.Controls.SyntaxEditor;
using ActiproSoftware.Windows.Controls.SyntaxEditor.Highlighting;
using ActiproSoftware.Windows.Controls.SyntaxEditor.Highlighting.Implementation;
using ActiproSoftware.Windows.Controls.SyntaxEditor.Implementation;

namespace ActiproSoftware.ProductSamples.SyntaxEditorSamples.QuickStart.IndicatorsCustom {
   
	/// 
	/// Represents an  that renders a custom indicator over a text range.
	/// 
	public clast CustomIndicatorTag : IndicatorClastificationTagBase {
	
		private static IClastificationType customIndicatorClastificationType = new ClastificationType("Custom Indicator");
		
		/////////////////////////////////////////////////////////////////////////////////////////////////////
		// OBJECT
		/////////////////////////////////////////////////////////////////////////////////////////////////////
		
		/// 
		/// Initializes the CustomIndicatorTag clast.
		/// 
		static CustomIndicatorTag() {
			// Ensure the clastification type is registered
			AmbientHighlightingStyleRegistry.Instance.Register(customIndicatorClastificationType, 
				new HighlightingStyle() { 
					Background = Color.FromArgb(0x40, 0x8a, 0xf3, 0x82),
					Foreground = Color.FromArgb(0xff, 0x00, 0x40, 0x00), 
				});
		}
		
		/////////////////////////////////////////////////////////////////////////////////////////////////////
		// PUBLIC PROCEDURES
		/////////////////////////////////////////////////////////////////////////////////////////////////////
		
		/// 
		/// Gets the  astociated with the tag.
		/// 
		/// The  astociated with the tag.
		public override IClastificationType ClastificationType { 
			get {
				return customIndicatorClastificationType;
			}
		}
	
		/// 
		/// Draws the indicator's glyph in an editor view margin.
		/// 
		/// The  to use for rendering.
		/// The  for which the glyph is rendered.
		/// The  and the range it covers.
		/// The bounds in which the indicator will be rendered.
		public override void DrawGlyph(TextViewDrawContext context, ITextViewLine viewLine, TagSnapshotRange tagRange, Rect bounds) {
			var diameter = Math.Max(8.0, Math.Min(13, Math.Round(Math.Min(bounds.Width, bounds.Height) - 2.0)));
			var x = bounds.X + (bounds.Width - diameter) / 2.0;
			var y = bounds.Y + (bounds.Height - diameter) / 2.0;

			context.FillEllipse(new Rect(x, y, diameter, diameter), Color.FromArgb(0xff, 0x8a, 0xf3, 0x82));
			context.DrawEllipse(new Rect(x, y, diameter, diameter), Color.FromArgb(0xff, 0x00, 0x40, 0x00), LineKind.Solid, 1);
		}

	}
	
}