diff options
| author | jpbruyere <jp.bruyere@hotmail.com> | 2016-07-19 03:35:12 +0200 |
|---|---|---|
| committer | jpbruyere <jp.bruyere@hotmail.com> | 2016-07-19 03:35:12 +0200 |
| commit | b24beece9ed58b2700dd5d2d56fa45e446567ab0 (patch) | |
| tree | 8930bbda0c8b8a216718fe986eb3ef5c9635ef75 /src/Measure.cs | |
| parent | 762161320ddf4bcad8b201cc9170f617f4ec2bed (diff) | |
lots of unordered changes, I commited all in a devel branch, which will be the programming branch
Diffstat (limited to 'src/Measure.cs')
| -rw-r--r-- | src/Measure.cs | 31 |
1 files changed, 30 insertions, 1 deletions
diff --git a/src/Measure.cs b/src/Measure.cs index 64e5cc98..19e8f548 100644 --- a/src/Measure.cs +++ b/src/Measure.cs @@ -22,22 +22,47 @@ using System; namespace Crow { + /// <summary> + /// Measurement unit + /// </summary> public enum Unit { Pixel, Percent } + /// <summary> + /// Measure class allow proportional sizes as well as stretched and fit on content. + /// </summary> public struct Measure { + /// <summary> + /// Integer value of the measure + /// </summary> public int Value; + /// <summary> + /// Measurement unit + /// </summary> public Unit Units; + /// <summary> + /// Fit on content, this special measure is defined as a fixed integer set to -1 pixel + /// </summary> public static Measure Fit = new Measure(-1); - //TODO:implement stretching as 100%, not 0% + /// <summary> + /// Stretched into parent client area. This special measure is defined as a proportional cote + /// set to 100 Percents + /// </summary> public static Measure Stretched = new Measure(100, Unit.Percent); + #region CTOR public Measure (int _value, Unit _units = Unit.Pixel) { Value = _value; Units = _units; } + #endregion + + /// <summary> + /// True is size is fixed in pixels, this means not proportional, stretched nor fit. + /// </summary> public bool IsFixed { get { return Value > 0 && Units == Unit.Pixel; }} + #region Operators public static implicit operator int(Measure m){ return m.Value; @@ -59,6 +84,8 @@ namespace Crow return !(m1.Value == m2.Value && m1.Units == m2.Units); } #endregion + + #region Object overrides public override int GetHashCode () { return Value.GetHashCode (); @@ -75,6 +102,8 @@ namespace Crow Units == Unit.Percent ? Value == 100 ? "Stretched" : Value.ToString () + "%" : Value.ToString (); } + #endregion + public static Measure Parse(string s){ if (string.IsNullOrEmpty (s)) return Measure.Stretched; |