各位大侠个给看看错在哪里了,谢谢
using Autodesk.AutoCAD.ApplicationServices;using Autodesk.AutoCAD.EditorInput;
using Autodesk.AutoCAD.Runtime;
using Autodesk.Windows;
using System.Windows.Controls;
using System.Windows.Input;
using System.Windows;
using System;
namespace insFst
{
public class Commands
{
public bool _added = false;
public void RibbonTextBox()
{
if (!_added)
{
RibbonControl rc = ComponentManager.Ribbon;
RibbonTab rt = null;
foreach (RibbonTab tab in rc.Tabs)
{
if (tab.Name == "Plug-ins")
{
rt = tab;
break;
}
}
if (rt == null)
{
rt = new RibbonTab();
rt.Title = "Custom";
rt.Id = "ID_CUSTOMRIBBONTAB";
rc.Tabs.Add(rt);
}
RibbonPanelSource rps = new RibbonPanelSource();
rps.Title = "Notifying Textbox";
RibbonPanel rp = new RibbonPanel();
rp.Source = rps;
rt.Panels.Add(rp);
RibbonItem ri0 = new RibbonItem { Text = "90",};
RibbonItem ri1 = new RibbonItem { Text = "-90", };
RibbonCombo tb = new RibbonCombo();
tb.CommandHandler = new ComboBoxCommandHandler();
tb.Items.Add(ri0);
tb.Items.Add(ri1);
rps.Items.Add(tb);
rt.IsActive = true;
_added = true;
}
}
public static void Print(string s)
{
Document doc =
Autodesk.AutoCAD.ApplicationServices.
Application.DocumentManager.MdiActiveDocument;
doc.Editor.WriteMessage(s);
}
}
public class ComboBoxCommandHandler : ICommand
{
#pragma warning disable 67
public event EventHandler CanExecuteChanged;
#pragma warning restore 67
public bool CanExecute(object parameter)
{
return true;
}
public void Execute(object parameter)
{
RibbonCombo tb = parameter as RibbonCombo;
if (tb != null)
{
Commands.Print( tb.Text );
}
}
}
}
我想实现的功能,就是在Cad的命令行中显示下拉框中的值
请各位大侠给看看哪里错了,为什么红色字体处设置断点后,不执行呢,我同样是RibbonTextBox,RibbonButton都执行,为什么,还是说RibbonCombo不这么写吗
看不懂
你确定是RibbonCombo, 而不是RibbonComboBox?
ComponentManager.Ribbon中ComponentManager 是什么?
编译不过去,不知道你是怎么编译过得!
还是看一下例子:http://www.cnblogs.com/junqilian/archive/2012/06/18/2553662.html
页:
[1]