Assigning custom images to line styles

Hi, I can see you can assign an image index to a line style, however how do you add your own images?

I have tried this.syntaxEdit.Gutter.Images.Images.Add(myImage) however that doesn’t seem to relate to the images used by styles.

Cheers,

john

We have examples of custom images usage in these demos:

  • AlternetStudio\Demo\Editor\QuickStarts\Bookmarks\
  • AlternetStudio\Demo\Editor\QuickStarts\LineStyles\

In both demos we add custom images that can be used in gutter and line styles.

If you have some custom image list, you can use such code in order to add it:

edit.Gutter.AlphaImages = InitCustomImages(edit.Gutter.AlphaImages);
edit.Gutter.AlphaImagesHighDpi = InitCustomImages(edit.Gutter.AlphaImagesHighDpi);

        private AlphaImageList InitCustomImages(AlphaImageList alphaImages)
        {
            IList<Image> images = new List<Image>();

            foreach (Image image in alphaImages.Images)
                images.Add(image);

            foreach (Image image in customGutterImages.Images)
                images.Add(image);
            return new AlphaImageList(images, alphaImages.ImageSize);
        }

where customGutterImages contains your own images.

If you need to add only one image:

            var customImageIndex = syntaxEdit1.Gutter.AddImage(
                this.GetType().Assembly,
                "LineStyles.Resources.gear16green.png",
                "LineStyles.Resources.gear32green.png");

            var customLineStyle = new EditLineStyle
            {
                BackColor = Color.Green,
                ForeColor = Color.White,
                Options = LineStyleOptions.BeyondEol,
                ImageIndex = customImageIndex,
            };

If you want to replace default images used on gutter, create AlphaImageList for both normal size and high-dpi images and assign them to gutter. In order to know used image indexes, you can use KnownGutterImageIndex enum.