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;
[assembly: CommandClass(typeof(insFst.Commands))]
namespace insFst
{
public class Commands
{
public bool _added = false;
[CommandMethod("RTB")]
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不这么写吗