2
1
初来乍到
namespace RibbonSample { public class Ribbon { [CommandMethod("MyRibbon")] public void MyRibbon() { Autodesk.Windows.RibbonControl ribbonControl = Autodesk.Windows.ComponentManager.Ribbon; RibbonTab Tab = new RibbonTab(); Tab.Title = "Autodesk .NET forum Ribbon Sample"; Tab.Id = "RibbonSample_TAB_ID"; Tab.IsContextualTab = false; ribbonControl.Tabs.Add(Tab); // create Ribbon panels Autodesk.Windows.RibbonPanelSource panel1Panel = new RibbonPanelSource(); panel1Panel.Title = "Panel1"; RibbonPanel Panel1 = new RibbonPanel(); Panel1.Source = panel1Panel; Tab.Panels.Add(Panel1); RibbonButton pan1button1 = new RibbonButton(); pan1button1.Text = "Button1"; pan1button1.ShowText = true; pan1button1.ShowImage = true; pan1button1.Image = Images.getBitmap(Properties.Resources.Small); pan1button1.LargeImage = Images.getBitmap(Properties.Resources.large); pan1button1.Orientation = System.Windows.Controls.Orientation.Vertical; pan1button1.Size = RibbonItemSize.Large; panel1Panel.Items.Add(pan1button1); Tab.IsActive = true; pan1button1.CommandHandler = new RibbonCommandHandler(); pan1button1.CommandParameter = "Test "; } [CommandMethod("Test")] public void MyRibbon2() { Autodesk.Windows.RibbonControl ribbonControl = Autodesk.Windows.ComponentManager.Ribbon; RibbonTab Tab1 = new RibbonTab(); Tab1.Title = "Autodesk test"; Tab1.Id = "RibbonSample_TAB_ID"; Tab1.IsContextualTab = false; ribbonControl.Tabs.Add(Tab1); // create Ribbon panels Autodesk.Windows.RibbonPanelSource panelPanel = new RibbonPanelSource(); panelPanel.Title = "Panel test"; RibbonPanel Panel = new RibbonPanel(); Panel.Source = panelPanel; Tab1.Panels.Add(Panel); RibbonButton pan1button1 = new RibbonButton(); pan1button1.Text = "Button test"; pan1button1.ShowText = true; pan1button1.ShowImage = true; pan1button1.Image = Images.getBitmap(Properties.Resources.Small); pan1button1.LargeImage = Images.getBitmap(Properties.Resources.large); pan1button1.Orientation = System.Windows.Controls.Orientation.Vertical; pan1button1.Size = RibbonItemSize.Standard; panelPanel.Items.Add(pan1button1); Tab1.IsActive = true; pan1button1.CommandHandler = new RibbonCommandHandler(); pan1button1.CommandParameter = "_Circle "; } public class RibbonCommandHandler : System.Windows.Input.ICommand { public RibbonTab Getstatus(RibbonTab tab) { return tab; } public bool CanExecute(object parameter) { return true; } public event EventHandler CanExecuteChanged; public void Execute(object parameter) { Document doc = acadApp.DocumentManager.MdiActiveDocument; RibbonCommandItem cmd = parameter as RibbonCommandItem; doc.SendStringToExecute((string)cmd.CommandParameter, true, false, true); } } public class Images { public static BitmapImage getBitmap(Bitmap image) { MemoryStream stream = new MemoryStream(); image.Save(stream, ImageFormat.Png); BitmapImage bmp = new BitmapImage(); bmp.BeginInit(); bmp.StreamSource = stream; bmp.EndInit(); return bmp; } } } }
本帖以下内容被隐藏保护;需要你回复后,才能看到!
使用道具 举报
本版积分规则 发表回复 回帖后跳转到最后一页
微信公众平台
扫描访问手机版
点击图片下载手机App
|关于我们|小黑屋|乐筑天下 繁体中文
GMT+8, 2024-11-22 09:02 , Processed in 0.237194 second(s), 54 queries .
© 2020-2024 乐筑天下
在线时间:10:00-17:00
暂无
扫一扫,关注我们
帮助中心
关于我们
下载APP客户端