• Industries
  • Products
  • Buy
  • Services & Support
  • Communities
  • Discussion Groups

    .NET

    Reply
    Contributor
    jamkhp
    Posts: 24
    Registered: ‎05-19-2011

    Not able to display my .png files in the ribbon

    140 Views, 2 Replies
    12-23-2012 07:30 PM

    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.

     

    Please use plain text.
    ADN Support Specialist
    Balaji_Ram
    Posts: 359
    Registered: ‎03-21-2011

    Re: Not able to display my .png files in the ribbon

    01-01-2013 10:06 PM 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

    Please use plain text.
    Contributor
    Posts: 21
    Registered: ‎08-20-2008

    Re: Not able to display my .png files in the ribbon

    01-02-2013 05:39 PM 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

     

    Please use plain text.