aboutsummaryrefslogtreecommitdiff
path: root/MediaBrowser.Model/Drawing/ImageSize.cs
diff options
context:
space:
mode:
authorLuke Pulverenti <luke.pulverenti@gmail.com>2014-05-08 16:26:20 -0400
committerLuke Pulverenti <luke.pulverenti@gmail.com>2014-05-08 16:26:20 -0400
commitbb031f553b940d21fa89f319d294745484c2234e (patch)
tree29aac2660ab9186b5d43941fb0c6ef249ce33a71 /MediaBrowser.Model/Drawing/ImageSize.cs
parentf02c3260273a09f465c4e7a97d8b90f0f6909734 (diff)
fix portable and 3.5 project references
Diffstat (limited to 'MediaBrowser.Model/Drawing/ImageSize.cs')
-rw-r--r--MediaBrowser.Model/Drawing/ImageSize.cs83
1 files changed, 83 insertions, 0 deletions
diff --git a/MediaBrowser.Model/Drawing/ImageSize.cs b/MediaBrowser.Model/Drawing/ImageSize.cs
new file mode 100644
index 000000000..acc245938
--- /dev/null
+++ b/MediaBrowser.Model/Drawing/ImageSize.cs
@@ -0,0 +1,83 @@
+using System.Globalization;
+
+namespace MediaBrowser.Model.Drawing
+{
+ /// <summary>
+ /// Struct ImageSize
+ /// </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
+ {
+ return _height;
+ }
+ set
+ {
+ _height = value;
+ }
+ }
+
+ /// <summary>
+ /// Gets or sets the width.
+ /// </summary>
+ /// <value>The width.</value>
+ 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))
+ {
+ string[] 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;
+ }
+ }
+ }
+ }
+ }
+} \ No newline at end of file