C# MSAGL change icons

882 views Asked by At

I build an winforms application in c#.

I'm trying to change the default icons of MSAGL GViewer component:

MSAGL icons

but I don't find where to do that.

How can I change them?

1

There are 1 answers

9
Reza Aghaei On BEST ANSWER

GViewer control uses an old ToolBar control to show those buttons. To replace those icons, you can find the toolbar in controls collection of the viewer control and set a new ImageList containing new images for the toolbar:

var toolbar = this.gViewer.Controls["toolbar"] as ToolBar;
toolbar.ImageList = this.imageList1;

The image list should have 18 images in below order. When adding images to image list. After adding images, set the Name property of image at index 2 to zoom.bmp because the toolbar use it's name instead of index:

enter image description here enter image description here enter image description here enter image description here enter image description here enter image description here enter image description here enter image description here enter image description here enter image description here enter image description here enter image description here enter image description here enter image description here enter image description here enter image description here enter image description here enter image description here

Using above images, and ColorDepth set to Depth24Bit and TransparentColor set to Magenta here is the final result:

enter image description here

Also as another option you can set ToolBarIsVisible property of GViewer component to false and use your own ToolStrip or ToolBar. Then when clicking each button, you can call corresponding method of viewer component, like ZoomInPressed, ZoomOutPressed, BackwardButtonPressed, ForwardButtonPressed, ... .

Note:

For more information you can take a look at Microsoft Automatic Graph Layout source code repository and source code for GViewer control.