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

Button image background in ribbons and toolbars

9 REPLIES 9
Reply
Message 1 of 10
cnicholas
1668 Views, 9 Replies

Button image background in ribbons and toolbars

Hello,

I trying to find the correct way to have the image backgrounds not stand out when they are used in the ribbon or tool bar.

For example, in AutoCAD's Insert ribbon the button's Attach and Auto Update the ribbon and button image background colours appear to be the sameatach.jpg and when the mouse pointer is hovered over them, the background remains the same atach2.jpg

 

I've defined some images, some with a grey background and some with a white background. The next three images show them in use in buttons in the ribbon. The grey background can be seen but not the white. However the white appears when the mouse is hovered over it.

atach3.jpgatach4.jpgatach5.jpg

 

When used in a tool bar atach6.jpg the grey background is not visible but the white is.

 

What do I need to do to define images so that I get the background behaving as it does for the AutoCAD Attach button and also not have backgrounds visible in toolbars?

 

Cheers

Craig

 

9 REPLIES 9
Message 2 of 10
_gile
in reply to: cnicholas

Hi,

 

Did you try .png or .ico files with a transparent background ?



Gilles Chanteau
Programmation AutoCAD LISP/.NET
GileCAD
GitHub

Message 3 of 10
Keith.Brown
in reply to: _gile

This is the colour that you need for transparent pixels in the ribbon.

 

 R=192, G=192, B=192

 

I got that value from Kean's blog located here.

Message 4 of 10
cnicholas
in reply to: Keith.Brown

Hi

Thanks for your replies. I haven't tried ICO or PNG yet because I have a large number of bitmaps that I hope to be able to use for both tool bars and ribbon buttons.

The 192,192,192 background in the bitmap works through CUI. I changed the White BG image to use the new background and this is how it appears in the tool bar atach7.jpg, ribbon buton atach8.jpg and when mouse hovered over ribbon button atach9.jpg .

All the bmp files are in my project's resource file. When I try to programatically build the ribbon the result is not as expected i.e. the background is visible e.g. atach10.jpg

 

Here's an extract of the code

   // ...
   Bitmap img16 = new Bitmap;
   img16 = Resources.MyImage16;
   // ...
   RibbonButton rb = new RibbonButton();
   rb.Image = GetBitmap(img16);
   // ...
}

private BitmapImage GetBitmap(Bitmap image)
{
    MemoryStream stream = new MemoryStream();
    image.Save(stream,ImageFormat.Png);
    BitmapImage bmp = new BitmapImage();
    bmp.BeginInit();
    bmp.StreamSource = stream;
    bmp.EndInit();
    return bmp;
}

 

What do you think?

 

Craig

 

Message 5 of 10
cnicholas
in reply to: cnicholas

I've created a corresponding set of icons with transparent backgrounds and I am now using them as the images for the ribbon buttons. The backgrounds are no longer visible.

It would be nice to understand why the bitmap route is not working.

 

Craig

Message 6 of 10
Balaji_Ram
in reply to: cnicholas

Hello Craig,

 

I haven't tried your code but I think the bitmap does not have its transparent color set.

So, can you please try this ?

 

bmp.MakeTransparent(System.Drawing.Color.FromArgb(192, 192, 192));

 

Regards,

Balaji



Balaji
Developer Technical Services
Autodesk Developer Network

Message 7 of 10
cnicholas
in reply to: Balaji_Ram

Hi Balaji,

The result of calling MakeTransparent made the background appear black.

 

Regards

Craig

Message 8 of 10
Balaji_Ram
in reply to: cnicholas

Hello Craig,

 

Sorry for the delay. I got involved in another task that came up.

 

I have attached a sample code that works ok. The image appeared transparent in a ribbon button.

 

Regards,

Balaji



Balaji
Developer Technical Services
Autodesk Developer Network

Message 9 of 10
TiStars
in reply to: Balaji_Ram

Hi Balaji,

I tried your sample code, Ribbons work very well, and imges of them are shown good.

But my commands can't be recognized , I just put your code before my Class. looks like:

...

your sample code

namespace PipelineBuilding
{
public class ProfileOperation
{
[CommandMethod("AddCurve")]
public void AddCurve()
{
...

天ę¶Æ굷角ēš„山姆


ę‚Ø认äøŗę­¤åø–子ę˜Æå¦ęœ‰ē”Øļ¼Ÿę¬¢čæŽäøŗę­¤åø–ē‚¹čµžć€‚

ę‚Øēš„问题ę˜Æå¦å·²å¾—åˆ°č§£ē­”ļ¼ŸčÆ·ē‚¹å‡»ā€œęŽ„å—č§£ē­”ā€ęŒ‰é’®ć€‚


EESignature



Message 10 of 10
Virupaksha_aithal
in reply to: TiStars

Hi,

 

Tough to suggest what is happening at your end from the information provided. Can you provide non-confidential simple sample which demonstrates the behavior?



Virupaksha Aithal KM
Developer Technical Services
Autodesk Developer Network

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