Icon 图标
#
简介图标对象可以由以下方法创建:
export interface IWindow extends IControl { CreateManagedIcon(icon: IconSource): IIcon;}
export class IconSource { constructor(resId: number, pixelSizeWhen100Percent: number);}
#
资源 ID在使用图标之前,需要先创建 resource map 以获取资源 id:
const iconDataMap = { Open: [path.resolve(__dirname, './FileOpen#0.png')],};const resMap = app.CreateResourceMap( app, [16] /* icon size list */, iconDataMap,);
然后它是这样用的:
window.OnCreateContent((sender) => { const button = new Button(window); button.SetText('Open'); button.SetVisualTextLayout(VisualTextLayout.HorzVisualText);
const iconSource = new IconSource(resMap.Open, 16); const icon = window.CreateManagedIcon(iconSource); button.SetVisual(icon); ... return true;});