/// <summary> /// Paints the SystemCaptionItem as icon in left hand corner. /// </summary> /// <param name="e"></param> public override void PaintSystemIcon(SystemCaptionItemRendererEventArgs e, bool isEnabled) { System.Drawing.Graphics g = e.Graphics; SystemCaptionItem item = e.SystemCaptionItem; Rectangle r = item.DisplayRectangle; r.Offset((r.Width - 16) / 2, (r.Height - 16) / 2); if (item.Icon != null) { if (System.Environment.Version.Build <= 3705 && System.Environment.Version.Revision == 288 && System.Environment.Version.Major == 1 && System.Environment.Version.Minor == 0) { IntPtr hdc = g.GetHdc(); try { NativeFunctions.DrawIconEx(hdc, r.X, r.Y, item.Icon.Handle, r.Width, r.Height, 0, IntPtr.Zero, 3); } finally { g.ReleaseHdc(hdc); } } else g.DrawIcon(item.Icon, r); } }
public virtual void Paint(SystemCaptionItemRendererEventArgs e) { if (e.SystemCaptionItem.IsSystemIcon) PaintSystemIcon(e, e.SystemCaptionItem.GetEnabled()); else PaintFormButtons(e); }
/// <summary> /// Paints the SystemCaptionItem as set of buttons minimize, restore/maximize and close. /// </summary> /// <param name="e"></param> public override void PaintFormButtons(SystemCaptionItemRendererEventArgs e) { if (e.GlassEnabled) // When Windows Vista Glass is enabled we let system caption button paint themselves return; System.Drawing.Graphics g = e.Graphics; SystemCaptionItem item = e.SystemCaptionItem; Office2007SystemButtonColorTable colorTable = m_ColorTable.SystemButton; Rectangle r = item.DisplayRectangle; Region oldClip = g.Clip; Rectangle rclip = r; rclip.Height++; g.SetClip(rclip); Size buttonSize = item.GetButtonSize(); if (buttonSize.Height > r.Height) buttonSize = new Size(r.Height, r.Height); bool itemEnabled = item.GetEnabled(); // Minimize button Rectangle rb = new Rectangle(r.X, r.Y + (r.Height - buttonSize.Height) / 2, buttonSize.Width, buttonSize.Height); eDotNetBarStyle effectiveStyle = item.EffectiveStyle; if (effectiveStyle == eDotNetBarStyle.Metro && item.ContainerControl is DevComponents.DotNetBar.Metro.MetroForm) { Form form = (Form)item.ContainerControl; if(form.FormBorderStyle == FormBorderStyle.FixedDialog) rb.Inflate(0, -2); } Office2007SystemButtonStateColorTable ct = colorTable.Default; if (item.HelpVisible && (!item.IsRightToLeft || item.CloseVisible && item.IsRightToLeft)) { Office2007SystemButtonColorTable originalColorTable = colorTable; if (item.CloseEnabled && itemEnabled && item.IsRightToLeft && m_ColorTable.SystemButtonClose != null) colorTable = m_ColorTable.SystemButtonClose; if (item.CloseEnabled && itemEnabled && item.IsRightToLeft || !item.IsRightToLeft) { if (item.MouseDownButton == SystemButton.Help && !item.IsRightToLeft || item.MouseDownButton == SystemButton.Close && item.IsRightToLeft) ct = colorTable.Pressed; else if (item.MouseOverButton == SystemButton.Help && !item.IsRightToLeft || item.MouseOverButton == SystemButton.Close && item.IsRightToLeft) ct = colorTable.MouseOver; } PaintBackground(g, rb, ct); if (item.IsRightToLeft) PaintClose(g, rb, ct, item.CloseEnabled && itemEnabled); else PaintHelp(g, rb, ct, itemEnabled); rb.Offset(rb.Width + 1, 0); colorTable = originalColorTable; } if (item.MinimizeVisible && item.HelpVisible || item.MinimizeVisible && !item.HelpVisible && (!item.IsRightToLeft || item.CloseVisible && item.IsRightToLeft)) { ct = colorTable.Default; if (item.CloseEnabled && itemEnabled && item.IsRightToLeft || !item.IsRightToLeft) { if (item.MouseDownButton == SystemButton.Minimize && !item.IsRightToLeft || item.MouseDownButton == SystemButton.Close && item.IsRightToLeft) ct = colorTable.Pressed; else if (item.MouseOverButton == SystemButton.Minimize && !item.IsRightToLeft || item.MouseOverButton == SystemButton.Close && item.IsRightToLeft) ct = colorTable.MouseOver; } PaintBackground(g, rb, ct); if (item.IsRightToLeft) PaintClose(g, rb, ct, item.CloseEnabled && itemEnabled); else PaintMinimize(g, rb, ct, itemEnabled); rb.Offset(rb.Width + 1, 0); } if (item.RestoreMaximizeVisible) { if (item.RestoreEnabled && itemEnabled) { ct = colorTable.Default; if (item.MouseDownButton == SystemButton.Restore) ct = colorTable.Pressed; else if (item.MouseOverButton == SystemButton.Restore) ct = colorTable.MouseOver; PaintBackground(g, rb, ct); PaintRestore(g, rb, ct, itemEnabled); } else { ct = colorTable.Default; if (item.MouseDownButton == SystemButton.Maximize) ct = colorTable.Pressed; else if (item.MouseOverButton == SystemButton.Maximize) ct = colorTable.MouseOver; PaintBackground(g, rb, ct); PaintMaximize(g, rb, ct, itemEnabled); } rb.Offset(rb.Width + 1, 0); } if (item.CloseVisible && !item.IsRightToLeft || !item.HelpVisible && item.MinimizeVisible && item.IsRightToLeft || item.HelpVisible && item.IsRightToLeft) { Office2007SystemButtonColorTable originalColorTable = colorTable; if (item.CloseEnabled && itemEnabled && !item.IsRightToLeft && m_ColorTable.SystemButtonClose != null) colorTable = m_ColorTable.SystemButtonClose; ct = colorTable.Default; if (item.CloseEnabled && itemEnabled && !item.IsRightToLeft || item.IsRightToLeft) { if (item.MouseDownButton == SystemButton.Close && !item.IsRightToLeft || item.MouseDownButton == SystemButton.Minimize && item.IsRightToLeft) ct = colorTable.Pressed; else if (item.MouseOverButton == SystemButton.Close && !item.IsRightToLeft || item.MouseOverButton == SystemButton.Minimize && item.IsRightToLeft) ct = colorTable.MouseOver; } PaintBackground(g, rb, ct); if (item.IsRightToLeft) { if (item.HelpVisible) PaintHelp(g, rb, ct, itemEnabled); else PaintMinimize(g, rb, ct, itemEnabled); } else PaintClose(g, rb, ct, item.CloseEnabled && itemEnabled); colorTable = originalColorTable; } g.Clip = oldClip; if (oldClip != null) oldClip.Dispose(); }
public virtual void PaintFormButtons(SystemCaptionItemRendererEventArgs e) { }
public virtual void PaintSystemIcon(SystemCaptionItemRendererEventArgs e, bool isEnabled) { }