云题海 - 专业文章范例文档资料分享平台

当前位置:首页 > C#在AutoCAD2010中创建Ribbon

C#在AutoCAD2010中创建Ribbon

  • 62 次阅读
  • 3 次下载
  • 2025/5/4 0:59:27

API for CUIx files and the Runtime Ribbon in AutoCAD?

//now create button 2

Autodesk.Windows.RibbonButton ribButton2 = new RibbonButton(); ribButton2.Text = \;

ribButton2.CommandParameter = \; ribButton2.ShowText = true;

ribButton2.CommandHandler = new AdskCommandHandler();

//create a tooltip

Autodesk.Windows.RibbonToolTip ribToolTip = new RibbonToolTip(); ribToolTip.Command = \; ribToolTip.Title = \;

ribToolTip.Content = \;

ribToolTip.ExpandedContent = \Also check which event you should add handle to add custom ribbon on AutoCAD startup.\; ribButton1.ToolTip = ribToolTip;

//now add the 2 button with a RowBreak ribSourcePanel.Items.Add(ribButton1);

ribSourcePanel.Items.Add(new RibbonRowBreak()); ribSourcePanel.Items.Add(ribButton2);

//now add and expanded panel (with 1 button)

Autodesk.Windows.RibbonRowPanel ribExpPanel = new RibbonRowPanel();

//and add it to source

ribSourcePanel.Items.Add(ribExpPanel);//needs to be here

Autodesk.Windows.RibbonButton ribExpButton1 = new RibbonButton(); ribExpButton1.Text = \; ribExpButton1.ShowText = true;

ribExpButton1.CommandParameter = \;

ribExpButton1.CommandHandler = new AdskCommandHandler(); ribExpPanel.Items.Add(ribExpButton1);

5

API for CUIx files and the Runtime Ribbon in AutoCAD?

//ribSourcePanel.Items.Add(new RibbonPanelBreak()); //ribSourcePanel.Items.Add(ribExpPanel);//needs to be above }

private static void addPanel2(RibbonTab ribTab) {

//create the panel source

Autodesk.Windows.RibbonPanelSource ribSourcePanel = new RibbonPanelSource(); ribSourcePanel.Title = \; //now the panel

RibbonPanel ribPanel = new RibbonPanel(); ribPanel.Source = ribSourcePanel; ribTab.Panels.Add(ribPanel);

//create a Ribbon text

Autodesk.Windows.RibbonTextBox ribTxt = new RibbonTextBox(); ribTxt.Width = 100;

ribTxt.IsEmptyTextValid = false; ribTxt.InvokesCommand = true;

ribTxt.CommandHandler = new AdskCommandHandler();

//create a Ribbon List Button

Autodesk.Windows.RibbonSplitButton ribListBtn = new RibbonSplitButton(); Autodesk.Windows.RibbonButton ribButton1 = new RibbonButton(); ribButton1.Text = \; ribButton1.ShowText = true;

ribButton1.CommandParameter = \;

ribButton1.CommandHandler = new AdskCommandHandler(); Autodesk.Windows.RibbonButton ribButton2 = new RibbonButton(); ribButton2.Text = \; ribButton2.ShowText = true;

ribButton2.CommandParameter = \;

6

API for CUIx files and the Runtime Ribbon in AutoCAD?

ribButton2.CommandHandler = new AdskCommandHandler(); ribListBtn.Text = \; ribListBtn.ShowText = true; ribListBtn.Items.Add(ribButton1); ribListBtn.Items.Add(ribButton2);

ribSourcePanel.Items.Add(ribTxt);

ribSourcePanel.Items.Add(new RibbonRowBreak()); ribSourcePanel.Items.Add(ribListBtn); }

Here is the Event handler that is called when the control is clicked.

public class AdskCommandHandler: System.Windows.Input.ICommand {

public bool CanExecute(object parameter) {

return true; }

public event EventHandler CanExecuteChanged;

public void Execute(object parameter) {

//is from a Ribbon Button?

RibbonButton ribBtn = parameter as RibbonButton; if (ribBtn != null)

Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.SendStringToExecute((String)ribBtn.CommandParameter, true, false, true);

//is from s Ribbon Textbox?

RibbonTextBox ribTxt = parameter as RibbonTextBox;

7

API for CUIx files and the Runtime Ribbon in AutoCAD?

if (ribTxt != null)

System.Windows.Forms.MessageBox.Show(ribTxt.TextValue); } }

This command will remove the ribbon:

[CommandMethod(\)] public void removeRibbon() {

Autodesk.Windows.RibbonControl ribCntrl =

Autodesk.AutoCAD.Ribbon. RibbonServices.RibbonPaletteSet.RibbonControl; //find the custom tab using the Id for (int i = 0; i < ribCntrl.Tabs.Count; i++) {

if (ribCntrl.Tabs[i].Id.Equals(MY_TAB_ID)) {

ribCntrl.Tabs.Remove(ribCntrl.Tabs[i]); return; } } }

Here is a screenshot of the Ribbon with the new Tab after running the addMyRibbon command:

8

搜索更多关于: C#在AutoCAD2010中创建Ribbon 的文档
  • 收藏
  • 违规举报
  • 版权认领
下载文档10.00 元 加入VIP免费下载
推荐下载
本文作者:...

共分享92篇相关文档

文档简介:

API for CUIx files and the Runtime Ribbon in AutoCAD? //now create button 2 Autodesk.Windows.RibbonButton ribButton2 = new RibbonButton(); ribButton2.Text = \; ribButton2.CommandParameter = \; ribButton2.ShowText = true; ribButton2.CommandHandler = new AdskCommandHandler(); //create a tooltip Autodesk.Window

× 游客快捷下载通道(下载后可以自由复制和排版)
单篇付费下载
限时特价:10 元/份 原价:20元
VIP包月下载
特价:29 元/月 原价:99元
低至 0.3 元/份 每月下载150
全站内容免费自由复制
VIP包月下载
特价:29 元/月 原价:99元
低至 0.3 元/份 每月下载150
全站内容免费自由复制
注:下载文档有可能“只有目录或者内容不全”等情况,请下载之前注意辨别,如果您已付费且无法下载或内容有问题,请联系我们协助你处理。
微信:fanwen365 QQ:370150219
Copyright © 云题海 All Rights Reserved. 苏ICP备16052595号-3 网站地图 客服QQ:370150219 邮箱:370150219@qq.com