aboutsummaryrefslogtreecommitdiff
path: root/MediaBrowser.Model/Drawing/ImageSize.cs
diff options
context:
space:
mode:
authorAndrew Rabert <ar@nullsum.net>2018-12-27 18:27:57 -0500
committerAndrew Rabert <ar@nullsum.net>2018-12-27 18:27:57 -0500
commita86b71899ec52c44ddc6c3018e8cc5e9d7ff4d62 (patch)
treea74f6ea4a8abfa1664a605d31d48bc38245ccf58 /MediaBrowser.Model/Drawing/ImageSize.cs
parent9bac3ac616b01f67db98381feb09d34ebe821f9a (diff)
Add GPL modules
Diffstat (limited to 'MediaBrowser.Model/Drawing/ImageSize.cs')
-rw-r--r--MediaBrowser.Model/Drawing/ImageSize.cs93
1 files changed, 93 insertions, 0 deletions
diff --git a/MediaBrowser.Model/Drawing/ImageSize.cs b/MediaBrowser.Model/Drawing/ImageSize.cs
new file mode 100644
index 000000000..c2b0291bd
--- /dev/null
+++ b/MediaBrowser.Model/Drawing/ImageSize.cs
@@ -0,0 +1,93 @@
+using System.Globalization;
+
+namespace MediaBrowser.Model.Drawing
+{
+ /// <summary>
+ /// Struct ImageSize
+ /// </summary>
+ public struct ImageSize
+ {
+ 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);
+ }
+
+ public ImageSize(int width, int height)
+ {
+ _width = width;
+ _height = height;
+ }
+
+ public ImageSize(double width, double height)
+ {
+ _width = width;
+ _height = height;
+ }
+
+ 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, CultureInfo.InvariantCulture, out val))
+ {
+ _width = val;
+ }
+
+ if (double.TryParse(parts[1], NumberStyles.Any, CultureInfo.InvariantCulture, out val))
+ {
+ _height = val;
+ }
+ }
+ }
+ }
+ }
+} \ No newline at end of file