2016-10-23 19:47:34 +00:00
|
|
|
using System.Globalization;
|
2014-05-08 20:26:20 +00:00
|
|
|
|
|
|
|
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);
|
|
|
|
}
|
|
|
|
|
2014-12-09 04:57:18 +00:00
|
|
|
public ImageSize(int width, int height)
|
|
|
|
{
|
|
|
|
_width = width;
|
|
|
|
_height = height;
|
|
|
|
}
|
|
|
|
|
2017-05-11 02:57:48 +00:00
|
|
|
public ImageSize(double width, double height)
|
|
|
|
{
|
|
|
|
_width = width;
|
|
|
|
_height = height;
|
|
|
|
}
|
|
|
|
|
2014-05-08 20:26:20 +00:00
|
|
|
private void ParseValue(string value)
|
|
|
|
{
|
|
|
|
if (!string.IsNullOrEmpty(value))
|
|
|
|
{
|
|
|
|
string[] parts = value.Split('-');
|
|
|
|
|
|
|
|
if (parts.Length == 2)
|
|
|
|
{
|
|
|
|
double val;
|
|
|
|
|
2016-10-23 19:47:34 +00:00
|
|
|
if (double.TryParse(parts[0], NumberStyles.Any, CultureInfo.InvariantCulture, out val))
|
2014-05-08 20:26:20 +00:00
|
|
|
{
|
|
|
|
_width = val;
|
|
|
|
}
|
|
|
|
|
2016-10-23 19:47:34 +00:00
|
|
|
if (double.TryParse(parts[1], NumberStyles.Any, CultureInfo.InvariantCulture, out val))
|
2014-05-08 20:26:20 +00:00
|
|
|
{
|
|
|
|
_height = val;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|