Hi everyone!
How do i create a ribbon tab and button for my application, can anyone give a sample code?
How do i interact the button click with my application?
Thanks.
raghulan: I have not experimented with button colors myself but my guess there should be some posibility to do it. Just not sure to what extent is possible with it. As a fall back you could just make images of different colors and drop them in instead.
Are you trying to create a drop down window for a color selection?
just in case you haven't seen this post http://adndevblog.typepad.com/autocad/2012/06/autocad-performance-gauges-app.html
Thanks guys, I would play around and update back when I find a good solution.
you could just add some colorful bitmaps into your application resources and then just covert them something like this:
Shared Function AddOnePanel() As RibbonPanel
Dim rb As RibbonButton
Dim rps As New RibbonPanelSource()
rps.Title = "ToDazeReality"
Dim rp As New RibbonPanel()
rp.Source = rps
Dim rci As New RibbonButton()
rci.Name = "cmdDoSomething"
rps.DialogLauncher = rci
rb = New RibbonButton()
rb.CommandParameter = "doSomething "
rb.Name = "btnDoSomething"
rb.CommandHandler = New tdrCommandHandler()
rb.Image = thumbConvert(BlaBlaBla.My.Resources.Resources.SomeBitMapImage)
rps.Items.Add(rb)
Return rp
End Function
Public Function thumbConvert(value As System.Drawing.Bitmap) As Object
If value Is Nothing Then
Return Nothing
End If
Dim myImageCodecInfo As Drawing.Imaging.ImageCodecInfo
myImageCodecInfo = GetEncoderInfo(Drawing.Imaging.ImageFormat.Png)
Dim myEncoder As Drawing.Imaging.Encoder
myEncoder = Drawing.Imaging.Encoder.Quality
Dim myEncoderParameter As Drawing.Imaging.EncoderParameter
Dim myEncoderParameters As Drawing.Imaging.EncoderParameters
myEncoderParameters = New Drawing.Imaging.EncoderParameters(1)
myEncoderParameter = New Drawing.Imaging.EncoderParameter(myEncoder, CType(75L, Int32))
myEncoderParameters.Param(0) = myEncoderParameter
Dim image = CType(value, System.Drawing.Image)
Dim bitmap = New System.Windows.Media.Imaging.BitmapImage()
bitmap.BeginInit()
Dim memoryStream As New IO.MemoryStream()
image.Save(memoryStream, myImageCodecInfo, myEncoderParameters)
memoryStream.Seek(0, System.IO.SeekOrigin.Begin)
bitmap.StreamSource = memoryStream
bitmap.EndInit()
Return bitmap
End Function
Private Function GetEncoderInfo(ByVal format As Drawing.Imaging.ImageFormat) As Drawing.Imaging.ImageCodecInfo
Dim j As Integer
Dim encoders() As Drawing.Imaging.ImageCodecInfo
encoders = Drawing.Imaging.ImageCodecInfo.GetImageEncoders()
j = 0
While j < encoders.Length
If encoders(j).FormatID = format.Guid Then
Return encoders(j)
End If
j += 1
End While
Return Nothing
End Function
Your mileage my vary doing it this way...
Thanks Mate, for the information.
This is a very old topic, but I did not see in it the full solution for VB.NET
So I add full sample project used @Irvin code. Rename VBRibbonSample.gzip to VBRibbonSample.zip
Відповідь корисна? Клікніть на "ВПОДОБАЙКУ" цім повідомленням! | Do you find the posts helpful? "LIKE" these posts!
Находите сообщения полезными? Поставьте "НРАВИТСЯ" этим сообщениям!
На ваше запитання відповіли? Натисніть кнопку "ПРИЙНЯТИ РІШЕННЯ" | Have your question been answered successfully? Click "ACCEPT SOLUTION" button.
На ваш вопрос успешно ответили? Нажмите кнопку "УТВЕРДИТЬ РЕШЕНИЕ"
Alexander Rivilis / Александр Ривилис / Олександр Рівіліс
Programmer & Teacher & Helper / Программист - Учитель - Помощник / Програміст - вчитель - помічник
Facebook | Twitter | LinkedIn