need help creating a custom indicator

SyntaxEditor for Windows Forms Forum

Posted 17 years ago by SamWare
Avatar
Pardon my ignorance, but I cannot figure out how to inherit any "Indicator" class and I've found no examples.

public class MethodIndicator : ActiproSoftware.SyntaxEditor.SpanIndicator
{
    public MethodIndicator(string name, int displayPriority, bool hasGlyph, IndicatorMarks indicatorMarks)
    {
        //
    }

    protected override void DrawMarks(Graphics g, Rectangle bounds)
    {
        //
    }
}
When I compile I get this error: "No overload for method 'SpanIndicator' takes '0' arguments".

I don't inherit abstract classes much, and I've not encountered this type of problem prior to now. I know it's my lack of knowledge, but I don't know where to find the information that will help me fix this.

Comments (3)

Posted 17 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
Here's some sample code for an indicator... note where I marked where you should add drawing code for a glyph if you want.
using System;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Windows.Forms;
using ActiproSoftware.Drawing;

namespace ActiproSoftware.SyntaxEditor {

    /// <summary>
    /// Represents a breakpoint indicator.
    /// </summary>
    public class BreakpointIndicator : SpanIndicator {

        private static int defaultDisplayPriority;

        private Color    backColor;
        private Color    foreColor;

        /// <summary>
        /// Initializes a static instance of the <c>BreakpointIndicator</c> class.
        /// </summary>
        static BreakpointIndicator() {
            defaultDisplayPriority = 20;
        }

        /// <summary>
        /// Initializes a new instance of the <c>BreakpointIndicator</c> class.
        /// </summary>
        public BreakpointIndicator() : 
            this(BreakpointIndicator.DefaultName, BreakpointIndicator.DefaultDisplayPriority, Color.White, Color.Maroon) {
        }

        /// <summary>
        /// Initializes a new instance of the <c>BreakpointIndicator</c> class with a custom name and color scheme.
        /// </summary>
        /// <param name="name">The name to identify the type of indicator.</param>
        /// <param name="displayPriority">The priority of display level for the indicator.</param>
        /// <param name="foreColor">The <c>Color</c> to use when drawing the foreground of the indicator.</param>
        /// <param name="backColor">The <c>Color</c> to use when drawing the background of the indicator.</param>
        public BreakpointIndicator(string name, int displayPriority, Color foreColor, Color backColor) : 
            base(name, displayPriority, true, IndicatorMarks.StyleAssignment) {

            // Initialize parameters
            this.backColor = backColor;
            this.foreColor = foreColor;
        }

        /////////////////////////////////////////////////////////////////////////////////////////////////////
        // PUBLIC PROCEDURES
        /////////////////////////////////////////////////////////////////////////////////////////////////////

        /// <summary>
        /// Gets or sets the default priority of display level for the newly created indicators of this class.
        /// </summary>
        /// <value>
        /// The priority of display level for the newly created indicators of this class.
        /// The default value is <c>20</c>.
        /// </value>
        /// <remarks>
        /// Indicators with the lowest priority numbers are painted first with other indicators 
        /// painted on top in increasing priority order.
        /// </remarks>
        public static int DefaultDisplayPriority {
            get {
                return defaultDisplayPriority;
            }
            set {
                defaultDisplayPriority = value;
            }
        }

        /// <summary>
        /// Gets the default name for a breakpoint.
        /// </summary>
        /// <value>The default name for a breakpoint.</value>
        public static string DefaultName {
            get {
                return "Breakpoint";
            }
        }

        /// <summary>
        /// Draws the glyph associated with the indicator.
        /// </summary>
        /// <param name="g">The <c>Graphics</c> object to use for drawing.</param>
        /// <param name="bounds">A <c>Rectangle</c> specifying the bounds in which to draw.</param>
        protected internal override void DrawGlyph(Graphics g, Rectangle bounds) {
            // TODO: Drawing code for indicator glyph goes here
        }

        /// <summary>
        /// Draws the marks associated with the indicator.
        /// </summary>
        /// <param name="g">The <c>Graphics</c> object to use for drawing.</param>
        /// <param name="bounds">A <c>Rectangle</c> specifying the bounds in which to draw.</param>
        protected internal override void DrawMarks(Graphics g, Rectangle bounds) {
        }

        /// <summary>
        /// Returns the <see cref="HighlightingStyle"/> to use when drawing text within the indicator.
        /// </summary>
        /// <returns>The <see cref="HighlightingStyle"/> to use when drawing text within the indicator.</returns>
        /// <remarks>This method should be implemented by indicators that have a style assignment.</remarks>
        protected internal override HighlightingStyle GetHighlightingStyle() {
            return new HighlightingStyle("BreakpointStyle", "Breakpoint", foreColor, backColor, false, false, false);
        }
    }
}
[Modified at 10/01/2005 11:52 AM]


Actipro Software Support

Posted 17 years ago by phruby
Avatar
This is a great help but it doesn't compile.

At the DrawGylph and DrawMarks, I get
BreakpointIndicator.DrawGlyph(System.Drawing.Graphics, System.Drawing.Rectangle)': cannot change access modifiers when overriding 'protected' inherited member 'ActiproSoftware.SyntaxEditor.SpanIndicator.DrawGlyph(System.Drawing.Graphics, System.Drawing.Rectangle)'

Also, at HighlightingStyle, I get
The type or namespace name 'HighlightingStyle' could not be found (are you missing a using directive or an assembly reference?)
Posted 17 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
Use a protected access modified and not protected internal. Sorry, that was copied from our code. Try that out.


Actipro Software Support

The latest build of this product (v22.1.0) was released 1 month ago, which was after the last post in this thread.

Add Comment

Please log in to a validated account to post comments.