FontInfo.cs 3.2 KB

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