/// <summary> /// Redraws the non client area. /// </summary> /// <param name="invalidateBuffer">if set to <c>true</c> the buffer is invalidated.</param> /// <returns>true if the original painting should be suppressed otherwise false.</returns> protected internal virtual bool OnNcPaint(bool invalidateBuffer) { if (!IsProcessNcArea) { return(false); } bool result = false; try { SkinningFormPaintData paintData = CreatePaintData(); // create painting meta data for caption buttons if (_captionButtons.Count > 0) { paintData.CaptionButtons = new CaptionButtonPaintData[_captionButtons.Count]; for (int i = 0; i < _captionButtons.Count; i++) { CaptionButton button = _captionButtons[i]; CaptionButtonPaintData buttonData = new CaptionButtonPaintData() { BaseData = new PaintDataBase(_basePaintParas._bufferGraphics.Graphics, button.Bounds), Pressed = button.Pressed, Hovered = button.Hovered, Enabled = button.Enabled, HitTest = button.HitTest }; paintData.CaptionButtons[i] = buttonData; } } // paint result = OnNcPaint(paintData); // render buffered graphics if (_basePaintParas._bufferGraphics != null) { _basePaintParas._bufferGraphics.Render(_basePaintParas._g); } } catch (System.Exception) { result = false; } _basePaintParas.Reset(); return(result); }
/// <summary> /// Gets the button paint indices. /// </summary> /// <param name="button">The button paint info.</param> /// <param name="active">A value indicating whether the button is active.</param> /// <param name="buttonIndex">Index of the button icon image strip.</param> /// <param name="rendererIndex">Index of the button background image strip.</param> public static void GetButtonData(CaptionButtonPaintData button, bool active, out int buttonIndex, out int rendererIndex) { if (!button.Enabled) { rendererIndex = -1; buttonIndex = 4; } else if (button.Pressed) { buttonIndex = active ? 2 : 3; rendererIndex = 1; } else if (button.Hovered) { buttonIndex = active ? 1 : 3; rendererIndex = 0; } else { buttonIndex = active ? 0 : 3; rendererIndex = -1; } }