功能区为经常访问且与当前工作区相关的工具提供位置。
它被组织成选项卡,就像工具栏上的菜单一样。每个选项卡都包含一个或多个面板,其中包含执行不同操作的项目。
Autodesk.Windows是包含与功能区关联的类和枚举的托管命名空间。
制表符
选项卡是功能区中的初始导航界面。用于创建选项卡的类。RibbonTab
有两种类型:
- ActiveTab - 表示当前选择的选项卡。
- ActiveContextualTab - 表示仅在所选内容中包含特定类型的 AutoCAD 对象(如填充或表格)时才显示的选项卡。
板
面板包含与选项卡关联的所有工具。带有前缀的类控制面板的各个方面,例如面板的可见性、大小和浮动位置。RibbonPanel
RibbonRow对象定义面板中放置项目的行。这些行将添加到一个对象中,该对象包含功能区中显示的面板的面板定义。RibbonPanelSource
项目
项目可能是以下两种情况之一。它们可以是面板中包含的单个工具,例如按钮 () 或窗体 ();或者它们可以是一个视觉分隔符,例如行面板 () 或分隔符 ()。 是这两种类型的父类。RibbonButtonRibbonFormRibbonRowPanelRibbonSeparatorRibbonItem
在项本身中存在其他子类,例如 、 或 下面 。有关这些子类型的更多信息,请参阅《ObjectARX 托管类参考指南》。RibbonDropDownButtonRibbonMenuButtonRibbonToggleButtonRibbonButton
功能区创建示例
下面是创建和填充对象的示例代码。这里的重要信息是遵循构造的层次结构,例如,必须将项目添加到面板中,而面板必须添加到选项卡中。功能区还有许多可自定义的属性,例如标题文本、大小、方向、工具提示和要显示的图像。Ribbon
- VB.NET
-
'' First, the button items are created:
Dim button1 As RibbonButton = New RibbonButton()
button1.Text = "Button1"
Dim button2 As RibbonButton = New RibbonButton()
button2.Text = "Button2"
'' These are then added to a row:
Dim row As RibbonRow = New RibbonRow()
row.RowItems.Add(button1)
row.RowItems.Add(button2)
'' This row is added to a panel source, which is then added to a panel:
Dim panelSource As RibbonPanelSource = New RibbonPanelSource()
panelSource.Title = "Panel1"
panelSource.Rows.Add(row)
Dim panel As RibbonPanel = New RibbonPanel()
panel.Source = panelSource
'' Last, the panel is added to a tab, which is added to the ribbon:
Dim tab As RibbonTab = New RibbonTab()
tab.Title = "Tab1"
tab.Panels.Add(panel)
Dim ribbon As RibbonControl = New RibbonControl()
ribbon.Tabs.Add(tab)
- C#
-
// First, the button items are created:
RibbonButton button1 = new RibbonButton;
button1.Text = "Button1";
RibbonButton button2 = new RibbonButton;
button2.Text = "Button2";
// These are then added to a row:
RibbonRow row = new RibbonRow();
row.RowItems.Add(button1);
row.RowItems.Add(button2);
// This row is added to a panel source, which is then added to a panel:
RibbonPanelSource panelSource = new RibbonPanelSource();
panelSource.Title = "Panel1";
panelSource.Rows.Add(row);
RibbonPanel panel = new RibbonPanel();
panel.Source = panelSource;
// Last, the panel is added to a tab, which is added to the ribbon:
RibbonTab tab = new RibbonTab();
tab.Title = "Tab1";
tab.Panels.Add(panel);
RibbonControl ribbon = new RibbonControl();
ribbon.Tabs.Add(tab);
|