C# MSAGL 更改图标

标签 c# winforms toolbar msagl

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

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

MSAGL icons

但我不知道在哪里可以做到这一点。

如何更改它们?

最佳答案

GViewer 控件使用旧的 ToolBar控件来显示这些按钮。要替换这些图标,您可以在查看器控件的控件集合中找到工具栏并设置新的 ImageList包含工具栏的新图像:

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

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

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

使用上面的图像,并将 ColorDepth 设置为 Depth24Bit 并将 TransparentColor 设置为 Magenta 这里是最终结果:

enter image description here

作为另一个选项,您可以将 GViewer 组件的 ToolBarIsVisible 属性设置为 false 并使用您自己的 ToolStrip工具栏。然后,当单击每个按钮时,您可以调用查看器组件相应的方法,例如 ZoomInPressedZoomOutPressedBackwardButtonPressedForwardButtonPressed >, ... .

注意:

欲了解更多信息,您可以查看Microsoft Automatic Graph Layout源代码存储库和 GViewer 的源代码控制。

关于C# MSAGL 更改图标,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37689002/

相关文章:

c# - 维持稳定用户 session 的标准方法是什么?

c# - 在 Caliburn Micro 中进行多个窗口的正确方法?

c# - 是否可以防止 Visual Studio 在 BackgroundWorker.DoWork 内出现异常时中断

c# - Android应用程序和Winform应用程序之间发送和接收消息

javascript - 屏幕底部的温泉元素列表

c# - 如何在 BeforeTestRun 中创建内容并在步骤定义中访问它

c# - 如何将文本框设置为可见 false 但仍可在其上书写?

c# - MEF 加载和卸载特定插件?

java - Materialdesign 工具栏后退箭头在 Lollipop 之前的版本中不显示

html - 将背景图像分配给 ExtJs 的工具栏