明经CAD社区

 找回密码
 注册

QQ登录

只需一步,快速开始

搜索
查看: 940|回复: 2

各位大侠个给看看错在哪里了,谢谢

[复制链接]
发表于 2015-6-16 13:58 | 显示全部楼层 |阅读模式
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不这么写吗

发表于 2015-6-16 18:53 | 显示全部楼层
看不懂
发表于 2015-6-17 16:52 | 显示全部楼层
你确定是RibbonCombo, 而不是RibbonComboBox?
ComponentManager.Ribbon中ComponentManager 是什么?
编译不过去,不知道你是怎么编译过得!
还是看一下例子:http://www.cnblogs.com/junqilian/archive/2012/06/18/2553662.html

您需要登录后才可以回帖 登录 | 注册

本版积分规则

小黑屋|手机版|CAD论坛|CAD教程|CAD下载|联系我们|关于明经|明经通道 ( 粤ICP备05003914号 )  
©2000-2023 明经通道 版权所有 本站代码,在未取得本站及作者授权的情况下,不得用于商业用途

GMT+8, 2024-5-3 11:16 , Processed in 2.641045 second(s), 27 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表