本文介绍如用C1RadialMenu创建源于OneNote的圆形菜单,完全替代传统菜单和工具栏。
首先从工具箱拖拽C1RadialMenu到窗体,它被放到底部的组件栏。
其次,打开C1RadialMenu的Items,弹出RadialMenuItem的集合编辑器。添加需要的Item。它可以嵌套添加多层的Item。
然后,可以通过Image和Text属性给Item设置图片和文字。
最后通过调用C1RadialMenu.ShowMenu方法,将C1RadialMenu在运行时显示在特定的位置。并且通过调用C1RadialMenu.HideMenu方法,隐藏已经显示出来的C1RadiaMenu。这两个方法说明如下:
// // 摘要: // Shows the radial menu at the specified screen point. If the menu is currently // visible at another location, it is hidden first. // // 参数: // form: // The owner form. // // pt: // The radial menu center's screen coordinates. // // expand: // Indicates whether the menu should show initially expanded. public void ShowMenu(Form form, Point pt, bool expand = false); // 摘要: // Hides the radial menu if it is currently visible. public void HideMenu();
这样,在附件的Demo里,点击鼠标右键将会显示C1RadialMenu创建的圆形菜单,点击鼠标左键就会关闭。该圆形菜单的样子如下所示:
本文Demo中创建圆形菜单的源代码如下: