/EventTracker.Phone.Api/Models/Image.cs

https://github.com/eddwinston/Event-tracker · C# · 205 lines · 133 code · 32 blank · 40 comment · 10 complexity · f8510ed268c176cf3d5d3d47a5e0db15 MD5 · raw file

  1. using System;
  2. using System.Net;
  3. using System.Windows;
  4. using System.Windows.Controls;
  5. using System.Windows.Documents;
  6. using System.Windows.Ink;
  7. using System.Windows.Input;
  8. using System.Windows.Media;
  9. using System.Windows.Media.Animation;
  10. using System.Windows.Shapes;
  11. using System.Xml.Serialization;
  12. using GalaSoft.MvvmLight;
  13. namespace EventTracker.Phone.Api
  14. {
  15. #region ImageBase
  16. public class ImageBase : ViewModelBase
  17. {
  18. public ImageBase()
  19. {
  20. _url = "/Assets/NoImage.png";
  21. }
  22. #region Url
  23. /// <summary>
  24. /// The <see cref="Url" /> property's name.
  25. /// </summary>
  26. public const string UrlPropertyName = "Url";
  27. private string _url = string.Empty;
  28. /// <summary>
  29. /// Gets the Url property.
  30. /// TODO Update documentation:
  31. /// Changes to that property's value raise the PropertyChanged event.
  32. /// This property's value is broadcasted by the Messenger's default instance when it changes.
  33. /// </summary>
  34. [XmlElement("url")]
  35. public string Url
  36. {
  37. get
  38. {
  39. return _url;
  40. }
  41. set
  42. {
  43. if (_url == value)
  44. {
  45. return;
  46. }
  47. _url = value;
  48. // Update bindings, no broadcast
  49. RaisePropertyChanged(UrlPropertyName);
  50. }
  51. }
  52. #endregion
  53. public bool IsLocal
  54. {
  55. get
  56. {
  57. if (_url.StartsWith("http:") || _url.StartsWith("https:"))
  58. return false;
  59. return true;
  60. }
  61. }
  62. }
  63. #endregion
  64. [XmlRoot("small")]
  65. public class Small : ImageBase { }
  66. [XmlRoot("thumb")]
  67. public class Thumbnail : ImageBase { }
  68. [XmlRoot("medium")]
  69. public class Medium : ImageBase { }
  70. [XmlRoot("image")]
  71. public class Image : ImageBase
  72. {
  73. public Image()
  74. {
  75. Small = new Small();
  76. Thumbnail = new Thumbnail();
  77. Medium = new Medium();
  78. }
  79. #region Small
  80. /// <summary>
  81. /// The <see cref="Small" /> property's name.
  82. /// </summary>
  83. public const string SmallPropertyName = "Small";
  84. private Small _small = null;
  85. /// <summary>
  86. /// Gets the Small property.
  87. /// TODO Update documentation:
  88. /// Changes to that property's value raise the PropertyChanged event.
  89. /// This property's value is broadcasted by the Messenger's default instance when it changes.
  90. /// </summary>
  91. [XmlElement("small", Type = typeof(Small))]
  92. public Small Small
  93. {
  94. get
  95. {
  96. return _small;
  97. }
  98. set
  99. {
  100. if (_small == value)
  101. {
  102. return;
  103. }
  104. _small = value;
  105. // Update bindings, no broadcast
  106. RaisePropertyChanged(SmallPropertyName);
  107. }
  108. }
  109. #endregion
  110. #region Thumbnail
  111. /// <summary>
  112. /// The <see cref="Thumbnail" /> property's name.
  113. /// </summary>
  114. public const string ThumbnailPropertyName = "Thumbnail";
  115. private Thumbnail _thumbnail = null;
  116. /// <summary>
  117. /// Gets the Thumbnail property.
  118. /// TODO Update documentation:
  119. /// Changes to that property's value raise the PropertyChanged event.
  120. /// This property's value is broadcasted by the Messenger's default instance when it changes.
  121. /// </summary>
  122. [XmlElement("thumb")]
  123. public Thumbnail Thumbnail
  124. {
  125. get
  126. {
  127. return _thumbnail;
  128. }
  129. set
  130. {
  131. if (_thumbnail == value)
  132. {
  133. return;
  134. }
  135. _thumbnail = value;
  136. // Update bindings, no broadcast
  137. RaisePropertyChanged(ThumbnailPropertyName);
  138. }
  139. }
  140. #endregion
  141. #region Medium
  142. /// <summary>
  143. /// The <see cref="Medium" /> property's name.
  144. /// </summary>
  145. public const string MediumPropertyName = "Medium";
  146. private Medium _medium = null;
  147. /// <summary>
  148. /// Gets the Medium property.
  149. /// TODO Update documentation:
  150. /// Changes to that property's value raise the PropertyChanged event.
  151. /// This property's value is broadcasted by the Messenger's default instance when it changes.
  152. /// </summary>
  153. [XmlElement("medium")]
  154. public Medium Medium
  155. {
  156. get
  157. {
  158. return _medium;
  159. }
  160. set
  161. {
  162. if (_medium == value)
  163. {
  164. return;
  165. }
  166. _medium = value;
  167. // Update bindings, no broadcast
  168. RaisePropertyChanged(MediumPropertyName);
  169. }
  170. }
  171. #endregion
  172. }
  173. }