protected bool _isVisible = true;\r
VerticalAlignment _verticalAlignment;\r
HorizontalAlignment _horizontalAlignment;\r
+ Size _maximumSize;\r
+ Size _minimumSize;\r
\r
Picture _backgroundImage;\r
string _template;\r
registerForGraphicUpdate ();\r
}\r
}\r
+ [XmlAttributeAttribute()][DefaultValue("0;0")]\r
+ public Size MaximumSize {\r
+ get { return _maximumSize; }\r
+ set { _maximumSize = value; }\r
+ }\r
+ [XmlAttributeAttribute()][DefaultValue("0;0")]\r
+ public Size MinimumSize {\r
+ get { return _minimumSize; }\r
+ set { _minimumSize = value; }\r
+ }\r
#endregion\r
+\r
public string BackImgSub = null;\r
\r
/// <summary>\r
pi.SetValue (this, Font.Parse ((string)dv.Value), null);\r
else if (pi.PropertyType == typeof(Picture))\r
pi.SetValue (this, Picture.Parse ((string)dv.Value), null);\r
+ else if (pi.PropertyType == typeof(Size))\r
+ pi.SetValue (this, Size.Parse ((string)dv.Value), null);\r
else\r
pi.SetValue (this, dv.Value, null);\r
continue;\r
TopContainer.redrawClip.AddRectangle (ScreenCoordinates(Slot));\r
}\r
protected virtual Size measureRawSize ()\r
- { \r
+ {\r
return Bounds.Size;\r
}\r
\r
else\r
Slot.Width = Parent.ClientRectangle.Width;\r
\r
+ //size constrain\r
+ if (Slot.Width < MinimumSize.Width)\r
+ Slot.Width = MinimumSize.Width;\r
+ else if (Slot.Width > MaximumSize.Width && MaximumSize.Width > 0)\r
+ Slot.Width = MaximumSize.Width;\r
+\r
if (LastSlots.Width == Slot.Width)\r
break;\r
\r
else\r
Slot.Height = Parent.ClientRectangle.Height;\r
\r
+ //size constrain\r
+ if (Slot.Height < MinimumSize.Height)\r
+ Slot.Height = MinimumSize.Height;\r
+ else if (Slot.Height > MaximumSize.Height && MaximumSize.Height > 0)\r
+ Slot.Height = MaximumSize.Height;\r
+\r
+\r
if (LastSlots.Height == Slot.Height)\r
break;\r
\r
pi.SetValue (this, Font.Parse ((string)defaultValue), null);\r
else if (pi.PropertyType == typeof(Picture))\r
pi.SetValue (this, Picture.Parse ((string)defaultValue), null);\r
+ else if (pi.PropertyType == typeof(Size))\r
+ pi.SetValue (this, Size.Parse ((string)defaultValue), null);\r
else\r
pi.SetValue (this, defaultValue, null);\r
} else {\r
{\r
public static Size Zero\r
{ get { return new Size(0, 0); } }\r
+\r
int _width;\r
int _height;\r
\r
- //public Size()\r
- //{ }\r
public Size(int width, int height)\r
{\r
_width = width;\r
_height = height;\r
}\r
+ public Size(int size)\r
+ {\r
+ _width = size;\r
+ _height = size;\r
+ }\r
public int Width\r
{\r
get { return _width; }\r
get { return _height; }\r
set { _height = value; }\r
}\r
- public override string ToString()\r
- {\r
- return string.Format("({0},{1})", Width, Height);\r
- }\r
+ #region operators\r
public static implicit operator Rectangle(Size s)\r
{\r
return new Rectangle (s);\r
{\r
return new Size(i, i);\r
}\r
- public static bool operator ==(Size s1, Size s2)\r
+ public static implicit operator string(Size s)\r
+ {\r
+ return s.ToString ();\r
+ }\r
+ public static implicit operator Size(string s)\r
+ {\r
+ return string.IsNullOrEmpty (s) ? Size.Zero : Parse (s);\r
+ }\r
+ public static bool operator ==(Size s1, Size s2)\r
{\r
if (s1.Width == s2.Width && s1.Height == s2.Height)\r
return true;\r
{\r
return new Size(s.Width + i, s.Height + i);\r
}\r
- }\r
+ #endregion\r
+ \r
+ public override string ToString()\r
+ {\r
+ return string.Format("{0},{1}", Width, Height);\r
+ }\r
+ public static Size Parse(string s)\r
+ {\r
+ string[] d = s.Split(new char[] { ';' });\r
+ return d.Length == 1 ? new Size(int.Parse(d[0])) : new Size(\r
+ int.Parse(d[0]),\r
+ int.Parse(d[1]));\r
+ }\r
+ }\r
\r
}\r