Im not 100% sure exactly whats going on with it. The code is copied from others that I've gotten but here is a bigger snip it, minus the main ribbon button area. Though here is majority of the code dealing with the ribbon bar itself.
Imports System.Drawing
Imports System.Drawing.Imaging
Imports System.IO
Imports System.Runtime.InteropServices
Imports System.Windows.Media.Imaging
Imports Autodesk.AutoCAD.EditorInput
Imports Autodesk.Windows
Imports Autodesk.AutoCAD.DatabaseServices
Imports Autodesk.AutoCAD.ApplicationServices
Imports cadApp = Autodesk.AutoCAD.ApplicationServices.Application
Imports cadAppSrvs = Autodesk.AutoCAD.ApplicationServices
Public Class BottleConveyorRibbon
Public Shared BlockName As String
Public Sub TrapWSCurrentChange(ByVal sender As Object, _
ByVal e As cadAppSrvs.SystemVariableChangedEventArgs)
If e.Name.Equals("WSCURRENT") Then createRibbon()
End Sub
'Creates the Ribbon Tabs
Public Sub createRibbon()
Dim ribCntrl As Autodesk.Windows.RibbonControl = Autodesk.Windows.ComponentManager.Ribbon
If ComponentManager.Ribbon Is Nothing Then
Return
End If
For i As Integer = 0 To ribCntrl.Tabs.Count - 1
If ribCntrl.Tabs(i).Id.Equals("My_Rib_ID") Then
Return
End If
Next
'Creates a tab
Dim mbc1Tab As New RibbonTab()
mbc1Tab.Title = "Bottle Conveyor Mattop 1-10"
mbc1Tab.Id = "Bottle_Conveyor_Mattop_1_10"
ribCntrl.Tabs.Add(mbc1Tab)
Dim mbc2Tab As New RibbonTab()
mbc2Tab.Title = "Bottle Conveyor Mattop 12-20"
mbc2Tab.Id = "Bottle_Conveyor_Mattop_12_20"
ribCntrl.Tabs.Add(mbc2Tab)
Dim bcmiscTab As New RibbonTab()
bcmiscTab.Title = "Bottle Conveyor Misc"
bcmiscTab.Id = "Bottle_Conveyor_Misc"
ribCntrl.Tabs.Add(bcmiscTab)
'Create and add the panels
'Bottle Conveyor Mattop 1-10
addmbc1c(mbc1Tab)
addmbc2c(mbc1Tab)
addmbc3c(mbc1Tab)
addmbc4c(mbc1Tab)
addmbc5c(mbc1Tab)
addmbc6c(mbc1Tab)
addmbc7c(mbc1Tab)
addmbc8c(mbc1Tab)
addmbc10c(mbc1Tab)
'Bottle Conveyor Mattop 12-20
addmbc12c(mbc2Tab)
addmbc14c(mbc2Tab)
addmbc16c(mbc2Tab)
addmbc18c(mbc2Tab)
addmbc20c(mbc2Tab)
'Bottle Conveyor Misc
addmbcFM(bcmiscTab)
addmbcclean(bcmiscTab)
addmbcAccum(bcmiscTab)
addssbcAccum(bcmiscTab)
addmbcWF(bcmiscTab)
'set as active tab
mbc1Tab.IsActive = True
End Sub
Private Sub removeRibbon()
Dim ribCntrl As Autodesk.Windows.RibbonControl = Autodesk.Windows.ComponentManager.Ribbon
'find the custom tab using the Id
For i As Integer = 0 To ribCntrl.Tabs.Count - 1
If ribCntrl.Tabs(i).Id.Equals("Mattop_Bottle_Conveyor") Then
ribCntrl.Tabs.Remove(ribCntrl.Tabs(i))
Return
End If
Next
End Sub
''' Bunch of Ribbon Bar Buttons :)
'Imaging Information
Public Function getBitmap(ByVal image As Bitmap) As BitmapImage
Dim stream As New MemoryStream()
image.Save(stream, ImageFormat.Png)
Dim bmp As New BitmapImage()
bmp.BeginInit()
bmp.StreamSource = stream
bmp.EndInit()
Return bmp
End Function
End Class
Public Class AdskCommandHandler
Implements System.Windows.Input.ICommand
Public Function CanExecute(ByVal parameter As Object) _
As Boolean Implements System.Windows.Input.ICommand.CanExecute
Return True
End Function
Public Event CanExecuteChanged(ByVal sender As Object, ByVal e As System.EventArgs) _
Implements System.Windows.Input.ICommand.CanExecuteChanged
Public Sub Execute(ByVal parameter As Object) _
Implements System.Windows.Input.ICommand.Execute
Dim ribBtn As RibbonButton = TryCast(parameter, RibbonButton)
If ribBtn IsNot Nothing Then
BottleConveyorRibbon.BlockName = ribBtn.Text
cadApp.DocumentManager.MdiActiveDocument.SendStringToExecute( _
ribBtn.CommandParameter, True, False, True)
End If
End Sub
End Class
Another Piece of the code that deals with the trap function.
Imports Autodesk.AutoCAD.Runtime
Imports cadApp = Autodesk.AutoCAD.ApplicationServices.Application
<Assembly: ExtensionApplication(GetType(BottleConveyorRibbonApp.IntialEnd))>
Namespace BottleConveyorRibbonApp
Public Class IntialEnd
Implements IExtensionApplication
Public Sub Initialize() Implements IExtensionApplication.Initialize
Dim cnvrRib As New BottleConveyorRibbon
cnvrRib.createRibbon()
AddHandler cadApp.SystemVariableChanged, AddressOf cnvrRib.TrapWSCurrentChange
End Sub
Public Sub Terminate() Implements IExtensionApplication.Terminate
End Sub
End Class
End Namespace