ArthurGanem icon

Revit API PushButton Icon

ArthurGanem | PRO | 04/08/25 05:26:49 AM UTC (Edited) | 0 ⭐ | 13058 👁️ | Never ⏰ | []
C# |

1.89 KB

|

None

|

0 👍

/

0 👎

/*************************************************/
 
/* .ico image embedded into .RESX file   * START */
 
            PushButton pButton = rPanel.AddItem(buttonData) as PushButton;
 
            Icon icon = Properties.Resources.AG_Asset_Protector_Icon;
            MemoryStream ms = new MemoryStream();
            icon.Save(ms);
            ms.Position = 0;
            BitmapImage bLargeImage = new BitmapImage();
            bLargeImage.BeginInit();
            bLargeImage.StreamSource = ms;
            bLargeImage.EndInit();
            pButton.LargeImage = bLargeImage;
            ms.Dispose();
 
/* .ico image embedded into .RESX file     * END */
 
/*************************************************/
 
/* .ico image embedded as file by itself * START */
 
            PushButton pButton = rPanel.AddItem(buttonData) as PushButton;
 
            BitmapImage bLargeImage = new BitmapImage();
            bLargeImage.BeginInit();
            bLargeImage.UriSource = new Uri("pack://application:,,,/AG_View_Bookmarks;component/Images/bookmark-ui-32.ico");
            bLargeImage.EndInit();
            pButton.LargeImage = bLargeImage;
 
            // bLargeImage.UriSource = new Uri("pack://application:,,,/AG_View_Bookmarks;component/Images/bookmark-ui-32.png");
            // ^-- Interestingly enough this below crops the image although it also is 32x32 like the ico...    
 
/* .ico image embedded as file by itself   * END */
 
/*************************************************/
 
/* .ico image called from a directory    * START */
 
            PushButton pButton = rPanel.AddItem(buttonData) as PushButton;
 
            Uri uriImage = new Uri(@"c:\AG_Tools\AG_ButtonOpenSheets_P.ico");
            BitmapImage bLargeImage = new BitmapImage(uriImage);
            pButton.LargeImage = bLargeImage;
 
/* .ico image called from a directory      * END */
 
/*************************************************/
 
 

Comments

  •  icon
    01/01/70 12:00:00 AM UTC
    Plain Text |

    0 B

    |

    👍

    /

    👎

    
        
  •  icon
    01/01/70 12:00:00 AM UTC
    Plain Text |

    0 B

    |

    👍

    /

    👎

    
        
  •  icon
    01/01/70 12:00:00 AM UTC
    Plain Text |

    0 B

    |

    👍

    /

    👎

    
        
  •  icon
    01/01/70 12:00:00 AM UTC
    Plain Text |

    0 B

    |

    👍

    /

    👎

    
        
  •  icon
    01/01/70 12:00:00 AM UTC
    Plain Text |

    0 B

    |

    👍

    /

    👎