How To Use Custom Marker Symbols?

Topics: Developer Forum, User Forum
Sep 11, 2010 at 7:52 PM

It is possible to to change built-in markers (editor.Margins.Margin1.AutoToggleMarkerNumber = xx). However, is it possible to use a user defined bitmap as marker symbol ?


Oct 2, 2010 at 1:12 PM

let me answer my own question. Yes, it is possible. Here is the code which I use for creating custom makers for my bookmarks in Margin1:

// convert bitmap to xmp (XpmConverter is public static)
string xpm = XpmConverter.ConvertToXPM(<your bmp with transparency>);

// define a new marker for marker number 0
// and assign it to AutoToggleMarkerNumber in Margin1
int markerNumber = 0;
editor.NativeInterface.MarkerDefinePixmap(markerNumber, xpm);
editor.Margins.Margin1.AutoToggleMarkerNumber = markerNumber;

// a few settings for Margin1
editor.Margins.Margin1.IsClickable = true;
editor.Margins.Margin1.Width = 16;


Oct 2, 2010 at 4:42 PM

I forgot to include one method to convert transparent Bitmaps to Xpm.

Include enclosed ConvertBitmapToXpm() and replace the a.m. line

string xpm = ConvertBitmapToXpm(<your bitmap>);

/// <summary>
/// Converts a Bitmap with transparent background to Xpm.
/// </summary>
public static string ConvertBitmapToXpm(Bitmap bitmap)
	Bitmap newBmp = new Bitmap(bitmap.Width, bitmap.Height);

	using (Graphics g = Graphics.FromImage(newBmp))
		g.FillRectangle(new SolidBrush(Color.Magenta), 0, 0, bitmap.Width, bitmap.Height);
		g.DrawImage(bitmap, 0, 0);

	return XpmConverter.ConvertToXPM(newBmp);