FontInfo.cs 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197
  1. /**
  2. * Namespace: System.Web.UI.WebControls
  3. * Class: FontInfo
  4. *
  5. * Author: Gaurav Vaish
  6. * Contact: <[email protected]>, <[email protected]>
  7. * Status: 80%
  8. *
  9. * (C) Gaurav Vaish (2001)
  10. */
  11. using System;
  12. using System.Reflection;
  13. using System.Web;
  14. using System.Web.UI;
  15. using System.Drawing;
  16. namespace System.Web.UI.WebControls
  17. {
  18. public sealed class FontInfo
  19. {
  20. private bool bold;
  21. private bool italic;
  22. private bool overline;
  23. private bool strikeout;
  24. private bool underline;
  25. private string name; //TODO: This will have the value of names[0] by default
  26. private string[] names; //TODO: How do get the list of fonts available?
  27. private FontUnit size = FontUnit.Empty;
  28. internal FontInfo()
  29. {
  30. bold = false;
  31. italic = false;
  32. overline = false;
  33. strikeout = false;
  34. underline = false;
  35. name = string.Empty;
  36. }
  37. public bool Bold
  38. {
  39. get
  40. {
  41. return bold;
  42. }
  43. set
  44. {
  45. bold = value;
  46. }
  47. }
  48. public bool Italic
  49. {
  50. get
  51. {
  52. return italic;
  53. }
  54. set
  55. {
  56. italic = value;
  57. }
  58. }
  59. public bool Overline
  60. {
  61. get
  62. {
  63. return overline;
  64. }
  65. set
  66. {
  67. overline = value;
  68. }
  69. }
  70. public bool Strikeout
  71. {
  72. get
  73. {
  74. return strikeout;
  75. }
  76. set
  77. {
  78. strikeout = value;
  79. }
  80. }
  81. public bool Underline
  82. {
  83. get
  84. {
  85. return underline;
  86. }
  87. set
  88. {
  89. underline = value;
  90. }
  91. }
  92. public string Name
  93. {
  94. get
  95. {
  96. return name;
  97. }
  98. set
  99. {
  100. name = value;
  101. }
  102. }
  103. public string[] Names
  104. {
  105. get
  106. {
  107. return names;
  108. }
  109. set
  110. {
  111. names = value;
  112. name = names[0];
  113. }
  114. }
  115. //TODO: To throw exception if the index is negative
  116. public FontUnit Size
  117. {
  118. get
  119. {
  120. return size;
  121. }
  122. set
  123. {
  124. size = value;
  125. }
  126. }
  127. public void CopyFrom(FontInfo from)
  128. {
  129. //TODO: What a rubbish way to accomplish the task
  130. /*this.bold = from.Bold;
  131. this.italic = from.Italic;
  132. this.name = from.Name;
  133. this.names = from.Names;
  134. this.overline = from.Overline;
  135. this.size = from.Size;*/
  136. //TODO: Let me try Relflection
  137. Type t = from.GetType();
  138. MethodInfo[] fi = t.GetMethods();
  139. foreach(MethodInfo f in fi)
  140. {
  141. //System.Console.WriteLine("Field: {0}", f.Name);
  142. if(f.Name.StartsWith("get_"))
  143. {
  144. System.Console.WriteLine("\tStarts with get_");
  145. }
  146. }
  147. }
  148. private void ListFields(FontInfo from)
  149. {
  150. Type t = from.GetType();
  151. MethodInfo[] fi = t.GetMethods();
  152. foreach(MethodInfo f in fi)
  153. {
  154. System.Console.WriteLine("Field: {0}", f.Name);
  155. if(f.Name.StartsWith("get_"))
  156. {
  157. System.Console.WriteLine("\tStarts with get_");
  158. }
  159. }
  160. }
  161. //TODO: after CopyFrom is implemented
  162. public void MergeWith(FontInfo with)
  163. {
  164. }
  165. public override string ToString()
  166. {
  167. string retVal = this.name;
  168. if(this.size != FontUnit.Empty)
  169. {
  170. this.name += ("," + this.size);
  171. }
  172. return retVal;
  173. }
  174. /*
  175. protected object MemberwiseClone()
  176. {
  177. }
  178. //*/
  179. }
  180. }