Advertisement
ArthurGanem

Revit API PushButton Icon

Apr 7th, 2025 (edited)
300
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.89 KB | None | 0 0
  1. /*************************************************/
  2.  
  3. /* .ico image embedded into .RESX file   * START */
  4.  
  5.             PushButton pButton = rPanel.AddItem(buttonData) as PushButton;
  6.  
  7.             Icon icon = Properties.Resources.AG_Asset_Protector_Icon;
  8.             MemoryStream ms = new MemoryStream();
  9.             icon.Save(ms);
  10.             ms.Position = 0;
  11.             BitmapImage bLargeImage = new BitmapImage();
  12.             bLargeImage.BeginInit();
  13.             bLargeImage.StreamSource = ms;
  14.             bLargeImage.EndInit();
  15.             pButton.LargeImage = bLargeImage;
  16.             ms.Dispose();
  17.  
  18. /* .ico image embedded into .RESX file     * END */
  19.  
  20. /*************************************************/
  21.  
  22. /* .ico image embedded as file by itself * START */
  23.  
  24.             PushButton pButton = rPanel.AddItem(buttonData) as PushButton;
  25.  
  26.             BitmapImage bLargeImage = new BitmapImage();
  27.             bLargeImage.BeginInit();
  28.             bLargeImage.UriSource = new Uri("pack://application:,,,/AG_View_Bookmarks;component/Images/bookmark-ui-32.ico");
  29.             bLargeImage.EndInit();
  30.             pButton.LargeImage = bLargeImage;
  31.  
  32.             // bLargeImage.UriSource = new Uri("pack://application:,,,/AG_View_Bookmarks;component/Images/bookmark-ui-32.png");
  33.             // ^-- Interestingly enough this below crops the image although it also is 32x32 like the ico...   
  34.  
  35. /* .ico image embedded as file by itself   * END */
  36.  
  37. /*************************************************/
  38.  
  39. /* .ico image called from a directory    * START */
  40.  
  41.             PushButton pButton = rPanel.AddItem(buttonData) as PushButton;
  42.  
  43.             Uri uriImage = new Uri(@"c:\AG_Tools\AG_ButtonOpenSheets_P.ico");
  44.             BitmapImage bLargeImage = new BitmapImage(uriImage);
  45.             pButton.LargeImage = bLargeImage;
  46.  
  47. /* .ico image called from a directory      * END */
  48.  
  49. /*************************************************/
  50.  
  51.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement