ImageDescriptionAttribute.cs 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  1. #region --------------- Copyright Dresser Wayne Pignone -------------
  2. /*
  3. * $Log: /Wrk/WayneLibraries/Wrk/StateEngine/Description/ImageDescriptionAttribute.cs $
  4. *
  5. * 4 08-03-10 15:02 Mattias.larsson
  6. * Changed parameter to GetDefaultImageFileName().
  7. *
  8. * 3 08-03-07 10:01 Mattias.larsson
  9. * Added StateMachineDefaultMainImage.
  10. *
  11. * 2 07-03-29 9:10 Mattias.larsson
  12. */
  13. #endregion
  14. using System;
  15. namespace Wayne.Lib.StateEngine
  16. {
  17. /// <summary>
  18. /// Adds a document image describing this state.
  19. /// </summary>
  20. [AttributeUsage(AttributeTargets.Class, AllowMultiple = true, Inherited = true)]
  21. public sealed class ImageDescriptionAttribute : Attribute
  22. {
  23. #region Fields
  24. private string imageFileName;
  25. private string description;
  26. #endregion
  27. #region Construction
  28. /// <summary>
  29. /// Description of an image with its default file name and no description.
  30. /// </summary>
  31. public ImageDescriptionAttribute()
  32. {
  33. this.description = "";
  34. this.imageFileName = "";
  35. }
  36. /// <summary>
  37. /// Description of an image with its default file name.
  38. /// </summary>
  39. /// <param name="imageFileName">The file name of the image.
  40. /// Keep null or empty to use default state image filename.</param>
  41. public ImageDescriptionAttribute(string imageFileName)
  42. {
  43. this.imageFileName = imageFileName;
  44. this.description = "";
  45. }
  46. /// <summary>
  47. /// Description of an image given a file name.
  48. /// </summary>
  49. /// <param name="imageFileName">The file name of the image.
  50. /// Keep null or empty to use default state image filename.</param>
  51. /// <param name="description">A descriptive text for the image.</param>
  52. public ImageDescriptionAttribute(string imageFileName, string description)
  53. {
  54. this.imageFileName = imageFileName;
  55. this.description = description;
  56. }
  57. #endregion
  58. #region Properties
  59. /// <summary>
  60. /// The file name of the image.
  61. /// </summary>
  62. public string ImageFileName
  63. {
  64. get { return imageFileName; }
  65. }
  66. /// <summary>
  67. /// A descriptive text for the image.
  68. /// </summary>
  69. public string Description
  70. {
  71. get { return description; }
  72. }
  73. /// <summary>
  74. /// Gets the default filename (including relative path and extension) given a state.
  75. /// </summary>
  76. /// <param name="factoryName"></param>
  77. /// <returns></returns>
  78. public static string GetDefaultImageFileName(string factoryName)
  79. {
  80. return string.Concat(factoryName, DefaultImageFileExtension);
  81. }
  82. /// <summary>
  83. /// The default image filename extension.
  84. /// </summary>
  85. /// <returns></returns>
  86. public static string DefaultImageFileExtension
  87. {
  88. get { return ".png"; }
  89. }
  90. /// <summary>
  91. /// The default filename of the main image of the StateMachine.
  92. /// </summary>
  93. /// <returns></returns>
  94. public static string StateMachineDefaultMainImage
  95. {
  96. get { return string.Concat("MainStates", DefaultImageFileExtension); }
  97. }
  98. #endregion
  99. }
  100. }