FontInfo.cs 3.2 KB

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