public void AddIcon(string name, Bitmap bitmap, string tooltip = "") { U.MakeTransparent(bitmap); AppendInfoSt aist = new AppendInfoSt(); aist.icon = bitmap; aist.tooltip = tooltip; IconList[name] = aist; }
//アイコンリストから描画. ツールチップもつけるよ! public static Size DrawIconAndText(ComboBoxEx lb, int index, Graphics g, Rectangle listbounds, bool isWithDraw) { if (index < 0 || index >= lb.Items.Count) { return(new Size(listbounds.X, listbounds.Y)); } string text = lb.Items[index].ToString(); SolidBrush brush = new SolidBrush(lb.ForeColor); Font normalFont = lb.Font; Rectangle bounds = listbounds; int textmargineY = (ListBoxEx.OWNER_DRAW_ICON_SIZE - (int)lb.Font.Height) / 2; uint addr = InputFormRef.SelectToAddr(lb, index); AppendInfoSt aist = lb.GetAISTByIconList(text, index); //アイコンを描く. Rectangle b = bounds; b.Width = ListBoxEx.OWNER_DRAW_ICON_SIZE; b.Height = ListBoxEx.OWNER_DRAW_ICON_SIZE; if (aist.icon == null) { bounds.X += ListBoxEx.OWNER_DRAW_ICON_SIZE; } else { bounds.X += U.DrawPicture(aist.icon, g, isWithDraw, b); } //bitmap.Dispose(); //アイコンリストにあるので解放してはいけない. //テキストを描く. b = bounds; b.Y += textmargineY; bounds.X += U.DrawText(text, g, normalFont, brush, isWithDraw, b); bounds.Y += ListBoxEx.OWNER_DRAW_ICON_SIZE; brush.Dispose(); if (aist.tooltip != "") { lb.ShowTooltip(aist.tooltip); } return(new Size(bounds.X, bounds.Y)); }
public Bitmap GetCurrentIcon() { AppendInfoSt aist = this.GetAISTByIconList(this.Text, this.SelectedIndex); return(aist.icon); }