diff options
| author | Eric Reed <ebr@mediabrowser3.com> | 2013-11-07 12:27:21 -0500 |
|---|---|---|
| committer | Eric Reed <ebr@mediabrowser3.com> | 2013-11-07 12:27:21 -0500 |
| commit | bda3a301e70b8cdca8af06e6395701ec98a89e09 (patch) | |
| tree | c32ec5d48a48a64bb9e06dd827da9fbc04ce6406 /MediaBrowser.Model/Drawing/DrawingUtils.cs | |
| parent | 63554bde5be929588e9073415ea811170264508b (diff) | |
| parent | 01f1ed05b9a401939ccbd586e07951c144232608 (diff) | |
Merge branch 'master' of https://github.com/MediaBrowser/MediaBrowser
Diffstat (limited to 'MediaBrowser.Model/Drawing/DrawingUtils.cs')
| -rw-r--r-- | MediaBrowser.Model/Drawing/DrawingUtils.cs | 69 |
1 files changed, 66 insertions, 3 deletions
diff --git a/MediaBrowser.Model/Drawing/DrawingUtils.cs b/MediaBrowser.Model/Drawing/DrawingUtils.cs index fabe1b24c..e95b5e375 100644 --- a/MediaBrowser.Model/Drawing/DrawingUtils.cs +++ b/MediaBrowser.Model/Drawing/DrawingUtils.cs @@ -1,4 +1,5 @@ - +using System.Globalization; + namespace MediaBrowser.Model.Drawing { /// <summary> @@ -131,15 +132,77 @@ namespace MediaBrowser.Model.Drawing /// </summary> public struct ImageSize { + private static readonly CultureInfo UsCulture = new CultureInfo("en-US"); + + private double _height; + private double _width; + /// <summary> /// Gets or sets the height. /// </summary> /// <value>The height.</value> - public double Height { get; set; } + public double Height + { + get + { + return _height; + } + set + { + _height = value; + } + } + /// <summary> /// Gets or sets the width. /// </summary> /// <value>The width.</value> - public double Width { get; set; } + public double Width + { + get { return _width; } + set { _width = value; } + } + + public bool Equals(ImageSize size) + { + return Width.Equals(size.Width) && Height.Equals(size.Height); + } + + public override string ToString() + { + return string.Format("{0}-{1}", Width, Height); + } + + public ImageSize(string value) + { + _width = 0; + + _height = 0; + + ParseValue(value); + } + + private void ParseValue(string value) + { + if (!string.IsNullOrEmpty(value)) + { + var parts = value.Split('-'); + + if (parts.Length == 2) + { + double val; + + if (double.TryParse(parts[0], NumberStyles.Any, UsCulture, out val)) + { + _width = val; + } + + if (double.TryParse(parts[1], NumberStyles.Any, UsCulture, out val)) + { + _height = val; + } + } + } + } } } |
