18 using System.Windows.Forms;
20 namespace sage.ew.formul.ButtonTittle.Themes
22 internal class ThemeBase : ITheme
25 protected Point buttonOffset =
new Point(0, 0);
26 protected Size controlBoxSize = Size.Empty;
28 protected Size frameBorder = Size.Empty;
29 protected bool? isDisplayed;
30 protected bool? isToolbar;
31 protected Size systemButtonSize = Size.Empty;
33 public ThemeBase(Form form)
38 protected bool IsToolbar
42 if (isToolbar == null)
44 isToolbar = form.FormBorderStyle == FormBorderStyle.FixedToolWindow ||
45 form.FormBorderStyle == FormBorderStyle.SizableToolWindow;
47 return (
bool) isToolbar;
51 #region ITheme Members 57 if (backColor ==
Color.Empty)
59 backColor =
Color.FromKnownColor(KnownColor.Control);
66 public bool IsDisplayed
70 if (isDisplayed == null)
72 if ((!form.ControlBox &&
string.IsNullOrEmpty(form.Text))
73 || form.FormBorderStyle == FormBorderStyle.None
83 return (
bool) isDisplayed;
87 public virtual Size ControlBoxSize
91 if (controlBoxSize == Size.Empty)
97 controlBoxSize =
new Size(SystemButtonSize.Width, SystemButtonSize.Height);
101 controlBoxSize =
new Size(0, 0);
107 if (!form.MaximizeBox && !form.MinimizeBox && form.ControlBox)
109 index = (form.HelpButton) ? 2 : 1;
113 index = (form.ControlBox) ? 3 : 0;
115 controlBoxSize =
new Size(index*SystemButtonSize.Width, SystemButtonSize.Height);
118 return controlBoxSize;
122 public virtual Point ButtonOffset
124 get {
return buttonOffset; }
128 public virtual Size FrameBorder
132 if (frameBorder == Size.Empty)
134 switch (form.FormBorderStyle)
136 case FormBorderStyle.SizableToolWindow:
137 frameBorder =
new Size(SystemInformation.FrameBorderSize.Width + 2,
138 SystemInformation.FrameBorderSize.Height + 2);
140 case FormBorderStyle.Sizable:
141 frameBorder =
new Size(SystemInformation.FrameBorderSize.Width,
142 SystemInformation.FrameBorderSize.Height + 2);
144 case FormBorderStyle.FixedToolWindow:
145 frameBorder =
new Size(SystemInformation.Border3DSize.Width + 3,
146 SystemInformation.Border3DSize.Height + 3);
149 frameBorder =
new Size(SystemInformation.Border3DSize.Width + 1,
150 SystemInformation.Border3DSize.Height + 3);
158 public virtual Size SystemButtonSize
162 if (systemButtonSize == Size.Empty)
166 Size size = SystemInformation.ToolWindowCaptionButtonSize;
169 systemButtonSize = size;
173 systemButtonSize =
new Size(SystemInformation.CaptionButtonSize.Width,
174 SystemInformation.CaptionHeight - 2
177 SystemInformation.BorderSize.
179 SystemInformation.Border3DSize
184 return systemButtonSize;