public void CreateUI() { RibbonControl rc = Autodesk.Windows.ComponentManager.Ribbon; RibbonTab primaryTab = rc.FindTab(Jpp.Ironstone.Core.Constants.IRONSTONE_TAB_ID); RibbonPanel Panel = new RibbonPanel(); RibbonPanelSource source = new RibbonPanelSource(); source.Title = Properties.Resources.ExtensionApplication_UI_PanelTitle; RibbonRowPanel column1 = new RibbonRowPanel(); column1.IsTopJustified = true; column1.Items.Add(UIHelper.CreateWindowToggle(Properties.Resources.ExtensionApplication_UI_SoilMenuButton, Properties.Resources.Earth_Small, RibbonItemSize.Standard, new SoilPropertiesView(), "4c7eae1d-ce9f-4a7a-a397-584aced7983c")); column1.Items.Add(new RibbonRowBreak()); RibbonSplitButton rsb = new RibbonSplitButton(); rsb.ShowText = true; rsb.Items.Add(UIHelper.CreateButton("Add Tree", Properties.Resources.Tree_Small, RibbonItemSize.Standard, "S_TreeRings_New")); rsb.Items.Add(UIHelper.CreateButton("Copy Tree", Properties.Resources.Tree_Small, RibbonItemSize.Standard, "S_TreeRings_Copy")); rsb.Items.Add(UIHelper.CreateButton("Add Hedge Row", Properties.Resources.Tree_Small, RibbonItemSize.Standard, "S_Hedgerow_New")); column1.Items.Add(rsb); //Build the UI hierarchy source.Items.Add(column1); Panel.Source = source; primaryTab.Panels.Add(Panel); }
/// <summary> /// This will set the font on your ribbon. /// </summary> /// <param name="fontName">The font to use.</param> /// <returns name="fontName">Thefont used.</returns> public static string SetFont(string fontName) { adWin.RibbonControl ribbon = adWin.ComponentManager.Ribbon; ribbon.FontFamily = new System.Windows.Media .FontFamily(fontName); return(fontName); }
private CustomRibbon() { _ribbonControl = UIFramework.RevitRibbonControl.RibbonControl; if (_ribbonControl is null) { throw new NotSupportedException("Could not initialize Revit ribbon control"); } }
public Result OnStartup(UIControlledApplication a) { adWin.RibbonControl ribbon = adWin.ComponentManager.Ribbon; foreach (adWin.RibbonTab tab in ribbon.Tabs) { if (tab.Id == "Analyze") { foreach (adWin.RibbonPanel panel in tab.Panels) { if (panel.Source.Id == "cea_shr") { adWin.RibbonButton button = new adWin.RibbonButton(); button.Name = "TbcButtonName"; //button.Image = image; //button.LargeImage = image; button.Id = "ID_TBC_BUTTON"; button.AllowInStatusBar = true; button.AllowInToolBar = true; button.GroupLocation = Autodesk.Private .Windows.RibbonItemGroupLocation.Middle; button.IsEnabled = true; button.IsToolTipEnabled = true; button.IsVisible = true; button.ShowImage = false; // true; button.ShowText = true; button.ShowToolTipOnDisabled = true; button.Text = "The Building Coder"; button.ToolTip = "Open The Building " + "Coder blog on the Revit API"; button.MinHeight = 0; button.MinWidth = 0; button.Size = adWin.RibbonItemSize.Large; button.ResizeStyle = adWin .RibbonItemResizeStyles.HideText; button.IsCheckable = true; button.Orientation = System.Windows .Controls.Orientation.Vertical; button.KeyTip = "TBC"; adWin.ComponentManager.UIElementActivated += new EventHandler < adWin.UIElementActivatedEventArgs>( ComponentManager_UIElementActivated); panel.Source.Items.Add(button); return(Result.Succeeded); } } } } return(Result.Succeeded); }
//public bool IsVisible; public CustomRibbon(UIControlledApplication application) { _application = application; _ribbonControl = RevitRibbonControl.RibbonControl as Autodesk.Windows.RibbonControl; if (_ribbonControl is null) { throw new NotSupportedException("Could not initialize Revit ribbon control"); } }
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; } } }
public static AW.RibbonTab GetTab(string tabName) { AW.RibbonControl ribbon = AW.ComponentManager.Ribbon; foreach (AW.RibbonTab tab in ribbon.Tabs) { if (tab.Name == tabName) { return(tab); } } return(null); }
public void CreateRibbon() { if (ComponentManager.Ribbon == null) { MessageBox.Show($"请先通过 RIBBON 命令打开选项卡,然后重复 {CmdStartRibbon} 命令。", @"提示", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } var ed = Application.DocumentManager.MdiActiveDocument.Editor; RibbonControl ribCntrl = ComponentManager.Ribbon; // ribCntrl can also be RibbonServices.RibbonPaletteSet.RibbonControl, this class can be found in AcWindows.dll; // 如果已经加载,则显示出来即可 var existingRibbonTab = ribCntrl.Tabs.FirstOrDefault(r => r.Id == TabId_SubgradeQuantity && r.Title == TabTitle_SubgradeQuantity && r.Name == TabName_SubgradeQuantity); if (existingRibbonTab != null) { ed.Command(new object[] { "Ribbon" }); existingRibbonTab.IsActive = true; return; } else { //Add the tab RibbonTab ribTab = new RibbonTab { Title = TabTitle_SubgradeQuantity, Id = TabId_SubgradeQuantity, Name = TabName_SubgradeQuantity }; ribCntrl.Tabs.Add(ribTab); // try { AddControls(ribTab); } catch (Exception ex) { MessageBox.Show(ex.Message, "选项卡工具加载出错\r\n" + ex.StackTrace, MessageBoxButtons.OK, MessageBoxIcon.Error); } //set as active tab ribTab.IsActive = true; } ed.Command(new object[] { "Ribbon" }); }
/// <summary> /// This will give you access to all tabs. /// </summary> /// <param name="toggle">True or false to refresh collection.</param> /// <returns name="ribbonTabs">The ribbon tabs in the application.</returns> /// <search> /// Ribbon.RenameTab /// </search> public static List <adWin.RibbonTab> GetTabs(bool toggle) { var uiapp = DocumentManager.Instance.CurrentUIApplication; adWin.RibbonControl ribbon = adWin.ComponentManager.Ribbon; List <adWin.RibbonTab> ribbonTabs = new List <adWin.RibbonTab>(); foreach (adWin.RibbonTab tab in ribbon.Tabs) { ribbonTabs.Add(tab); } return(ribbonTabs); }
public void Setup(adWin.RibbonControl ribbon) { try { // find the view tab listing1.Items.Clear(); foreach (adWin.RibbonTab tab in ribbon.Tabs) { ListViewItem item = listing1.Items.Add(tab.Id); item.Tag = tab; } } catch (Exception e) { //failed to add button, don't do a thing } }
public static void Test() { Autodesk.Windows.RibbonControl rbnCtrl = Autodesk.AutoCAD.Ribbon.RibbonServices.RibbonPaletteSet.RibbonControl; //Add custom ribbon tab RibbonTab rbnTab = new RibbonTab { Title = "Custom commands", Id = TAB_ID }; rbnCtrl.Tabs.Add(rbnTab); rbnTab.IsActive = true; //Add custom ribbon panel RibbonPanel rbnPnl = new RibbonPanel { //Add ribbon panel source Source = new RibbonPanelSource { Title = "Custom Panel" } }; rbnTab.Panels.Add(rbnPnl); //Add custom ribbon button Autodesk.Windows.RibbonButton rbnBtn = new RibbonButton { Text = "ADN", CommandParameter = "ADN ", ShowText = true, Image = GetBitmap("RibbonToolTip_Case.Yoda.jpg", 16, 16), LargeImage = GetBitmap("RibbonToolTip_Case.Yoda.jpg", 32, 32), ShowImage = true }; Autodesk.Windows.RibbonToolTip rbnTT = new RibbonToolTip { Command = "ADN", Title = "Hello ADN", Content = "blah ..", ExpandedContent = "Expanded Blah ..." }; rbnBtn.ToolTip = rbnTT; rbnPnl.Source.Items.Add(rbnBtn); }
public static AW.RibbonPanel GetPanel(string tabName, string panelName) { AW.RibbonControl ribbon = AW.ComponentManager.Ribbon; foreach (AW.RibbonTab tab in ribbon.Tabs) { if (tab.Name == tabName) { foreach (AW.RibbonPanel panel in tab.Panels) { if (panel.Source.Title == panelName) { return(panel); } } } } return(null); }
public void createRibbon() { Autodesk.Windows.RibbonControl ribCntrl = Autodesk.AutoCAD.Ribbon.RibbonServices.RibbonPaletteSet.RibbonControl; //can also be Autodesk.Windows.ComponentManager.Ribbon; //add the tab RibbonTab ribTab = new RibbonTab(); ribTab.Title = "My custom tab"; ribTab.Id = MY_TAB_ID; ribCntrl.Tabs.Add(ribTab); //create and add both panels addPanel1(ribTab); addPanel2(ribTab); //set as active tab ribTab.IsActive = true; }
//Hacky way to get a ribbon item, not supported officially public AW.RibbonItem GetButton(string tabName, string panelName, string itemName) { AW.RibbonControl ribbon = AW.ComponentManager.Ribbon; foreach (AW.RibbonTab tab in ribbon.Tabs) { if (tab.Name == tabName) { foreach (AW.RibbonPanel panel in tab.Panels) { if (panel.Source.Title == panelName) { return(panel.FindItem("CustomCtrl_%CustomCtrl_%" + tabName + "%" + panelName + "%" + itemName, true) as AW.RibbonItem); } } } } return(null); }
/// <summary> /// This will set the color of your ribbon. /// </summary> /// <param name="color">The color to use</param> /// <returns name="color">The rotated amount.</returns> public static Color SetColor(Color color) { adWin.RibbonControl ribbon = adWin.ComponentManager.Ribbon; LinearGradientBrush gradientBrush = new LinearGradientBrush(); gradientBrush.GradientStops.Add( new GradientStop(System.Windows.Media.Color.FromRgb(color.Red, color.Green, color.Blue), 0.0)); gradientBrush.GradientStops.Add( new GradientStop(System.Windows.Media.Color.FromRgb(color.Red, color.Green, color.Blue), 1)); foreach (adWin.RibbonTab tab in ribbon.Tabs) { foreach (adWin.RibbonPanel panel in tab.Panels) { panel.CustomPanelBackground = gradientBrush; panel.CustomPanelTitleBarBackground = gradientBrush; } } return(color); }
public static void InitGeo7Ribbon() { AppLog.Add("InitGeo7Ribbon()..."); if (Geo7ToolsTab == null) { Geo7ToolsTab = new RibbonTab(); Geo7ToolsTab.Title = Geo7ToolsApp.AppName; Geo7ToolsTab.Id = Geo7ToolsApp.AppName.Replace(" ", "_"); if (Ac.Licence.IsValid || Ac.RunWithoutLicense) { AppLog.Add("InitGeo7Ribbon():AddBlocksPanel()..."); AddBlocksPanel(); AppLog.Add("InitGeo7Ribbon():AddDrawPanel()..."); AddDrawPanel(); AppLog.Add("InitGeo7Ribbon():AddToolsPanel()..."); AddToolsPanel(); } AppLog.Add("InitGeo7Ribbon():AddConfigurationPanel()..."); AddConfigurationPanel(); AppLog.Add("InitGeo7Ribbon():Done."); } Autodesk.Windows.RibbonControl ribbon = ComponentManager.Ribbon; if (ribbon == null) { AppLog.Add(AcConsts.RibbonNotFound); Ac.WriteLn(AcConsts.RibbonNotFound); return; } if (ribbon.FindTab(Geo7ToolsTab.Id) == null) { AppLog.Add("InitGeo7Ribbon():ribbon.Tabs.Add(Geo7ToolsTab)..."); ribbon.Tabs.Add(Geo7ToolsTab); } AppLog.Add("InitGeo7Ribbon():Done."); }
static public void createRibbon() { Autodesk.Windows.RibbonControl ribCntrl = Autodesk.AutoCAD.Ribbon.RibbonServices.RibbonPaletteSet.RibbonControl; //can also be Autodesk.Windows.ComponentManager.Ribbon; //add the tab RibbonTab ribTab = new RibbonTab(); ribTab.Title = "WT-Tools"; ribTab.Id = MY_TAB_ID; ribCntrl.Tabs.Add(ribTab); //create and add both panels //addRegistry(ribTab); addRefMgr(ribTab); addWDGed(ribTab); addCusEnt(ribTab); //addPanel2(ribTab); //set as active tab ribTab.IsActive = true; }
public void createRibbon() { //Get the AutoCAD Ribbon Autodesk.Windows.RibbonControl ribCntrl = Autodesk.AutoCAD.Ribbon.RibbonServices.RibbonPaletteSet.RibbonControl; //can also use Autodesk.Windows.ComponentManager.Ribbon; //Create a tab RibbonTab ribTab = new RibbonTab(); ribTab.Title = "女裤"; ribTab.Id = MY_TAB_ID; // Add the tab to the ribbon. ribCntrl.Tabs.Add(ribTab); // Create and add a couple of panels. (Methods are below) AddPanel1(ribTab); AddPanel2(ribTab); //Make the tab active ribTab.IsActive = true; }
//[CommandMethod("NetAddRibbon")] public void CreateRibbon() { RibbonControl ribCntrl = RibbonServices.RibbonPaletteSet.RibbonControl; RibbonTab tab = ribCntrl.Tabs.Where(q => q.Title.Equals("My custom tab")).FirstOrDefault(); if (tab != null) { ribCntrl.Tabs.Remove(tab); } //can also be Autodesk.Windows.ComponentManager.Ribbon; //add the tab RibbonTab ribTab = new RibbonTab(); ribTab.Title = "My custom tab"; ribTab.Id = MY_TAB_ID; ribCntrl.Tabs.Add(ribTab); //create and add both panels //addPanel1(ribTab); addPanel2(ribTab); //set as active tab ribTab.IsActive = true; }
//Ribbon hinzufügen public void addRessourceTab() { RibbonSeparator separator = new RibbonSeparator(); separator.SeparatorStyle = RibbonSeparatorStyle.Spacer; //************** //PanelSource IO RibbonPanelSource panelSrcIO = new RibbonPanelSource(); panelSrcIO.Title = "Punkte Import/Export"; //Pt Import RibbonButton bt_PtImport = new RibbonButton(); bt_PtImport.Id = "PtImport"; bt_PtImport.Text = "Punkte importieren"; bt_PtImport.Image = myUtilities.Media.Images.ToImageSource(global::CAS2018.Resources.IN_small); bt_PtImport.LargeImage = myUtilities.Media.Images.ToImageSource(global::CAS2018.Resources.IN_small); bt_PtImport.Orientation = System.Windows.Controls.Orientation.Horizontal; bt_PtImport.Size = RibbonItemSize.Standard; bt_PtImport.ShowText = false; bt_PtImport.ShowImage = true; bt_PtImport.CommandHandler = new RibbonCommandHandler(); bt_PtImport.ShowToolTipOnDisabled = true; bt_PtImport.Description = "Punkte importieren"; //Import 3d? RibbonCheckBox ribchkBoxImport3d = new RibbonCheckBox(); ribchkBoxImport3d.Id = "PtImport3d"; ribchkBoxImport3d.Text = "3d"; ribchkBoxImport3d.Initialized += new EventHandler(ribchkBoxImport3d_Initialized); ribchkBoxImport3d.PropertyChanged += new System.ComponentModel.PropertyChangedEventHandler(ribchkBoxImport3d_PropertyChanged); ribchkBoxImport3d.CommandHandler = new RibbonCommandHandler(); //Pt Export RibbonButton bt_PtExport = new RibbonButton(); bt_PtExport.Id = "PtExport"; bt_PtExport.Text = "Punkte exportieren"; bt_PtExport.Image = myUtilities.Media.Images.ToImageSource(global::CAS2018.Resources.Out_small); bt_PtExport.LargeImage = myUtilities.Media.Images.ToImageSource(global::CAS2018.Resources.Out); bt_PtExport.Orientation = System.Windows.Controls.Orientation.Horizontal; bt_PtExport.Size = RibbonItemSize.Standard; bt_PtExport.ShowText = false; bt_PtExport.ShowImage = true; bt_PtExport.CommandHandler = new RibbonCommandHandler(); bt_PtExport.ShowToolTipOnDisabled = true; bt_PtExport.Description = "Punkte exportieren"; //ComboBox für aktuellen Punktlayer RibbonCombo ribCB_Basislayer = new RibbonCombo(); ribCB_Basislayer.Text = "Basislayer:"; ribCB_Basislayer.ShowText = true; ribCB_Basislayer.MinWidth = 100; ribCB_Basislayer.DropDownWidth = 150; ribCB_Basislayer.Initialized += new EventHandler(ribCB_Basislayer_Initialized); ribCB_Basislayer.CurrentChanged += new EventHandler <RibbonPropertyChangedEventArgs>(ribCB_Basislayer_CurrentChanged); ribCB_Basislayer.DropDownOpened += new EventHandler <EventArgs>(ribCB_Basislayer_DropDownOpened); RibbonRowPanel rowPanel_IO = new RibbonRowPanel(); rowPanel_IO.Items.Add(bt_PtImport); rowPanel_IO.Items.Add(ribchkBoxImport3d); rowPanel_IO.Items.Add(new RibbonRowBreak()); rowPanel_IO.Items.Add(bt_PtExport); rowPanel_IO.Items.Add(separator); rowPanel_IO.Items.Add(ribCB_Basislayer); panelSrcIO.Items.Add(rowPanel_IO); //************** //PanelSource Tools Autodesk.Windows.RibbonPanelSource panelSrcTools = new Autodesk.Windows.RibbonPanelSource(); panelSrcTools.Title = "Tools"; //Punkte einfügen Autodesk.Windows.RibbonButton bt_PtIns = new Autodesk.Windows.RibbonButton(); bt_PtIns.Id = "PtIns"; bt_PtIns.Text = "Punkte einfügen"; bt_PtIns.Image = myUtilities.Media.Images.ToImageSource(global::CAS2018.Resources.BlockManipulation); bt_PtIns.LargeImage = myUtilities.Media.Images.ToImageSource(global::CAS2018.Resources.BlockManipulation); bt_PtIns.Orientation = System.Windows.Controls.Orientation.Horizontal; bt_PtIns.Size = Autodesk.Windows.RibbonItemSize.Standard; bt_PtIns.ShowText = false; bt_PtIns.ShowImage = true; bt_PtIns.CommandHandler = new RibbonCommandHandler(); bt_PtIns.ShowToolTipOnDisabled = true; bt_PtIns.Description = "Punkte einfügen"; //Blockattribute Pre-/Suffix Autodesk.Windows.RibbonButton bt_attPreSuf = new Autodesk.Windows.RibbonButton(); bt_attPreSuf.Id = "BlockManipulator"; bt_attPreSuf.Text = "Block Operationen"; bt_attPreSuf.Image = myUtilities.Media.Images.ToImageSource(global::CAS2018.Resources.BlockManipulation); bt_attPreSuf.LargeImage = myUtilities.Media.Images.ToImageSource(global::CAS2018.Resources.BlockManipulation); bt_attPreSuf.Orientation = System.Windows.Controls.Orientation.Horizontal; bt_attPreSuf.Size = Autodesk.Windows.RibbonItemSize.Standard; bt_attPreSuf.ShowText = false; bt_attPreSuf.ShowImage = true; bt_attPreSuf.CommandHandler = new RibbonCommandHandler(); bt_attPreSuf.ShowToolTipOnDisabled = true; bt_attPreSuf.Description = "Blöcke manipulieren"; //Layer exportieren Autodesk.Windows.RibbonButton bt_layExport = new Autodesk.Windows.RibbonButton(); bt_layExport.Id = "layExport"; bt_layExport.Text = "Layer exportieren"; bt_layExport.Image = myUtilities.Media.Images.ToImageSource(global::CAS2018.Resources.LayerEport); bt_layExport.LargeImage = myUtilities.Media.Images.ToImageSource(global::CAS2018.Resources.LayerEport); bt_layExport.Orientation = System.Windows.Controls.Orientation.Horizontal; bt_layExport.Size = Autodesk.Windows.RibbonItemSize.Large; bt_layExport.ShowText = false; bt_layExport.ShowImage = true; bt_layExport.CommandHandler = new RibbonCommandHandler(); bt_layExport.ShowToolTipOnDisabled = true; bt_layExport.Description = "Layer exportieren"; //Objekte auf 3d heben Autodesk.Windows.RibbonButton bt_Obj3d = new Autodesk.Windows.RibbonButton(); bt_layExport.Id = "Obj3d"; bt_layExport.Text = "Objekte auf 3d heben"; bt_layExport.Image = myUtilities.Media.Images.ToImageSource(global::CAS2018.Resources.ObjTo3d); bt_layExport.LargeImage = myUtilities.Media.Images.ToImageSource(global::CAS2018.Resources.ObjTo3d); bt_layExport.Orientation = System.Windows.Controls.Orientation.Horizontal; bt_layExport.Size = Autodesk.Windows.RibbonItemSize.Standard; bt_layExport.ShowText = false; bt_layExport.ShowImage = true; bt_layExport.CommandHandler = new RibbonCommandHandler(); bt_layExport.ShowToolTipOnDisabled = true; bt_layExport.Description = "Objekte auf 3d heben"; panelSrcTools.Items.Add(bt_PtIns); panelSrcTools.Items.Add(bt_attPreSuf); panelSrcTools.Items.Add(bt_layExport); panelSrcTools.Items.Add(new RibbonRowBreak()); panelSrcTools.Items.Add(bt_Obj3d); //************** //PanelSource Attribute Autodesk.Windows.RibbonPanelSource panelSrcAtt = new Autodesk.Windows.RibbonPanelSource(); panelSrcAtt.Title = "Blockattribute"; Autodesk.Windows.RibbonSubPanelSource panelSubSrcAtt = new Autodesk.Windows.RibbonSubPanelSource(); //Att Pon Autodesk.Windows.RibbonButton bt_AttPon = new Autodesk.Windows.RibbonButton(); bt_AttPon.Id = "AttPon"; bt_AttPon.Image = myUtilities.Media.Images.ToImageSource(global::CAS2018.Resources.AttPon); bt_AttPon.LargeImage = myUtilities.Media.Images.ToImageSource(global::CAS2018.Resources.AttPon); bt_AttPon.Orientation = System.Windows.Controls.Orientation.Vertical; bt_AttPon.Size = Autodesk.Windows.RibbonItemSize.Standard; bt_AttPon.ShowText = false; bt_AttPon.ShowImage = true; bt_AttPon.CommandHandler = new RibbonCommandHandler(); bt_AttPon.ShowToolTipOnDisabled = true; bt_AttPon.Description = "PNr einschalten"; //Att Poff Autodesk.Windows.RibbonButton bt_AttPoff = new Autodesk.Windows.RibbonButton(); bt_AttPoff.Id = "AttPoff"; bt_AttPoff.Image = myUtilities.Media.Images.ToImageSource(global::CAS2018.Resources.AttPoff_small); bt_AttPoff.LargeImage = myUtilities.Media.Images.ToImageSource(global::CAS2018.Resources.AttPoff); bt_AttPoff.Orientation = System.Windows.Controls.Orientation.Horizontal; bt_AttPoff.Size = Autodesk.Windows.RibbonItemSize.Standard; bt_AttPoff.ShowText = false; bt_AttPoff.ShowImage = true; bt_AttPoff.CommandHandler = new RibbonCommandHandler(); bt_AttPoff.ShowToolTipOnDisabled = true; bt_AttPoff.Description = "PNr ausschalten"; //Att Hon Autodesk.Windows.RibbonButton bt_AttHon = new Autodesk.Windows.RibbonButton(); bt_AttHon.Id = "AttHon"; bt_AttHon.Image = myUtilities.Media.Images.ToImageSource(global::CAS2018.Resources.AttHon_small); bt_AttHon.LargeImage = myUtilities.Media.Images.ToImageSource(global::CAS2018.Resources.AttHon_small1); bt_AttHon.Orientation = System.Windows.Controls.Orientation.Horizontal; bt_AttHon.Size = Autodesk.Windows.RibbonItemSize.Standard; bt_AttHon.ShowText = false; bt_AttHon.ShowImage = true; bt_AttHon.CommandHandler = new RibbonCommandHandler(); bt_AttHon.ShowToolTipOnDisabled = true; bt_AttHon.Description = "Höhe einschalten"; //Att Hoff Autodesk.Windows.RibbonButton bt_AttHoff = new Autodesk.Windows.RibbonButton(); bt_AttHoff.Id = "AttHoff"; bt_AttHoff.Image = myUtilities.Media.Images.ToImageSource(global::CAS2018.Resources.AttHoff); bt_AttHoff.LargeImage = myUtilities.Media.Images.ToImageSource(global::CAS2018.Resources.AttHoff); bt_AttHoff.Orientation = System.Windows.Controls.Orientation.Horizontal; bt_AttHoff.Size = Autodesk.Windows.RibbonItemSize.Standard; bt_AttHoff.ShowText = false; bt_AttHoff.ShowImage = true; bt_AttHoff.CommandHandler = new RibbonCommandHandler(); bt_AttHoff.ShowToolTipOnDisabled = true; bt_AttHoff.Description = "Höhe ausschalten"; Autodesk.Windows.RibbonRowPanel rowPanel_Att = new Autodesk.Windows.RibbonRowPanel(); rowPanel_Att.Items.Add(bt_AttPon); rowPanel_Att.Items.Add(bt_AttPoff); rowPanel_Att.Items.Add(new RibbonRowBreak()); rowPanel_Att.Items.Add(bt_AttHon); rowPanel_Att.Items.Add(bt_AttHoff); panelSrcAtt.Items.Add(rowPanel_Att); //************** //PanelSource Zeichnen Autodesk.Windows.RibbonPanelSource panelSrcZeichnen = new Autodesk.Windows.RibbonPanelSource(); panelSrcZeichnen.Title = "Zeichnen"; //Settings Autodesk.Windows.RibbonButton bt_Block3P = new Autodesk.Windows.RibbonButton(); bt_Block3P.Id = "Block3P"; bt_Block3P.Text = "Einstellungen"; bt_Block3P.Image = myUtilities.Media.Images.ToImageSource(global::CAS2018.Resources.Block3P); bt_Block3P.LargeImage = myUtilities.Media.Images.ToImageSource(global::CAS2018.Resources.Block3P); bt_Block3P.Orientation = System.Windows.Controls.Orientation.Horizontal; bt_Block3P.Size = Autodesk.Windows.RibbonItemSize.Standard; bt_Block3P.ShowText = false; bt_Block3P.ShowImage = true; bt_Block3P.CommandHandler = new RibbonCommandHandler(); bt_Block3P.ShowToolTipOnDisabled = true; bt_Block3P.Description = "Block mit 3 Punkten einfügen"; panelSrcZeichnen.Items.Add(bt_Block3P); //************** //PanelSource Settings Autodesk.Windows.RibbonPanelSource panelSrcSettings = new Autodesk.Windows.RibbonPanelSource(); panelSrcSettings.Title = "Settings"; //Settings Autodesk.Windows.RibbonButton bt_Settings = new Autodesk.Windows.RibbonButton(); bt_Settings.Id = "Settings"; bt_Settings.Text = "Einstellungen"; bt_Settings.Image = myUtilities.Media.Images.ToImageSource(global::CAS2018.Resources.settings_16x16); bt_Settings.LargeImage = myUtilities.Media.Images.ToImageSource(global::CAS2018.Resources.Settings); bt_Settings.Orientation = System.Windows.Controls.Orientation.Horizontal; bt_Settings.Size = Autodesk.Windows.RibbonItemSize.Large; bt_Settings.ShowText = false; bt_Settings.ShowImage = true; bt_Settings.CommandHandler = new RibbonCommandHandler(); bt_Settings.ShowToolTipOnDisabled = true; bt_Settings.Description = "Einstellungen "; panelSrcSettings.Items.Add(bt_Settings); //************** //PanelSource Help Autodesk.Windows.RibbonPanelSource panelSrcHelp = new Autodesk.Windows.RibbonPanelSource(); panelSrcHelp.Title = "Hilfe"; //AboutBox Autodesk.Windows.RibbonButton bt_About = new Autodesk.Windows.RibbonButton(); bt_About.Id = "AboutBox"; bt_About.Text = "Info zu CAS2018"; bt_About.Image = myUtilities.Media.Images.ToImageSource(global::CAS2018.Resources.helpdoc); bt_About.LargeImage = myUtilities.Media.Images.ToImageSource(global::CAS2018.Resources.helpdoc); bt_About.Orientation = System.Windows.Controls.Orientation.Horizontal; bt_About.Size = Autodesk.Windows.RibbonItemSize.Large; bt_About.ShowText = false; bt_About.ShowImage = true; bt_About.CommandHandler = new RibbonCommandHandler(); bt_About.ShowToolTipOnDisabled = true; bt_About.Description = "Info über CAS2018"; panelSrcHelp.Items.Add(bt_About); // Row Panel Autodesk.Windows.RibbonRowPanel rowPanel1 = new Autodesk.Windows.RibbonRowPanel(); rowPanel1.Items.Add(bt_About); rowPanel1.Items.Add(bt_attPreSuf); //rowPanel.Items.Add( panelSubSrcAtt); rowPanel1.Items.Add(bt_Settings); rowPanel1.ResizeStyle = Autodesk.Windows.RibbonItemResizeStyles.ChangeSize; rowPanel1.Size = Autodesk.Windows.RibbonItemSize.Standard; // Create a panel for holding the panel // source content Autodesk.Windows.RibbonPanel panelCAS = new Autodesk.Windows.RibbonPanel(); panelCAS.Source = panelSrcIO; Autodesk.Windows.RibbonControl control = panelCAS.RibbonControl; //Tabs Autodesk.Windows.RibbonPanel panel_IO = new Autodesk.Windows.RibbonPanel(); panel_IO.Source = panelSrcIO; Autodesk.Windows.RibbonPanel panel_Tools = new Autodesk.Windows.RibbonPanel(); panel_Tools.Source = panelSrcTools; Autodesk.Windows.RibbonPanel panel_Att = new Autodesk.Windows.RibbonPanel(); panel_Att.Source = panelSrcAtt; Autodesk.Windows.RibbonPanel panel_Zeichnen = new RibbonPanel(); panel_Zeichnen.Source = panelSrcZeichnen; Autodesk.Windows.RibbonPanel panel_Settings = new Autodesk.Windows.RibbonPanel(); panel_Settings.Source = panelSrcSettings; Autodesk.Windows.RibbonPanel panel_Help = new Autodesk.Windows.RibbonPanel(); panel_Help.Source = panelSrcHelp; Autodesk.Windows.RibbonTab tabCAS2018 = new Autodesk.Windows.RibbonTab(); tabCAS2018.Title = "CAS2018"; tabCAS2018.Id = "CAS2018"; tabCAS2018.IsContextualTab = false; tabCAS2018.Panels.Add(panel_IO); tabCAS2018.Panels.Add(panel_Tools); tabCAS2018.Panels.Add(panel_Att); tabCAS2018.Panels.Add(panel_Zeichnen); tabCAS2018.Panels.Add(panel_Settings); tabCAS2018.Panels.Add(panel_Help); // Now add the tab to AutoCAD Ribbon bar... try { Autodesk.Windows.RibbonControl ribbonControl = RibbonServices.RibbonPaletteSet.RibbonControl; Autodesk.Windows.RibbonTab ribTab = new Autodesk.Windows.RibbonTab(); ribbonControl.Tabs.Add(tabCAS2018); } catch { } }
public void CreateRibbon() { AcadWindows.RibbonControl ribbon = AcadWindows.ComponentManager.Ribbon; AcadWindows.RibbonTab tab = new AcadWindows.RibbonTab(); tab.Name = "MyTab"; tab.Title = "My Tab"; tab.Id = "MyTabId"; ribbon.Tabs.Add(tab); AcadWindows.RibbonPanelSource panelSrc = new AcadWindows.RibbonPanelSource(); panelSrc.Name = "MyPanel"; panelSrc.Title = "My Panel"; panelSrc.Id = "MyPanelId"; AcadWindows.RibbonCheckBox cb = new Autodesk.Windows.RibbonCheckBox(); cb.Text = "Testing"; cb.IsChecked = true; cb.Size = AcadWindows.RibbonItemSize.Large; AcadWindows.RibbonButton button1 = new AcadWindows.RibbonButton(); button1.Name = "MyButton"; button1.Text = "My Button"; button1.Id = "MyButtonId"; AcadWindows.RibbonButton button2 = new AcadWindows.RibbonButton(); button2.Name = "MyOtherButton"; button2.Text = "My Other Button"; button2.Id = "MyOtherButtonId"; button2.Size = AcadWindows.RibbonItemSize.Large; button2.ShowText = true; button2.LargeImage = GetBitmap(new Bitmap(@"C:\Users\nguye\OneDrive\Desktop\Untitled.png"), 64, 64); button2.CommandHandler = new MyButtonCmd(); AcadWindows.RibbonButton button3 = new AcadWindows.RibbonButton(); button3.Name = "MyOtherButton"; button3.Text = "My Other Button"; button3.Id = "MyOtherButtonId"; button3.Size = AcadWindows.RibbonItemSize.Large; button3.ShowText = true; button3.Orientation = System.Windows.Controls.Orientation.Vertical; button3.LargeImage = GetBitmap(new Bitmap(@"C:\Users\nguye\OneDrive\Desktop\Untitled.png"), 64, 64); button3.CommandHandler = new MyButtonCmd(); panelSrc.Items.Add(button1); panelSrc.Items.Add(button2); panelSrc.Items.Add(button3); panelSrc.Items.Add(cb); AcadWindows.RibbonPanel panel = new AcadWindows.RibbonPanel(); panel.Source = panelSrc; panel.ResizeStyle = AcadWindows.RibbonResizeStyles.NeverChangeImageSize; tab.Panels.Add(panel); if (ps == null) { ps = new PaletteSet("My Palette 1", new Guid("229E43DB-E76F-48F9-849A-CC8D726DF257")); ps.SetLocation(new System.Drawing.Point(312, 763)); ps.SetSize(new System.Drawing.Size(909, 40)); /*For the first time we 'll enable on Bottom*/ ps.DockEnabled = DockSides.Right; UserControl user_control = new UserControl(); Button btn = new Button(); btn.Width = 100; btn.Height = 100; btn.Text = "abc"; user_control.Controls.Add(btn); ps.Add("1", user_control); } ps.Visible = true; /*Add Handler*/ ps.PaletteSetMoved += ps_PaletteSetMoved; }
public void PlaceButtonOnModifyRibbon() { try { String SystemTabId = "Modify"; String SystemPanelId = "modify_shr"; adWin.RibbonControl adWinRibbon = adWin.ComponentManager.Ribbon; adWin.RibbonTab adWinSysTab = null; adWin.RibbonPanel adWinSysPanel = null; adWin.RibbonTab adWinApiTab = null; adWin.RibbonPanel adWinApiPanel = null; adWin.RibbonItem adWinApiItem = null; foreach (adWin.RibbonTab ribbonTab in adWinRibbon.Tabs) { // Look for the specified system tab if (ribbonTab.Id == SystemTabId) { adWinSysTab = ribbonTab; foreach (adWin.RibbonPanel ribbonPanel in ribbonTab.Panels) { // Look for the specified panel // within the system tab if (ribbonPanel.Source.Id == SystemPanelId) { adWinSysPanel = ribbonPanel; } } } else { // Look for our API tab if (ribbonTab.Id == myTA.TabName) { adWinApiTab = ribbonTab; foreach (adWin.RibbonPanel ribbonPanel in ribbonTab.Panels) { if (ribbonPanel.Source.Id == "CustomCtrl_%" + myTA.TabName + "%" + myTA.PanelName) { foreach (adWin.RibbonItem ribbonItem in ribbonPanel.Source.Items) { if (ribbonItem.Id == "CustomCtrl_%CustomCtrl_%" + myTA.TabName + "%" + myTA.PanelName + "%" + myTA.Button_01) { adWinApiItem = ribbonItem; } } } if (ribbonPanel.Source.Id == "CustomCtrl_%" + myTA.TabName + "%" + myTA.PanelTransferring) { adWinApiPanel = ribbonPanel; } } } } } if (adWinSysTab != null && adWinSysPanel != null && adWinApiTab != null && adWinApiPanel != null && adWinApiItem != null) { adWinSysTab.Panels.Add(adWinApiPanel); adWinApiPanel.Source.Items.Add(adWinApiItem); adWinApiTab.Panels.Remove(adWinApiPanel); } } #region catch and finally catch (Exception ex) { TaskDialog.Show("me", ex.Message + Environment.NewLine + ex.InnerException); } finally { } #endregion }
public void OnIdling(object sender, IdlingEventArgs e) { int count = 0; ImageBrush picBrush = new ImageBrush(); picBrush.ImageSource = imgbg; picBrush.AlignmentX = AlignmentX.Center; picBrush.AlignmentY = AlignmentY.Center; picBrush.Stretch = Stretch.None; picBrush.TileMode = TileMode.None; adWin.RibbonControl ribbon = adWin.ComponentManager.Ribbon; if (stopwatch.ElapsedMilliseconds > 100) { if (modifier == 7) { count = 0; } else { count += modifier; } foreach (adWin.RibbonTab tab in ribbon.Tabs) { tab.Title = "Nyan Cat"; foreach (adWin.RibbonPanel panel in tab.Panels) { switch (count) { case 0: panel.CustomPanelBackground = new SolidColorBrush(Colors.Red); panel.CustomPanelTitleBarBackground = new SolidColorBrush(Colors.Red); break; case 1: panel.CustomPanelBackground = new SolidColorBrush(Colors.Orange); panel.CustomPanelTitleBarBackground = new SolidColorBrush(Colors.Orange); break; case 2: panel.CustomPanelBackground = new SolidColorBrush(Colors.Yellow); panel.CustomPanelTitleBarBackground = new SolidColorBrush(Colors.Yellow); panel.CustomPanelBackground = picBrush; break; case 3: panel.CustomPanelBackground = new SolidColorBrush(Colors.Green); panel.CustomPanelTitleBarBackground = new SolidColorBrush(Colors.Green); break; case 4: panel.CustomPanelBackground = new SolidColorBrush(Colors.Blue); panel.CustomPanelTitleBarBackground = new SolidColorBrush(Colors.Blue); break; case 5: panel.CustomPanelBackground = new SolidColorBrush(Colors.Indigo); panel.CustomPanelTitleBarBackground = new SolidColorBrush(Colors.Indigo); break; case 6: panel.CustomPanelBackground = new SolidColorBrush(Colors.Violet); panel.CustomPanelTitleBarBackground = new SolidColorBrush(Colors.Violet); break; } count += 1; if (count > 6) { count = 0; } } } if (modifier == 6) { modifier = 0; } else { modifier += 1; } } stopwatch.Reset(); stopwatch.Start(); }
public void RemoveTab() { Autodesk.Windows.RibbonControl newtab = Autodesk.Windows.ComponentManager.Ribbon; newtab.Tabs.Remove(AcacIOTab); }
void OnApplicationInitialized(object sender, Autodesk.Revit.DB.Events.ApplicationInitializedEventArgs e) { // Find a system ribbon tab and panel to house // our API items // Also find our API tab, panel and button within // the Autodesk.Windows.RibbonControl context adWin.RibbonControl adWinRibbon = adWin.ComponentManager.Ribbon; adWin.RibbonTab adWinSysTab = null; adWin.RibbonPanel adWinSysPanel = null; adWin.RibbonTab adWinApiTab = null; adWin.RibbonPanel adWinApiPanel = null; adWin.RibbonItem adWinApiItem = null; foreach (adWin.RibbonTab ribbonTab in adWinRibbon.Tabs) { // Look for the specified system tab if (ribbonTab.Id == SystemTabId) { adWinSysTab = ribbonTab; foreach (adWin.RibbonPanel ribbonPanel in ribbonTab.Panels) { // Look for the specified panel // within the system tab if (ribbonPanel.Source.Id == SystemPanelId) { adWinSysPanel = ribbonPanel; } } } else { // Look for our API tab if (ribbonTab.Id == ApiTabName) { adWinApiTab = ribbonTab; foreach (adWin.RibbonPanel ribbonPanel in ribbonTab.Panels) { // Look for our API panel. // The Source.Id property of an API created // ribbon panel has the following format: // CustomCtrl_%[TabName]%[PanelName] // Where PanelName correlates with the string // entered as the name of the panel at creation // The Source.AutomationName property can also // be used as it is also a direct correlation // of the panel name, but without all the cruft // Be sure to include any new line characters // (\n) used for the panel name at creation as // they still form part of the Id & AutomationName //if(ribbonPanel.Source.AutomationName // == ApiPanelName) // Alternative method if (ribbonPanel.Source.Id == "CustomCtrl_%" + ApiTabName + "%" + ApiPanelName) { adWinApiPanel = ribbonPanel; foreach (adWin.RibbonItem ribbonItem in ribbonPanel.Source.Items) { // Look for our command button // The Id property of an API created ribbon // item has the following format: // CustomCtrl_%CustomCtrl_%[TabName]%[PanelName]%[ItemName] // Where ItemName correlates with the string // entered as the first parameter (name) // of the PushButtonData() constructor // While AutomationName correlates with // the string entered as the second // parameter (text) of the PushButtonData() // constructor // Be sure to include any new line // characters (\n) used for the button // name and text at creation as they // still form part of the ItemName // & AutomationName //if(ribbonItem.AutomationName // == ApiButtonText) // alternative method if (ribbonItem.Id == "CustomCtrl_%CustomCtrl_%" + ApiTabName + "%" + ApiPanelName + "%" + ApiButtonName) { adWinApiItem = ribbonItem; } } } } } } } // Make sure we got everything we need if (adWinSysTab != null && adWinSysPanel != null && adWinApiTab != null && adWinApiPanel != null && adWinApiItem != null) { // First we'll add the whole panel including // the button to the system tab adWinSysTab.Panels.Add(adWinApiPanel); // now lets also add the button itself // to a system panel adWinSysPanel.Source.Items.Add(adWinApiItem); // Remove panel from original API tab // It can also be left there if needed, // there doesn't seem to be any problems with // duplicate panels / buttons on seperate tabs // / panels respectively adWinApiTab.Panels.Remove(adWinApiPanel); // Remove our original API tab from the ribbon adWinRibbon.Tabs.Remove(adWinApiTab); } // A new panel should now be added to the // specified system tab. Its command buttons // will behave as they normally would, including // API access and ExternalCommandAvailability tests. // There will also be a second copy of the command // button from the panel added to the specified // system panel. }
//convert revit ribbon to adwin for extra control over graphics //set buttons to no text public static void setButtonNoText() { Debug.Print("test"); adwin.RibbonControl ribbon = adwin.ComponentManager.Ribbon; adwin.RibbonTab my_tab = null; adwin.RibbonPanel my_panel = null; adwin.RibbonButton my_buttonStop = null; adwin.RibbonButton my_buttonPlay = null; ribbon.FontSize = 6; //needs a total restart to apply ribbon.FontFamily = new FontFamily("Impact"); //needs a total restart to apply ribbon.FontWeight = System.Windows.FontWeights.DemiBold; ribbon.Foreground = Brushes.Gray; //doesn't do anything Autodesk.Internal.Windows.TabTheme myTheme = new Autodesk.Internal.Windows.TabTheme(); myTheme.PanelBackground = Brushes.White; //this sits behind and is hidden by our tabs myTheme.PanelTitleForeground = Brushes.White; //this is the tab text colour //myTheme.PanelTitleBackground = Brushes.White; //myTheme.TabHeaderBackground = Brushes.LimeGreen; myTheme.TabHeaderForeground = Brushes.White; myTheme.PanelBorder = Brushes.Black; //doesn't do anything myTheme.PanelSeparatorBrush = Brushes.HotPink; //doesn't do anything myTheme.InnerBorder = Brushes.Black; //tab border myTheme.OuterBorder = Brushes.Red; //doesn't do anything myTheme.PanelSeparatorBrush = Brushes.Black; //doesn't do anything //myTheme.RolloverTabHeaderBackground = Brushes.HotPink; foreach (var tab in ribbon.Tabs) { Debug.Print(tab.Id); if (tab.Id == "BrickDims") { my_tab = tab; my_tab.Theme = myTheme; break; } } if (my_tab == null) { return; } foreach (var panel in my_tab.Panels) { Debug.Print(panel.Source.Id); if (panel.Source.Id == "CustomCtrl_%BrickDims%Brick Dims") { my_panel = panel; my_panel.CustomPanelTitleBarBackground = Brushes.Black; //this is the tab colour at the bottom when it's activated my_panel.CustomPanelBackground = Brushes.White; break; } } if (my_panel == null) { return; } foreach (var item in my_panel.Source.Items) { Debug.Print(item.Id); // The Id property of an API created ribbon // item has the following format: // CustomCtrl_%CustomCtrl_%[TabName]%[PanelName]%[ItemName] if (item.Id.Contains("Stop")) { Debug.Print("stop"); my_buttonStop = item as adwin.RibbonButton; //my_buttonStop.ShowText = false; } if (item.Id.Contains("Play")) { Debug.Print("play"); my_buttonPlay = item as adwin.RibbonButton; my_buttonPlay.Orientation = System.Windows.Controls.Orientation.Vertical; //my_buttonPlay.ShowText = false; break; } } if (my_buttonStop == null) { return; } if (my_buttonPlay == null) { return; } //string filepath = Path.Combine(@"K:\", "ArkUser", "basis.ico"); //my_button.LargeImage = new System.Windows.Media.Imaging.BitmapImage(new Uri(filepath, UriKind.Absolute)); }
public adWin.RibbonItem AdwinButton(string tabName, string panelName, string btnName, bool isSystemTab = false) { adWin.RibbonControl adWinRibbon = adWin.ComponentManager.Ribbon; adWin.RibbonTab adWinSysTab = null; adWin.RibbonPanel adWinSysPanel = null; adWin.RibbonTab adWinApiTab = null; adWin.RibbonPanel adWinApiPanel = null; adWin.RibbonItem adWinApiItem = null; //If input tab is system tab if (isSystemTab) { foreach (adWin.RibbonTab ribbonTab in adWinRibbon.Tabs) { if (ribbonTab.Id != tabName) { continue; } adWinSysTab = ribbonTab; break; } if (adWinSysTab != null) { foreach (adWin.RibbonPanel ribbonPanel in adWinApiTab.Panels) { if (ribbonPanel.Source.Id != tabName) { continue; } adWinSysPanel = ribbonPanel; break;; } } return(null); } //If input tab is not a system tab foreach (adWin.RibbonTab ribbonTab in adWinRibbon.Tabs) { if (!ribbonTab.Title.Equals(tabName)) { continue; } adWinApiTab = ribbonTab; adWinApiTab.IsVisible = false; break; } // Problem: Autodesk.Windows.RibbonTab.Panels = {0} ??? // I don't understand here if (adWinApiTab != null) { foreach (adWin.RibbonPanel ribbonPanel in adWinApiTab.Panels) { // Look for our API panel. // The ConvertToPushButton.Id property of an API created // ribbon panel has the following format: // CustomCtrl_%[TabName]%[PanelName] if (ribbonPanel.Source.Id != "CustomCtrl_%" + tabName + "%" + panelName) { continue; } adWinApiPanel = ribbonPanel; break;; } } if (adWinApiPanel != null) { foreach (adWin.RibbonItem ribbonItem in adWinApiPanel.Source.Items) { // Look for our command button // The Id property of an API created ribbon // item has the following format: // CustomCtrl_%CustomCtrl_%[TabName]%[PanelName]%[ItemName] //if(ribbonItem.AutomationName // == ApiButtonText) // alternative method if (ribbonItem.Id != "CustomCtrl_%CustomCtrl_%" + tabName + "%" + panelName + "%" + btnName) { continue; } adWinApiItem = ribbonItem; break; } } if (adWinApiItem != null) { adWinApiItem.ToolTip = "This button is found by api."; TaskDialog.Show("Existing Button", $"Button {btnName} founded"); // Do something return(adWinApiItem); } TaskDialog.Show("Existing Button", $"Button {btnName} is not founded"); return(null); }
private static RibbonPanel GetRibbonPanel(UIControlledApplication revApp, string tabName, string panelName) { try { // Verify if the tab exists, create it if ncessary adWin.RibbonControl ribbon = adWin.ComponentManager.Ribbon; adWin.RibbonTab tab = null; bool defaultTab = false; foreach (adWin.RibbonTab t in ribbon.Tabs) { if (t.Id == tabName) { if (t.Id != t.Name) { defaultTab = true; } tab = t; break; } } if (!defaultTab && tab == null) { revApp.CreateRibbonTab(tabName); } if (defaultTab) { tab = null; } // Verify if the panel exists List <RibbonPanel> panels; if (defaultTab) { panels = revApp.GetRibbonPanels(); } else { panels = revApp.GetRibbonPanels(tabName); } RibbonPanel panel = null; foreach (RibbonPanel rp in panels) { if (rp.Name == panelName) { panel = rp; break; } } if (panel == null && !defaultTab) { panel = revApp.CreateRibbonPanel(tabName, panelName); } else if (panel == null && defaultTab) { panel = revApp.CreateRibbonPanel(panelName); } return(panel); } catch { return(null); } }
//添加面板选项卡 public static void MyRibbon() { if (UI.Global.isOpen == false) { Autodesk.AutoCAD.ApplicationServices.Application.ShowAlertDialog("请先打开一个工程!"); return; } Autodesk.Windows.RibbonControl ribbonControl = Autodesk.Windows.ComponentManager.Ribbon; RibbonTab Tab = new RibbonTab(); //for (int i = 0; i < ribbonControl.Tabs.Count; i++) //{ // if(ribbonControl.Tabs[i].Id == "RibbonSample_TAB_ID") // { // isOpen = true; // } //} if (isOpen == false) { ribbonControl.Tabs.Add(Tab); Tab.Title = " 煤矿工程 "; Tab.Id = "RibbonSample_TAB_ID"; Autodesk.Windows.RibbonPanelSource panel1Panel = new RibbonPanelSource(); panel1Panel.Title = "手工绘制"; RibbonPanel Panel1 = new RibbonPanel(); Panel1.Source = panel1Panel; Tab.Panels.Add(Panel1); RibbonButton pan1button1 = new RibbonButton(); pan1button1.Text = "绘制方形"; pan1button1.ShowText = true; //pan1button1.ShowImage = true; //pan1button1.Image = Images.getBitmap(Forms.Resources.Small); //pan1button1.LargeImage = Images.getBitmap(Forms.Resources.large); pan1button1.Orientation = System.Windows.Controls.Orientation.Vertical; pan1button1.Size = RibbonItemSize.Standard; pan1button1.CommandHandler = new RibbonCommandHandler(); pan1button1.CommandParameter = "SqTunnel "; panel1Panel.Items.Add(pan1button1); RibbonButton pan1button2 = new RibbonButton(); pan1button2.Text = "绘制圆形"; pan1button2.ShowText = true; //pan1button2.ShowImage = true; //pan1button2.Image = Images.getBitmap(Forms.Resources.Small); //pan1button2.LargeImage = Images.getBitmap(Forms.Resources.large); pan1button2.Orientation = System.Windows.Controls.Orientation.Vertical; pan1button2.Size = RibbonItemSize.Standard; pan1button2.CommandHandler = new RibbonCommandHandler(); pan1button2.CommandParameter = "CylTunnel "; panel1Panel.Items.Add(pan1button2); RibbonButton pan1button3 = new RibbonButton(); pan1button3.Text = "绘制梯形"; pan1button3.ShowText = true; //pan1button3.ShowImage = true; //pan1button3.Image = Images.getBitmap(Forms.Resources.Small); //pan1button3.LargeImage = Images.getBitmap(Forms.Resources.large); pan1button3.Orientation = System.Windows.Controls.Orientation.Vertical; pan1button3.Size = RibbonItemSize.Standard; pan1button3.CommandHandler = new RibbonCommandHandler(); pan1button3.CommandParameter = "TrTunnel "; panel1Panel.Items.Add(pan1button3); RibbonPanelSource panel2Panel = new RibbonPanelSource(); panel2Panel.Title = "视图窗口"; RibbonPanel panel2 = new RibbonPanel(); panel2.Source = panel2Panel; Tab.Panels.Add(panel2); RibbonButton pan2button1 = new RibbonButton(); pan2button1.Text = "菜单列表"; pan2button1.ShowText = true; //pan2button1.ShowImage = true; //pan2button1.Image = Images.getBitmap(Forms.Resources.Small); //pan2button1.LargeImage = Images.getBitmap(Forms.Resources.large); pan2button1.Size = RibbonItemSize.Standard; pan2button1.Orientation = System.Windows.Controls.Orientation.Vertical; pan2button1.CommandHandler = new RibbonCommandHandler(); pan2button1.CommandParameter = "openTreeControl "; panel2Panel.Items.Add(pan2button1); RibbonButton pan3button1 = new RibbonButton(); pan3button1.Text = "坐标列表"; pan3button1.ShowText = true; //pan3button1.ShowImage = true; //pan3button1.Image = Images.getBitmap(Forms.Resources.Small); //pan3button1.LargeImage = Images.getBitmap(Forms.Resources.large); pan3button1.Size = RibbonItemSize.Standard; pan3button1.Orientation = System.Windows.Controls.Orientation.Vertical; pan3button1.CommandHandler = new RibbonCommandHandler(); pan3button1.CommandParameter = "openGridControl "; panel2Panel.Items.Add(pan3button1); RibbonPanelSource panel4Panel = new RibbonPanelSource(); panel4Panel.Title = "显示模式"; RibbonPanel panel4 = new RibbonPanel(); panel4.Source = panel4Panel; Tab.Panels.Add(panel4); RibbonButton pan4button1 = new RibbonButton(); pan4button1.Text = "切换模式"; pan4button1.ShowText = true; //pan4button1.ShowImage = true; //pan4button1.Image = Images.getBitmap(Forms.Resources.Small); //pan4button1.LargeImage = Images.getBitmap(Forms.Resources.large); pan4button1.Size = RibbonItemSize.Standard; pan4button1.Orientation = System.Windows.Controls.Orientation.Vertical; pan4button1.CommandHandler = new RibbonCommandHandler(); pan4button1.CommandParameter = "DisplayMode "; panel4Panel.Items.Add(pan4button1); RibbonButton pan5button1 = new RibbonButton(); pan5button1.Text = "演示动画"; pan5button1.ShowText = true; //pan5button1.ShowImage = true; //pan5button1.Image = Images.getBitmap(Forms.Resources.Small); //pan5button1.LargeImage = Images.getBitmap(Forms.Resources.large); pan5button1.Size = RibbonItemSize.Standard; pan5button1.Orientation = System.Windows.Controls.Orientation.Vertical; pan5button1.CommandHandler = new RibbonCommandHandler(); pan5button1.CommandParameter = "animate "; panel4Panel.Items.Add(pan5button1); RibbonButton pan6button1 = new RibbonButton(); pan6button1.Text = "特性面板"; pan6button1.ShowText = true; //pan6button1.ShowImage = true; //pan6button1.Image = Images.getBitmap(Forms.Resources.Small); //pan6button1.LargeImage = Images.getBitmap(Forms.Resources.large); pan6button1.Size = RibbonItemSize.Standard; pan6button1.Orientation = System.Windows.Controls.Orientation.Vertical; pan6button1.CommandHandler = new RibbonCommandHandler(); pan6button1.CommandParameter = "openPropertyControl "; panel2Panel.Items.Add(pan6button1); RibbonPanelSource panel7Panel = new RibbonPanelSource(); panel7Panel.Title = "数据传输"; RibbonPanel panel7 = new RibbonPanel(); panel7.Source = panel7Panel; Tab.Panels.Add(panel7); RibbonButton pan7button1 = new RibbonButton(); pan7button1.Text = "导出信息"; pan7button1.ShowText = true; //pan7button1.ShowImage = true; //pan7button1.Image = Images.getBitmap(Forms.Resources.Small); //pan7button1.LargeImage = Images.getBitmap(Forms.Resources.large); pan7button1.Size = RibbonItemSize.Standard; pan7button1.Orientation = System.Windows.Controls.Orientation.Vertical; pan7button1.CommandHandler = new RibbonCommandHandler(); pan7button1.CommandParameter = "OutGeoData "; panel7Panel.Items.Add(pan7button1); Tab.IsActive = true; } }