using System; using System.Drawing; using System.Windows.Forms; namespace TradeIdeas.TIProGUI.Charting.Controls.ChartMenuToolBar { [System.ComponentModel.DesignerCategory("")] public class MenuButton : Button { public Image LightImage { get; set; } public Image DarkImage { get; set; } public EventHandler ClickSubscriber { get { return null; } set { Click += value; } } public ToolTip _toolTip { get; set; } public string ToolTipText { get { return null; } set { // The heart menu tooltip is changed onclick, only new it up once so we don't get multiple tooltips displayed on hover if (_toolTip == null) _toolTip = new ToolTip(); _toolTip.SetToolTip(this, value); } } public MenuButton() { Height = 18; Width = 18; FlatStyle = FlatStyle.Flat; FlatAppearance.BorderSize = 0; BackColor = Color.Transparent; ImageAlign = ContentAlignment.MiddleCenter; //Note: Even though we're setting MiddleCenter, the image will be pushed down 1px and to the right 1px, so re-set padding to push it back left and up by 1px Padding = new Padding(0, 0, 1, 1); SetStyle(ControlStyles.Selectable, false); FlatAppearance.MouseOverBackColor = Color.Transparent; FlatAppearance.MouseDownBackColor = Color.Transparent; } public bool IsDarkTheme { get; set; } public virtual void SetTheme(Color backColor) { IsDarkTheme = backColor.IsDark(); Image = IsDarkTheme ? DarkImage : LightImage; } } }