DotNet 4.8.1 build of DotNetBar
This commit is contained in:
@@ -0,0 +1,13 @@
|
||||
using System;
|
||||
using System.Text;
|
||||
|
||||
namespace DevComponents.DotNetBar
|
||||
{
|
||||
/// <summary>
|
||||
/// Defines the abstract class for form caption painter.
|
||||
/// </summary>
|
||||
internal abstract class FormCaptionPainter
|
||||
{
|
||||
public abstract void PaintCaptionBackground(FormCaptionRendererEventArgs e);
|
||||
}
|
||||
}
|
@@ -0,0 +1,36 @@
|
||||
using System;
|
||||
using System.Text;
|
||||
using System.Drawing;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace DevComponents.DotNetBar
|
||||
{
|
||||
/// <summary>
|
||||
/// Provides data for form caption rendering events.
|
||||
/// </summary>
|
||||
public class FormCaptionRendererEventArgs : EventArgs
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets or sets the reference to graphics object.
|
||||
/// </summary>
|
||||
public Graphics Graphics = null;
|
||||
/// <summary>
|
||||
/// Gets or sets the caption bounds.
|
||||
/// </summary>
|
||||
public Rectangle Bounds = Rectangle.Empty;
|
||||
/// <summary>
|
||||
/// Gets or sets the form caption is rendered for.
|
||||
/// </summary>
|
||||
public Form Form = null;
|
||||
|
||||
/// <summary>
|
||||
/// Creates new instance of the class.
|
||||
/// </summary>
|
||||
public FormCaptionRendererEventArgs(Graphics g, Rectangle bounds, Form form)
|
||||
{
|
||||
this.Graphics = g;
|
||||
this.Bounds = bounds;
|
||||
this.Form = form;
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,65 @@
|
||||
using System;
|
||||
using System.Text;
|
||||
using DevComponents.DotNetBar.Rendering;
|
||||
using System.Drawing;
|
||||
using System.Drawing.Drawing2D;
|
||||
|
||||
namespace DevComponents.DotNetBar
|
||||
{
|
||||
/// <summary>
|
||||
/// Defines the Office 2007 style form caption painter.
|
||||
/// </summary>
|
||||
internal class Office2007FormCaptionPainter : FormCaptionPainter, IOffice2007Painter
|
||||
{
|
||||
#region IOffice2007Painter
|
||||
private Office2007ColorTable m_ColorTable = null; //new Office2007ColorTable();
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets color table used by renderer.
|
||||
/// </summary>
|
||||
public Office2007ColorTable ColorTable
|
||||
{
|
||||
get { return m_ColorTable; }
|
||||
set { m_ColorTable = value; }
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Internal Implementation
|
||||
public override void PaintCaptionBackground(FormCaptionRendererEventArgs e)
|
||||
{
|
||||
Graphics g = e.Graphics;
|
||||
Rendering.Office2007FormStateColorTable formct = m_ColorTable.Form.Active;
|
||||
System.Windows.Forms.Form form = e.Form;
|
||||
bool drawBottomBorder = false;
|
||||
if (form != null && form is RibbonForm)
|
||||
{
|
||||
if(!((RibbonForm)form).NonClientActive)
|
||||
formct = m_ColorTable.Form.Inactive;
|
||||
}
|
||||
else if (form != null && (form != System.Windows.Forms.Form.ActiveForm && form.MdiParent == null ||
|
||||
form.MdiParent != null && form.MdiParent.ActiveMdiChild != form))
|
||||
formct = m_ColorTable.Form.Inactive;
|
||||
if (form is OfficeForm) drawBottomBorder = true;
|
||||
|
||||
Rectangle captionRect = e.Bounds;
|
||||
|
||||
SmoothingMode sm = g.SmoothingMode;
|
||||
g.SmoothingMode = SmoothingMode.Default;
|
||||
// Top Part
|
||||
Rectangle topCaptionPart = new Rectangle(captionRect.X, captionRect.Y, captionRect.Width, (int)(captionRect.Height * .3));
|
||||
DisplayHelp.FillRectangle(g, topCaptionPart, formct.CaptionTopBackground);
|
||||
Rectangle bottomCaptionPart = new Rectangle(captionRect.X, topCaptionPart.Bottom, captionRect.Width, captionRect.Height - topCaptionPart.Height);
|
||||
DisplayHelp.FillRectangle(g, bottomCaptionPart, formct.CaptionBottomBackground);
|
||||
if (drawBottomBorder && formct.CaptionBottomBorder != null && formct.CaptionBottomBorder.Length > 0)
|
||||
{
|
||||
int lines = formct.CaptionBottomBorder.Length;
|
||||
for (int i = 0; i < lines; i++)
|
||||
{
|
||||
DisplayHelp.DrawLine(g, captionRect.X, captionRect.Bottom - lines + i, captionRect.Right, captionRect.Bottom - lines + i, formct.CaptionBottomBorder[i], 1);
|
||||
}
|
||||
}
|
||||
g.SmoothingMode = sm;
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
@@ -0,0 +1,521 @@
|
||||
using System;
|
||||
using System.Text;
|
||||
using DevComponents.DotNetBar.Rendering;
|
||||
using System.Drawing;
|
||||
using System.Drawing.Drawing2D;
|
||||
using System.Drawing.Text;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace DevComponents.DotNetBar
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents the painter for the Office 2007 SystemCaptionItem
|
||||
/// </summary>
|
||||
internal class Office2007SystemCaptionItemPainter : SystemCaptionItemPainter, IOffice2007Painter
|
||||
{
|
||||
#region IOffice2007Painter
|
||||
private Office2007ColorTable m_ColorTable = null; //new Office2007ColorTable();
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets color table used by renderer.
|
||||
/// </summary>
|
||||
public Office2007ColorTable ColorTable
|
||||
{
|
||||
get { return m_ColorTable; }
|
||||
set { m_ColorTable = value; }
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Internal Implementation
|
||||
/// <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 - Dpi.Width16) / 2, (r.Height - Dpi.Height16) / 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);
|
||||
}
|
||||
}
|
||||
|
||||
/// <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 (StyleManager.IsMetro(effectiveStyle) && 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;
|
||||
LinearGradientColorTable foregroundOverride = null;
|
||||
bool useForegroundOverride = item.ContainerControl is DevComponents.DotNetBar.Metro.MetroTabStrip && StyleManager.Style != eStyle.OfficeMobile2014;
|
||||
if (useForegroundOverride)
|
||||
foregroundOverride = new LinearGradientColorTable(m_ColorTable.Form.TextColor);
|
||||
else
|
||||
foregroundOverride = null;
|
||||
|
||||
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;
|
||||
foregroundOverride = null;
|
||||
}
|
||||
else if (item.MouseOverButton == SystemButton.Help && !item.IsRightToLeft ||
|
||||
item.MouseOverButton == SystemButton.Close && item.IsRightToLeft)
|
||||
{
|
||||
ct = colorTable.MouseOver;
|
||||
foregroundOverride = null;
|
||||
}
|
||||
}
|
||||
PaintBackground(g, rb, ct);
|
||||
if (item.IsRightToLeft)
|
||||
PaintClose(g, rb, ct, item.CloseEnabled && itemEnabled, foregroundOverride);
|
||||
else
|
||||
PaintHelp(g, rb, ct, itemEnabled, foregroundOverride);
|
||||
|
||||
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 (useForegroundOverride)
|
||||
foregroundOverride = new LinearGradientColorTable(m_ColorTable.Form.TextColor);
|
||||
else
|
||||
foregroundOverride = null;
|
||||
|
||||
if (item.CloseEnabled && itemEnabled && item.IsRightToLeft || !item.IsRightToLeft)
|
||||
{
|
||||
if (item.MouseDownButton == SystemButton.Minimize && !item.IsRightToLeft ||
|
||||
item.MouseDownButton == SystemButton.Close && item.IsRightToLeft)
|
||||
{
|
||||
ct = colorTable.Pressed;
|
||||
foregroundOverride = null;
|
||||
}
|
||||
else if (item.MouseOverButton == SystemButton.Minimize && !item.IsRightToLeft ||
|
||||
item.MouseOverButton == SystemButton.Close && item.IsRightToLeft)
|
||||
{
|
||||
ct = colorTable.MouseOver;
|
||||
foregroundOverride = null;
|
||||
}
|
||||
}
|
||||
PaintBackground(g, rb, ct);
|
||||
if (item.IsRightToLeft)
|
||||
PaintClose(g, rb, ct, item.CloseEnabled && itemEnabled, foregroundOverride);
|
||||
else
|
||||
PaintMinimize(g, rb, ct, itemEnabled, foregroundOverride);
|
||||
|
||||
rb.Offset(rb.Width + 1, 0);
|
||||
}
|
||||
|
||||
if (item.RestoreMaximizeVisible)
|
||||
{
|
||||
if (item.RestoreEnabled && itemEnabled)
|
||||
{
|
||||
ct = colorTable.Default;
|
||||
if (useForegroundOverride)
|
||||
foregroundOverride = new LinearGradientColorTable(m_ColorTable.Form.TextColor);
|
||||
else
|
||||
foregroundOverride = null;
|
||||
|
||||
if (item.MouseDownButton == SystemButton.Restore)
|
||||
{
|
||||
ct = colorTable.Pressed;
|
||||
foregroundOverride = null;
|
||||
}
|
||||
else if (item.MouseOverButton == SystemButton.Restore)
|
||||
{
|
||||
ct = colorTable.MouseOver;
|
||||
foregroundOverride = null;
|
||||
}
|
||||
PaintBackground(g, rb, ct);
|
||||
PaintRestore(g, rb, ct, itemEnabled, foregroundOverride);
|
||||
}
|
||||
else
|
||||
{
|
||||
ct = colorTable.Default;
|
||||
if (useForegroundOverride)
|
||||
foregroundOverride = new LinearGradientColorTable(m_ColorTable.Form.TextColor);
|
||||
else
|
||||
foregroundOverride = null;
|
||||
|
||||
if (item.MouseDownButton == SystemButton.Maximize)
|
||||
{
|
||||
ct = colorTable.Pressed;
|
||||
foregroundOverride = null;
|
||||
}
|
||||
else if (item.MouseOverButton == SystemButton.Maximize)
|
||||
{
|
||||
ct = colorTable.MouseOver;
|
||||
foregroundOverride = null;
|
||||
}
|
||||
PaintBackground(g, rb, ct);
|
||||
PaintMaximize(g, rb, ct, itemEnabled, foregroundOverride);
|
||||
}
|
||||
|
||||
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 (useForegroundOverride)
|
||||
foregroundOverride = new LinearGradientColorTable(m_ColorTable.Form.TextColor);
|
||||
else
|
||||
foregroundOverride = null;
|
||||
|
||||
if (item.CloseEnabled && itemEnabled && !item.IsRightToLeft ||
|
||||
item.IsRightToLeft)
|
||||
{
|
||||
if (item.MouseDownButton == SystemButton.Close && !item.IsRightToLeft ||
|
||||
item.MouseDownButton == SystemButton.Minimize && item.IsRightToLeft)
|
||||
{
|
||||
ct = colorTable.Pressed;
|
||||
foregroundOverride = null;
|
||||
}
|
||||
else if (item.MouseOverButton == SystemButton.Close && !item.IsRightToLeft ||
|
||||
item.MouseOverButton == SystemButton.Minimize && item.IsRightToLeft)
|
||||
{
|
||||
ct = colorTable.MouseOver;
|
||||
foregroundOverride = null;
|
||||
}
|
||||
}
|
||||
|
||||
PaintBackground(g, rb, ct);
|
||||
if (item.IsRightToLeft)
|
||||
{
|
||||
if (item.HelpVisible)
|
||||
PaintHelp(g, rb, ct, itemEnabled, foregroundOverride);
|
||||
else
|
||||
PaintMinimize(g, rb, ct, itemEnabled, foregroundOverride);
|
||||
}
|
||||
else
|
||||
PaintClose(g, rb, ct, item.CloseEnabled && itemEnabled, foregroundOverride);
|
||||
|
||||
colorTable = originalColorTable;
|
||||
}
|
||||
|
||||
g.Clip = oldClip;
|
||||
if (oldClip != null) oldClip.Dispose();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Paints the background of the button using specified color table colors.
|
||||
/// </summary>
|
||||
/// <param name="g">Graphics object.</param>
|
||||
/// <param name="r">Background bounds</param>
|
||||
/// <param name="ct">Color Table</param>
|
||||
protected virtual void PaintBackground(Graphics g, Rectangle r, Office2007SystemButtonStateColorTable ct)
|
||||
{
|
||||
int cornerSize = 2;
|
||||
Rectangle border = r;
|
||||
if (ct.OuterBorder != null && !ct.OuterBorder.IsEmpty)
|
||||
r.Inflate(-1, -1);
|
||||
|
||||
Rectangle rt = new Rectangle(r.X, r.Y, r.Width, r.Height / 2);
|
||||
if (ct.TopBackground != null && !ct.TopBackground.IsEmpty)
|
||||
{
|
||||
rt.Height++;
|
||||
if (ct.BottomBackground == null) rt = r;
|
||||
DisplayHelp.FillRectangle(g, rt, ct.TopBackground);
|
||||
rt.Height--;
|
||||
}
|
||||
|
||||
//Region oldClip = g.Clip;
|
||||
|
||||
if (ct.BottomBackground != null && !ct.BottomBackground.IsEmpty)
|
||||
{
|
||||
rt.Y += rt.Height;
|
||||
rt.Height = (r.Height - rt.Height);
|
||||
DisplayHelp.FillRectangle(g, rt, ct.BottomBackground);
|
||||
}
|
||||
|
||||
// Highlight
|
||||
if (ct.TopHighlight != null && !ct.TopHighlight.IsEmpty)
|
||||
{
|
||||
Rectangle fill = r;
|
||||
fill.Height = fill.Height / 2;
|
||||
DrawHighlight(g, ct.TopHighlight, fill, new PointF(fill.X + fill.Width / 2, fill.Bottom));
|
||||
}
|
||||
|
||||
// Highlight
|
||||
if (ct.BottomHighlight != null && !ct.BottomHighlight.IsEmpty)
|
||||
{
|
||||
Rectangle fill = r;
|
||||
fill.Height = fill.Height / 2;
|
||||
fill.Y += (r.Height - fill.Height);
|
||||
DrawHighlight(g, ct.BottomHighlight, fill, new PointF(fill.X + fill.Width / 2, fill.Bottom));
|
||||
}
|
||||
|
||||
if (ct.OuterBorder != null && !ct.OuterBorder.IsEmpty)
|
||||
{
|
||||
DisplayHelp.DrawRoundGradientRectangle(g, border, ct.OuterBorder, 1, cornerSize);
|
||||
border.Inflate(-1, -1);
|
||||
}
|
||||
|
||||
if (ct.InnerBorder != null && !ct.InnerBorder.IsEmpty)
|
||||
{
|
||||
DisplayHelp.DrawRoundGradientRectangle(g, border, ct.InnerBorder, 1, cornerSize);
|
||||
}
|
||||
}
|
||||
|
||||
private void DrawHighlight(Graphics g, LinearGradientColorTable c, Rectangle r, PointF centerPoint)
|
||||
{
|
||||
Rectangle ellipse = new Rectangle(r.X, r.Y, r.Width, r.Height * 2);
|
||||
GraphicsPath path = new GraphicsPath();
|
||||
path.AddEllipse(ellipse);
|
||||
PathGradientBrush brush = new PathGradientBrush(path);
|
||||
brush.CenterColor = c.Start;
|
||||
brush.SurroundColors = new Color[] { c.End };
|
||||
brush.CenterPoint = centerPoint;
|
||||
Blend blend = new Blend();
|
||||
blend.Factors = new float[] { 0f, .5f, 1f };
|
||||
blend.Positions = new float[] { .0f, .4f, 1f };
|
||||
brush.Blend = blend;
|
||||
|
||||
g.FillRectangle(brush, r);
|
||||
brush.Dispose();
|
||||
path.Dispose();
|
||||
}
|
||||
|
||||
protected virtual void PaintMinimize(Graphics g, Rectangle r, Office2007SystemButtonStateColorTable ct, bool isEnabled, LinearGradientColorTable foregroundOverride)
|
||||
{
|
||||
SmoothingMode sm = g.SmoothingMode;
|
||||
g.SmoothingMode = SmoothingMode.Default;
|
||||
|
||||
Size s = new Size(Dpi.Width7, Dpi.Height3);
|
||||
Rectangle rm = GetSignRect(r, s);
|
||||
|
||||
DisplayHelp.DrawLine(g, rm.X, rm.Y, rm.Right, rm.Y, ct.DarkShade, 1);
|
||||
rm.Offset(0, 1);
|
||||
LinearGradientColorTable foreground = foregroundOverride ?? ct.Foreground;
|
||||
DisplayHelp.DrawLine(g, rm.X, rm.Y, rm.Right, rm.Y, foreground.Start, 1);
|
||||
rm.Offset(0, 1);
|
||||
DisplayHelp.DrawLine(g, rm.X, rm.Y, rm.Right, rm.Y, ct.LightShade, 1);
|
||||
|
||||
g.SmoothingMode = sm;
|
||||
}
|
||||
|
||||
protected virtual Rectangle GetSignRect(Rectangle r, Size s)
|
||||
{
|
||||
if (r.Height < 10)
|
||||
return Rectangle.Empty;
|
||||
|
||||
return new Rectangle(r.X + (r.Width - s.Width) / 2, r.Bottom - r.Height / 4 - s.Height, s.Width, s.Height);
|
||||
}
|
||||
|
||||
protected virtual void PaintRestore(Graphics g, Rectangle r, Office2007SystemButtonStateColorTable ct, bool isEnabled, LinearGradientColorTable foregroundOverride)
|
||||
{
|
||||
SmoothingMode sm = g.SmoothingMode;
|
||||
g.SmoothingMode = SmoothingMode.Default;
|
||||
|
||||
Size s = new Size(Dpi.Width9, Dpi.Height8);
|
||||
Rectangle rm = GetSignRect(r, s);
|
||||
|
||||
Rectangle r1 = new Rectangle(rm.X, rm.Y + Dpi.Height1, Dpi.Width7, Dpi.Height7);
|
||||
Region oldClip = g.Clip;
|
||||
for (int i = 0; i < 2; i++)
|
||||
{
|
||||
LinearGradientColorTable foreground = foregroundOverride ?? ct.Foreground;
|
||||
DisplayHelp.DrawGradientRectangle(g, new Rectangle(r1.X, r1.Y + 1, r1.Width, r1.Height - 1), foreground, 1);
|
||||
DisplayHelp.DrawLine(g, r1.X, r1.Y, r1.Right - 1, r1.Y, ct.DarkShade, 1);
|
||||
DisplayHelp.DrawLine(g, r1.X + 1, r1.Y + 2, r1.Right - 2, r1.Y + 2, ct.LightShade, 1);
|
||||
DisplayHelp.DrawLine(g, r1.X + 1, r1.Y + 2, r1.Right - 2, r1.Y + 2, ct.LightShade, 1);
|
||||
g.SetClip(r1, CombineMode.Exclude);
|
||||
r1.Offset(Dpi.Width2, -Dpi.Height1);
|
||||
}
|
||||
|
||||
if (oldClip != null)
|
||||
g.Clip = oldClip;
|
||||
else
|
||||
g.ResetClip();
|
||||
|
||||
g.SmoothingMode = sm;
|
||||
}
|
||||
|
||||
protected virtual void PaintMaximize(Graphics g, Rectangle r, Office2007SystemButtonStateColorTable ct, bool isEnabled, LinearGradientColorTable foregroundOverride)
|
||||
{
|
||||
SmoothingMode sm = g.SmoothingMode;
|
||||
g.SmoothingMode = SmoothingMode.Default;
|
||||
|
||||
Size s = new Size(Dpi.Width9, Dpi.Height8);
|
||||
Rectangle rm = GetSignRect(r, s);
|
||||
|
||||
Color color = isEnabled ? ct.DarkShade : Color.FromArgb(128, ct.DarkShade);
|
||||
DisplayHelp.DrawLine(g, rm.X, rm.Y, rm.Right - 1, rm.Y, color, 1);
|
||||
rm.Y++;
|
||||
rm.Height--;
|
||||
LinearGradientColorTable foreground = foregroundOverride ?? ct.Foreground;
|
||||
color = isEnabled ? foreground.Start : Color.FromArgb(128, foreground.Start);
|
||||
DisplayHelp.DrawLine(g, rm.X, rm.Y, rm.Right - 1, rm.Y, color, 1);
|
||||
rm.Y++;
|
||||
rm.Height--;
|
||||
Rectangle r1 = rm;
|
||||
r1.Height--;
|
||||
if (isEnabled)
|
||||
DisplayHelp.DrawGradientRectangle(g, r1, foreground, 1);
|
||||
else
|
||||
DisplayHelp.DrawGradientRectangle(g, r1, Color.FromArgb(128, foreground.Start), Color.FromArgb(128, foreground.End), foreground.GradientAngle, 1);
|
||||
|
||||
color = isEnabled ? ct.LightShade : Color.FromArgb(128, ct.LightShade);
|
||||
DisplayHelp.DrawLine(g, rm.X, rm.Bottom - 1, rm.Right - 1, rm.Bottom - 1, color, 1);
|
||||
|
||||
g.SmoothingMode = sm;
|
||||
}
|
||||
|
||||
protected virtual void PaintClose(Graphics g, Rectangle r, Office2007SystemButtonStateColorTable ct, bool isEnabled, LinearGradientColorTable foregroundOverride)
|
||||
{
|
||||
SmoothingMode sm = g.SmoothingMode;
|
||||
g.SmoothingMode = SmoothingMode.Default;
|
||||
Size s = new Size(Dpi.Width11, Dpi.Height9);
|
||||
Rectangle rm = GetSignRect(r, s);
|
||||
|
||||
Rectangle r1 = rm;
|
||||
r1.Inflate(-Dpi.Width1, 0);
|
||||
r1.Height--;
|
||||
|
||||
using (GraphicsPath path = new GraphicsPath())
|
||||
{
|
||||
path.AddLine(r1.X, r1.Y, r1.X + Dpi.Width2, r1.Y);
|
||||
path.AddLine(r1.X + Dpi.Width2, r1.Y, r1.X + Dpi.Width4, r1.Y + Dpi.Width2);
|
||||
path.AddLine(r1.X + Dpi.Width4, r1.Y + Dpi.Width2, r1.X + Dpi.Width6, r1.Y + 0);
|
||||
path.AddLine(r1.X + Dpi.Width6, r1.Y + 0, r1.X + Dpi.Width8, r1.Y + 0);
|
||||
path.AddLine(r1.X + Dpi.Width8, r1.Y + 0, r1.X + Dpi.Width5, r1.Y + Dpi.Height3);
|
||||
path.AddLine(r1.X + Dpi.Width5, r1.Y + Dpi.Height4, r1.X + Dpi.Width8, r1.Y + Dpi.Height7);
|
||||
path.AddLine(r1.X + Dpi.Width8, r1.Y + Dpi.Height7, r1.X + Dpi.Width6, r1.Y + Dpi.Height7);
|
||||
path.AddLine(r1.X + Dpi.Width6, r1.Y + Dpi.Height7, r1.X + Dpi.Width4, r1.Y + Dpi.Height5);
|
||||
path.AddLine(r1.X + Dpi.Width4, r1.Y + Dpi.Height5, r1.X + Dpi.Width2, r1.Y + Dpi.Height7);
|
||||
path.AddLine(r1.X + Dpi.Width2, r1.Y + Dpi.Height7, r1.X + 0, r1.Y + Dpi.Height7);
|
||||
path.AddLine(r1.X + 0, r1.Y + Dpi.Height7, r1.X + Dpi.Width3, r1.Y + Dpi.Height4);
|
||||
path.AddLine(r1.X + Dpi.Width3, r1.Y + Dpi.Height3, r1.X, r1.Y);
|
||||
LinearGradientColorTable foreground = foregroundOverride ?? ct.Foreground;
|
||||
if (isEnabled)
|
||||
{
|
||||
DisplayHelp.FillPath(g, path, foreground);
|
||||
DisplayHelp.DrawGradientPathBorder(g, path, foreground, 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
LinearGradientColorTable lg = new LinearGradientColorTable(foreground.Start.IsEmpty ? foreground.Start : Color.FromArgb(128, foreground.Start),
|
||||
foreground.End.IsEmpty ? foreground.End : Color.FromArgb(128, foreground.End),
|
||||
foreground.GradientAngle);
|
||||
DisplayHelp.FillPath(g, path, lg);
|
||||
DisplayHelp.DrawGradientPathBorder(g, path, lg, 1);
|
||||
}
|
||||
}
|
||||
|
||||
if (!ct.DarkShade.IsEmpty)
|
||||
{
|
||||
using (Pen pen = new Pen(isEnabled ? ct.DarkShade : Color.FromArgb(128, ct.DarkShade), 1))
|
||||
{
|
||||
g.DrawLine(pen, r1.X, r1.Y, r1.X + Dpi.Width2, r1.Y);
|
||||
g.DrawLine(pen, r1.X + Dpi.Width2, r1.Y, r1.X + Dpi.Width4, r1.Y + Dpi.Width2);
|
||||
g.DrawLine(pen, r1.X + Dpi.Width4, r1.Y + Dpi.Width2, r1.X + Dpi.Width6, r1.Y + 0);
|
||||
g.DrawLine(pen, r1.X + Dpi.Width6, r1.Y + 0, r1.X + Dpi.Width8, r1.Y + 0);
|
||||
}
|
||||
}
|
||||
|
||||
if (!ct.LightShade.IsEmpty)
|
||||
{
|
||||
using (Pen pen = new Pen(isEnabled ? ct.LightShade : Color.FromArgb(128, ct.LightShade), 1))
|
||||
{
|
||||
g.DrawLine(pen, rm.X + 0, rm.Y + Dpi.Height8, rm.X + Dpi.Width3, rm.Y + Dpi.Height8);
|
||||
g.DrawLine(pen, rm.X + Dpi.Width3, rm.Y + Dpi.Height8, rm.X + Dpi.Width5, rm.Y + Dpi.Height6);
|
||||
g.DrawLine(pen, rm.X + Dpi.Width5, rm.Y + Dpi.Height6, rm.X + Dpi.Width7, rm.Y + Dpi.Height8);
|
||||
g.DrawLine(pen, rm.X + Dpi.Width7, rm.Y + Dpi.Height8, rm.X + Dpi.Width10, rm.Y + Dpi.Height8);
|
||||
}
|
||||
}
|
||||
|
||||
g.SmoothingMode = sm;
|
||||
|
||||
}
|
||||
|
||||
protected virtual void PaintHelp(Graphics g, Rectangle r, Office2007SystemButtonStateColorTable ct, bool isEnabled, LinearGradientColorTable foregroundOverride)
|
||||
{
|
||||
SmoothingMode sm = g.SmoothingMode;
|
||||
TextRenderingHint th = g.TextRenderingHint;
|
||||
g.SmoothingMode = SmoothingMode.Default;
|
||||
g.TextRenderingHint = TextRenderingHint.ClearTypeGridFit;
|
||||
#if FRAMEWORK20
|
||||
using (Font font = new Font(SystemFonts.DefaultFont, FontStyle.Bold))
|
||||
#else
|
||||
using(Font font = new Font("Arial", 10, FontStyle.Bold))
|
||||
#endif
|
||||
{
|
||||
Size s = TextDrawing.MeasureString(g, "?", font);
|
||||
s.Width += 4;
|
||||
s.Height -= 2;
|
||||
Rectangle rm = GetSignRect(r, s);
|
||||
|
||||
rm.Offset(1, 1);
|
||||
Color color = isEnabled ? ct.LightShade : Color.FromArgb(128, ct.LightShade);
|
||||
using (SolidBrush brush = new SolidBrush(color))
|
||||
g.DrawString("?", font, brush, rm);
|
||||
rm.Offset(-1, -1);
|
||||
LinearGradientColorTable foreground = foregroundOverride ?? ct.Foreground;
|
||||
color = isEnabled ? foreground.Start : Color.FromArgb(128, foreground.Start);
|
||||
using (SolidBrush brush = new SolidBrush(color))
|
||||
g.DrawString("?", font, brush, rm);
|
||||
|
||||
}
|
||||
g.SmoothingMode = sm;
|
||||
g.TextRenderingHint = th;
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
1586
PROMS/DotNetBar Source Code/Office2007Form/OfficeForm.cs
Normal file
1586
PROMS/DotNetBar Source Code/Office2007Form/OfficeForm.cs
Normal file
File diff suppressed because it is too large
Load Diff
2384
PROMS/DotNetBar Source Code/Office2007Form/RibbonForm.cs
Normal file
2384
PROMS/DotNetBar Source Code/Office2007Form/RibbonForm.cs
Normal file
File diff suppressed because it is too large
Load Diff
295
PROMS/DotNetBar Source Code/Office2007Form/SystemCaptionItem.cs
Normal file
295
PROMS/DotNetBar Source Code/Office2007Form/SystemCaptionItem.cs
Normal file
@@ -0,0 +1,295 @@
|
||||
using System;
|
||||
using System.Text;
|
||||
using System.Drawing;
|
||||
using System.ComponentModel;
|
||||
using System.Windows.Forms;
|
||||
using DevComponents.DotNetBar.Controls;
|
||||
|
||||
namespace DevComponents.DotNetBar
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents an item that provides system buttons displayed on form caption.
|
||||
/// </summary>
|
||||
public class SystemCaptionItem : MDISystemItem
|
||||
{
|
||||
#region Private Variables
|
||||
private bool m_MinimizeVisible = true;
|
||||
private bool m_RestoreMaximizeVisible = true;
|
||||
private bool m_CloseVisible = true;
|
||||
private bool m_HelpVisible = false;
|
||||
private bool m_GlassEnabled = false;
|
||||
#endregion
|
||||
|
||||
#region Internal Implementation
|
||||
/// <summary>
|
||||
/// Gets the default size of the system buttons.
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
internal override Size GetButtonSize()
|
||||
{
|
||||
Size s;
|
||||
if (!_CustomButtonSize.IsEmpty)
|
||||
return Dpi.Size(_CustomButtonSize);
|
||||
if (_ToolWindowButtons)
|
||||
{
|
||||
s = System.Windows.Forms.SystemInformation.ToolWindowCaptionButtonSize;
|
||||
s.Width += 5;
|
||||
return s;
|
||||
}
|
||||
|
||||
s = System.Windows.Forms.SystemInformation.CaptionButtonSize;
|
||||
if (System.Environment.OSVersion.Version.Major < 6 && this.ContainerControl is RibbonStrip)
|
||||
s = new Size(Dpi.Width25, Dpi.Height25);
|
||||
else if (this.ContainerControl is TabFormStripControl)
|
||||
s = new Size(Dpi.Width25, Dpi.Height20);
|
||||
else if (StyleManager.IsMetro(this.EffectiveStyle))
|
||||
s = new Size(Dpi.Width25, Dpi.Height25);
|
||||
if (System.Environment.OSVersion.Version.Major >= 6 && s.Height == 19 && this.Parent is CaptionItemContainer)
|
||||
s.Height += 3;
|
||||
|
||||
return s;
|
||||
}
|
||||
|
||||
private Size _CustomButtonSize = Size.Empty;
|
||||
/// <summary>
|
||||
/// Gets or sets the custom button size to use instead of system determined size.
|
||||
/// </summary>
|
||||
[Browsable(false), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
|
||||
public Size CustomButtonSize
|
||||
{
|
||||
get { return _CustomButtonSize; }
|
||||
set { _CustomButtonSize = value; }
|
||||
}
|
||||
|
||||
public override void Paint(ItemPaintArgs pa)
|
||||
{
|
||||
if (this.SuspendLayout)
|
||||
return;
|
||||
|
||||
if (_QueryIconOnPaint && pa.ContainerControl!=null)
|
||||
{
|
||||
Form parentForm = pa.ContainerControl.FindForm();
|
||||
if (parentForm != null)
|
||||
{
|
||||
this.SetIcon(parentForm.Icon);
|
||||
}
|
||||
}
|
||||
|
||||
m_GlassEnabled = pa.GlassEnabled;
|
||||
|
||||
if (pa.Renderer != null)
|
||||
pa.Renderer.DrawSystemCaptionItem(new SystemCaptionItemRendererEventArgs(pa.Graphics, this, pa.GlassEnabled));
|
||||
else
|
||||
base.Paint(pa);
|
||||
}
|
||||
|
||||
protected override bool ShowToolTips
|
||||
{
|
||||
get
|
||||
{
|
||||
return !m_GlassEnabled;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets whether Minimize button is visible.
|
||||
/// </summary>
|
||||
[Browsable(false), DefaultValue(true)]
|
||||
public bool MinimizeVisible
|
||||
{
|
||||
get { return m_MinimizeVisible; }
|
||||
set
|
||||
{
|
||||
m_MinimizeVisible = value;
|
||||
NeedRecalcSize = true;
|
||||
this.OnAppearanceChanged();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets whether Restore/Maximize button is visible.
|
||||
/// </summary>
|
||||
[Browsable(false), DefaultValue(true)]
|
||||
public bool RestoreMaximizeVisible
|
||||
{
|
||||
get { return m_RestoreMaximizeVisible; }
|
||||
set
|
||||
{
|
||||
m_RestoreMaximizeVisible = value;
|
||||
NeedRecalcSize = true;
|
||||
this.OnAppearanceChanged();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets whether Close button is visible.
|
||||
/// </summary>
|
||||
[Browsable(false), DefaultValue(true)]
|
||||
public bool CloseVisible
|
||||
{
|
||||
get { return m_CloseVisible; }
|
||||
set
|
||||
{
|
||||
m_CloseVisible = value;
|
||||
NeedRecalcSize = true;
|
||||
this.OnAppearanceChanged();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets whether help button is visible.
|
||||
/// </summary>
|
||||
[Browsable(false), DefaultValue(false)]
|
||||
public bool HelpVisible
|
||||
{
|
||||
get { return m_HelpVisible; }
|
||||
set
|
||||
{
|
||||
m_HelpVisible = value;
|
||||
NeedRecalcSize = true;
|
||||
this.OnAppearanceChanged();
|
||||
}
|
||||
}
|
||||
|
||||
public override void RecalcSize()
|
||||
{
|
||||
|
||||
if (this.SuspendLayout)
|
||||
return;
|
||||
|
||||
if (this.IsSystemIcon)
|
||||
{
|
||||
base.RecalcSize();
|
||||
}
|
||||
else
|
||||
{
|
||||
Size singleButtonSize = GetButtonSize();
|
||||
int buttonCount = 0;
|
||||
if (m_MinimizeVisible)
|
||||
buttonCount++;
|
||||
if(m_RestoreMaximizeVisible)
|
||||
buttonCount++;
|
||||
if (m_CloseVisible)
|
||||
buttonCount++;
|
||||
if (m_HelpVisible)
|
||||
buttonCount++;
|
||||
|
||||
if (this.Orientation == eOrientation.Horizontal)
|
||||
m_Rect.Size = new Size(singleButtonSize.Width * buttonCount + buttonCount - 1, singleButtonSize.Height);
|
||||
else
|
||||
m_Rect.Size = new Size(singleButtonSize.Width, singleButtonSize.Height * buttonCount + buttonCount - 1);
|
||||
}
|
||||
|
||||
m_NeedRecalcSize = false;
|
||||
}
|
||||
|
||||
internal override SystemButton GetButton(int x, int y)
|
||||
{
|
||||
Rectangle r = new Rectangle(this.DisplayRectangle.Location, GetButtonSize());
|
||||
//r.Inflate(-1, -2);
|
||||
r.Location = this.DisplayRectangle.Location;
|
||||
|
||||
if (this.Orientation == eOrientation.Horizontal)
|
||||
r.Offset(0, (this.DisplayRectangle.Height - r.Height) / 2);
|
||||
else
|
||||
r.Offset((this.WidthInternal - r.Width) / 2, 0);
|
||||
|
||||
if (m_HelpVisible && (!IsRightToLeft || m_CloseVisible && IsRightToLeft))
|
||||
{
|
||||
if (r.Contains(x, y))
|
||||
{
|
||||
if (IsRightToLeft)
|
||||
return SystemButton.Close;
|
||||
else
|
||||
return SystemButton.Help;
|
||||
}
|
||||
|
||||
if (this.Orientation == eOrientation.Horizontal)
|
||||
r.Offset(r.Width + 1, 0);
|
||||
else
|
||||
r.Offset(0, r.Height + 1);
|
||||
}
|
||||
|
||||
if (m_MinimizeVisible && m_HelpVisible || !m_HelpVisible && m_MinimizeVisible && (!IsRightToLeft || m_CloseVisible && IsRightToLeft))
|
||||
{
|
||||
if (r.Contains(x, y))
|
||||
{
|
||||
if (IsRightToLeft)
|
||||
return SystemButton.Close;
|
||||
else
|
||||
return SystemButton.Minimize;
|
||||
}
|
||||
|
||||
if (this.Orientation == eOrientation.Horizontal)
|
||||
r.Offset(r.Width + 1, 0);
|
||||
else
|
||||
r.Offset(0, r.Height + 1);
|
||||
}
|
||||
|
||||
if (m_RestoreMaximizeVisible)
|
||||
{
|
||||
if (r.Contains(x, y))
|
||||
{
|
||||
if (this.RestoreEnabled)
|
||||
return SystemButton.Restore;
|
||||
return SystemButton.Maximize;
|
||||
}
|
||||
|
||||
if (this.Orientation == eOrientation.Horizontal)
|
||||
r.Offset(r.Width + 3, 0);
|
||||
else
|
||||
r.Offset(0, r.Height + 3);
|
||||
}
|
||||
|
||||
if (m_CloseVisible && !IsRightToLeft || m_MinimizeVisible && IsRightToLeft)
|
||||
{
|
||||
if (r.Contains(x, y))
|
||||
{
|
||||
if (IsRightToLeft)
|
||||
return SystemButton.Minimize;
|
||||
else
|
||||
return SystemButton.Close;
|
||||
}
|
||||
}
|
||||
|
||||
return SystemButton.None;
|
||||
}
|
||||
|
||||
public override void Refresh()
|
||||
{
|
||||
base.Refresh();
|
||||
System.Drawing.Rectangle inv = m_Rect;
|
||||
Control c = this.ContainerControl as Control;
|
||||
if (c != null && IsHandleValid(c))
|
||||
{
|
||||
const int RDW_INVALIDATE = 0x0001;
|
||||
const int RDW_FRAME = 0x0400;
|
||||
int height = SystemInformation.Border3DSize.Height + SystemInformation.CaptionHeight;
|
||||
NativeFunctions.RECT r = new NativeFunctions.RECT(0, -height, c.Width, height);
|
||||
NativeFunctions.RedrawWindow(c.Handle, ref r, IntPtr.Zero, RDW_INVALIDATE | RDW_FRAME);
|
||||
}
|
||||
}
|
||||
|
||||
private bool _QueryIconOnPaint = false;
|
||||
/// <summary>
|
||||
/// Gets or sets whether Icon is queried when item is painted. Default value is false.
|
||||
/// </summary>
|
||||
[Browsable(false)]
|
||||
public bool QueryIconOnPaint
|
||||
{
|
||||
get { return _QueryIconOnPaint; }
|
||||
set
|
||||
{
|
||||
_QueryIconOnPaint = value;
|
||||
}
|
||||
}
|
||||
|
||||
private bool _ToolWindowButtons = false;
|
||||
internal bool ToolWindowButtons
|
||||
{
|
||||
get { return _ToolWindowButtons; }
|
||||
set { _ToolWindowButtons = value;}
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
@@ -0,0 +1,23 @@
|
||||
using System;
|
||||
using System.Text;
|
||||
|
||||
namespace DevComponents.DotNetBar
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents the base class for the SystemCaptionItem painter.
|
||||
/// </summary>
|
||||
internal class SystemCaptionItemPainter
|
||||
{
|
||||
public virtual void Paint(SystemCaptionItemRendererEventArgs e)
|
||||
{
|
||||
if (e.SystemCaptionItem.IsSystemIcon)
|
||||
PaintSystemIcon(e, e.SystemCaptionItem.GetEnabled());
|
||||
else
|
||||
PaintFormButtons(e);
|
||||
}
|
||||
|
||||
public virtual void PaintSystemIcon(SystemCaptionItemRendererEventArgs e, bool isEnabled) { }
|
||||
|
||||
public virtual void PaintFormButtons(SystemCaptionItemRendererEventArgs e) { }
|
||||
}
|
||||
}
|
@@ -0,0 +1,42 @@
|
||||
using System;
|
||||
using System.Text;
|
||||
using System.Drawing;
|
||||
|
||||
namespace DevComponents.DotNetBar
|
||||
{
|
||||
/// <summary>
|
||||
/// Provides data for the RenderSystemCaptionItem event.
|
||||
/// </summary>
|
||||
public class SystemCaptionItemRendererEventArgs : EventArgs
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets or sets Graphics control is rendered on.
|
||||
/// </summary>
|
||||
public Graphics Graphics = null;
|
||||
|
||||
/// <summary>
|
||||
/// Gets reference to SystemCaptionItem being rendered.
|
||||
/// </summary>
|
||||
public SystemCaptionItem SystemCaptionItem = null;
|
||||
|
||||
/// <summary>
|
||||
/// Gets whether Windows Vista Glass is enabled.
|
||||
/// </summary>
|
||||
public bool GlassEnabled = false;
|
||||
|
||||
/// <summary>
|
||||
/// Creates new instance of the class and initializes it with default values.
|
||||
/// </summary>
|
||||
/// <param name="g">Reference to Graphics object.</param>
|
||||
/// <param name="item">Reference to item being rendered.</param>
|
||||
/// <param name="glassEnabled">Indicates whether Vista Glass effect is enabled.</param>
|
||||
public SystemCaptionItemRendererEventArgs(Graphics g, SystemCaptionItem item, bool glassEnabled)
|
||||
{
|
||||
this.Graphics = g;
|
||||
this.SystemCaptionItem = item;
|
||||
this.GlassEnabled = glassEnabled;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
Reference in New Issue
Block a user