C# MSAGL 更改图标

C# MSAGL change icons

我用 c# 构建了一个 winforms 应用程序。

我正在尝试更改 MSAGL GViewer 组件的默认图标:

但我找不到在哪里可以这样做。

我该如何更改它们?

GViewer 控件使用包含新图像的旧 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 工具栏:

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

图片列表应该有 18 张图片,顺序如下。将图像添加到图像列表时。添加图像后,将索引 2 处图像的 Name 属性 设置为 zoom.bmp 因为工具栏使用它的名称而不是索引:

使用上面的图片,ColorDepth设置为Depth24BitTransparentColor设置为Magenta,这是最终结果:

此外,您可以将 GViewer 组件的 ToolBarIsVisible 属性 设置为 false 并使用您自己的 ToolStripToolBar .然后在点击每个按钮时,可以调用查看器组件对应的方法,如ZoomInPressedZoomOutPressedBackwardButtonPressedForwardButtonPressed、...

注:

有关更多信息,您可以查看 Microsoft Automatic Graph Layout source code repository and source code for GViewer 控件。