.NET
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Not able to display my .png files in the ribbon

2 REPLIES 2
Reply
Message 1 of 3
jamkhp
519 Views, 2 Replies

Not able to display my .png files in the ribbon

Hello all,

Good day,  Merry Christmas and a Happy new year to all,

I am trying to create a ribbon of my own, and the code and execution is fine, but I am not able to put the images.

my images are not more than 1 kb in size and are stored in the resources.resources1.... how do I get them to display.
Please help.

I am trying to work with the available code found in one of the training sessions,

'Code starts

'on one of my subs I am calling this function 

'ribBtn.LargeImage = LoadImage("FR.png")

Private Shared Function LoadImage(ByRef ImageName As String) As Imaging.BitmapImage

Dim bi As New System.Windows.Media.Imaging.BitmapImage()

bi.BeginInit()
bi.StreamSource = GetEmbeddedResourceStream("MyRibbon_Autocad." & ImageName)
bi.EndInit() ' When i debug the code, the code is exiting at this point, i am assuming it is not getting initialised.
Return bi
End Function

Protected Shared Function GetEmbeddedResourceStream(ByVal ResourceName As String) As Stream
Return System.Reflection.Assembly.GetExecutingAssembly().GetManifestResourceStream(ResourceName)
End Function

 

I dont see any error, but the ribbon is getting generated but withut any images, just a plane ribbon.

 

2 REPLIES 2
Message 2 of 3
Balaji_Ram
in reply to: jamkhp

Hello,

 

Wish you a very happy new year.

 

Have you set the "ribBtn.Size = RibbonItemSize.Large" ?

This will ensure that AutoCAD uses the large image.

 

Here is a blog post with a sample code that might help :

http://adndevblog.typepad.com/autocad/2012/05/arrange-ribbon-buttons-into-columns.html



Balaji
Developer Technical Services
Autodesk Developer Network

Message 3 of 3
autodeskprogrammer
in reply to: jamkhp

Hi

Thank you and to you

using System.Windows.Media.Imaging;
using Autodesk.Windows;
.
.
.

RibbonButton rConductorbutton = new RibbonButton();
            rConductorbutton.Text = "OOO";
            rConductorbutton.Id = "btnConductor";
            rConductorbutton.Orientation = System.Windows.Controls.Orientation.Vertical;
            rConductorbutton.Size = RibbonItemSize.Standard;
            rConductorbutton.Image = new BitmapImage(new Uri(... + @"\Icon\Conductor32.png", UriKind.RelativeOrAbsolute));
            rConductorbutton.ShowText = true;
            rConductorbutton.ShowImage = true;
            rConductorbutton.Click += new System.Windows.RoutedEventHandler(btnCounductor_Click);

 

 

it can be one of the ways that you can use to show png file but it's C# if couldn't change it to VB let me know to change it for you

 

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk DevCon in Munich May 28-29th


Autodesk Design & Make Report

”Boost