OSDN Git Service

hk
[psychlops/silverlight.git] / dev3 / psychlops / core / graphic / font.cs
diff --git a/dev3/psychlops/core/graphic/font.cs b/dev3/psychlops/core/graphic/font.cs
new file mode 100644 (file)
index 0000000..3c03840
--- /dev/null
@@ -0,0 +1,131 @@
+using System;\r
+using System.Net;\r
+using System.Windows;\r
+using System.Windows.Controls;\r
+using System.Windows.Documents;\r
+using System.Windows.Ink;\r
+using System.Windows.Input;\r
+using System.Windows.Media;\r
+using System.Windows.Media.Animation;\r
+using System.Windows.Shapes;\r
+\r
+namespace Psychlops\r
+{\r
+       public class Font\r
+       {\r
+               public static Font default_font;\r
+\r
+               public enum Style { normal_style, italic, oblique };\r
+               public enum Weight { normal_weight=400, bold=700 };\r
+               public double size;\r
+               public int weight;\r
+               public Style style;\r
+               public string[] family;\r
+\r
+               static Font()\r
+               {\r
+                       default_font = new Font();\r
+               }\r
+               public Font()\r
+               {\r
+                       size = 24;\r
+                       weight = (int)Weight.normal_weight;\r
+                       style = Style.normal_style;\r
+                       family = new string[1];\r
+               }\r
+               public Font(double size_, int weight_, Style style_, string family_)\r
+               {\r
+                       size = size_;\r
+                       weight = weight_;\r
+                       style = style_;\r
+                       family = new string[1];\r
+                       family[0] = family_;\r
+               }\r
+               public Font(string family_, double size_, int weight_, Style style_)\r
+               {\r
+                       size = size_;\r
+                       weight = weight_;\r
+                       style = style_;\r
+                       family = new string[1];\r
+                       family[0] = family_;\r
+               }\r
+               ~Font()\r
+               {\r
+               }\r
+       }\r
+\r
+       public class Letters : Shape\r
+       {\r
+               protected string str_;\r
+               protected Font font_;\r
+               protected double width_, height_;\r
+               public Point datum;\r
+\r
+               public enum HorizontalAlign { NOT_SPECIFIED=-1, TEXT_ALIGN_LEFT=0, TEXT_ALIGN_CENTER, TEXT_ALIGN_RIGHT };\r
+               public HorizontalAlign align;\r
+\r
+               public Letters()\r
+               {\r
+                       str_ = "";\r
+                       font = Font.default_font;\r
+                       align = HorizontalAlign.TEXT_ALIGN_LEFT;\r
+               }\r
+               public Letters(String init_str)\r
+               {\r
+                       str_ = init_str;\r
+                       font_ = Font.default_font;\r
+                       align = HorizontalAlign.TEXT_ALIGN_LEFT;\r
+               }\r
+               public Letters(String init_str, Font init_font)\r
+               {\r
+                       str_ = init_str;\r
+                       font_ = init_font;\r
+                       align = HorizontalAlign.TEXT_ALIGN_LEFT;\r
+               }\r
+               ~Letters()\r
+               {\r
+               }\r
+               public Font font\r
+               {\r
+                       get { return font_; }\r
+                       set { font_ = value; }\r
+               }\r
+               public Font getFont() { return font; }\r
+               public string str\r
+               {\r
+                       get { return str_; }\r
+                       set { str_ = value; }\r
+               }\r
+               public String getString() { return str; }\r
+               public Figure centering(Point p)\r
+               {\r
+                       datum = p;\r
+                       align = HorizontalAlign.TEXT_ALIGN_CENTER;\r
+                       return this;\r
+               }\r
+               public Figure shift(Point p)\r
+               {\r
+                       return this;\r
+               }\r
+               public Letters locate(Point p)\r
+               {\r
+                       datum = p;\r
+                       return this;\r
+               }\r
+               public Letters locate(double x, double y)\r
+               {\r
+                       datum.set(x,y);\r
+                       return this;\r
+               }\r
+\r
+               public void draw()\r
+               {\r
+                       Main.drawable.letters(this, Color.white);\r
+               }\r
+               public void draw(Color c)\r
+               {\r
+                       Main.drawable.letters(this, c);\r
+               }\r
+       }\r
+\r
+}\r