/// <summary> /// Raises the SystemColorsChanged event. /// </summary> /// <param name="e">An EventArgs that contains the event data. </param> protected override void OnSystemColorsChanged(EventArgs e) { // Update with the colors for the IDE style _colorDetails.DefineBaseColors(BackColor); _colorDetails.DefineTrackColors(SystemColors.Highlight); // Update the display now Refresh(); base.OnSystemColorsChanged(e); }
/// <summary> /// Initializes a new instance of the ButtonWithStyle class. /// </summary> public ButtonWithStyle() { // NAG processing NAG.NAG_Start(); // Prevent drawing flicker by blitting from memory in WM_PAINT SetStyle(ControlStyles.DoubleBuffer | ControlStyles.AllPaintingInWmPaint | ControlStyles.UserPaint | ControlStyles.ResizeRedraw, true); // Prevent base class from trying to generate double click events and // so testing clicks against the double click time and rectangle. Getting // rid of this allows the user to press then button very quickly. SetStyle(ControlStyles.StandardDoubleClick, false); // Should not be allowed to select this control SetStyle(ControlStyles.Selectable, false); // We do not want a mouse up to always cause a click, we decide that SetStyle(ControlStyles.StandardClick, false); // We are happy to allow a transparent background color SetStyle(ControlStyles.SupportsTransparentBackColor, true); // Set initial state _image = new CommandImage(); _mouseOver = false; _staticIDE = false; _mouseCapture = false; _mouseButton = MouseButtons.None; _colorDetails = new ColorDetails(); // Update with the tracking colors for the IDE style _colorDetails.DefineTrackColors(SystemColors.Highlight); // We need to know when our text changes TextChanged += new EventHandler(OnTextChanged); // Reset all properties to default values ResetImage(); ResetStyle(); ResetDirection(); ResetTextEdge(); ResetButtonStyle(); ResetPushed(); ResetBackColor(); ResetAlwaysDrawEnabled(); ResetAlwaysDrawBorder(); ResetOffice2003GradBack(); ResetIDE2005GradBack(); }