public ItemButton CreateItemButton(MapItem item, Rectangle rectangle, Color color, Color captionColor, Font font, int leftMargin, Image icon, bool iconVisible, string caption, object userObject, OnItemPrePaint prePaint, OnItemPostPaint postPaint) { ItemButton button; if (!item.ControlsOnScreen.ContainsKey(userObject)) { button = new ItemButton(rectangle, userObject); button.Caption = caption; button.Font = font; button.TextMargin = leftMargin; button.Color = color; button.CaptionColor = captionColor; button.ItemPrePaint += prePaint; button.ItemPostPaint += postPaint; item.ControlsOnScreen.Add(userObject, button); } else { button = (ItemButton)item.ControlsOnScreen[userObject]; button.ClientRectangle = rectangle; } if (iconVisible) { button.Icon = icon; } button.Caption = caption; button.Destroyed = false; return(button); }
public void CreateItemImage(MapItem item, Rectangle rectangle, Image image, bool imageVisible, Cursor cursor, string hint, object userObject, OnItemPrePaint prePaint, OnItemPostPaint postPaint) { ItemImage itemImage = null; if (!item.ControlsOnScreen.ContainsKey(userObject)) { if (image != null && imageVisible) { itemImage = new ItemImage(rectangle, userObject); itemImage.ItemPrePaint += prePaint; itemImage.ItemPostPaint += postPaint; item.ControlsOnScreen.Add(userObject, itemImage); } } else { itemImage = (ItemImage)item.ControlsOnScreen[userObject]; if (image == null || !imageVisible) { itemImage.Destroyed = true; itemImage = null; } else { itemImage.ClientRectangle = rectangle; } } if (itemImage != null) { itemImage.Image = image; itemImage.Cursor = cursor; itemImage.Hint = hint; itemImage.Destroyed = false; } }