OSDN Git Service

456
[psychlops/silverlight.git] / dev4 / psychlops / core / graphic / module.cs
index a53a41a..e55a779 100644 (file)
@@ -4,6 +4,48 @@ using System.Windows;
 \r
 namespace Psychlops\r
 {\r
+       public static class StaticFunctions\r
+       {\r
+               public static T[] NewArray<T>(int x)\r
+                       where T : new()\r
+               {\r
+                       T[] t = new T[x];\r
+                       for (int i = 0; i < x; i++)\r
+                       {\r
+                               t[i] = new T();\r
+                       }\r
+                       return t;\r
+               }\r
+               public static T[,] NewArray<T>(int x, int y)\r
+                       where T : new()\r
+               {\r
+                       T[,] t = new T[x,y];\r
+                       for (int i = 0; i < x; i++)\r
+                       {\r
+                               for (int j = 0; j < x; j++)\r
+                               {\r
+                                       t[i,j] = new T();\r
+                               }\r
+                       }\r
+                       return t;\r
+               }\r
+               public static T[,,] NewArray<T>(int x, int y, int z)\r
+                       where T : new()\r
+               {\r
+                       T[,,] t = new T[x, y, z];\r
+                       for (int i = 0; i < x; i++)\r
+                       {\r
+                               for (int j = 0; j < y; j++)\r
+                               {\r
+                                       for (int k = 0; k < z; k++)\r
+                                       {\r
+                                               t[i, j, k] = new T();\r
+                                       }\r
+                               }\r
+                       }\r
+                       return t;\r
+               }\r
+       }\r
 \r
        public partial struct Point\r
        {\r
@@ -78,9 +120,10 @@ namespace Psychlops
                        yellow = new Color(1, 1, 0, 1),\r
                        magenta = new Color(1, 0, 1, 1),\r
                        cyan = new Color(0, 1, 1, 1),\r
-                       white = new Color(1, 1, 1, 1),\r
                        gray = new Color(.5, .5, .5, 1),\r
-                       null_color = new Color(0, 0, 0, 0);\r
+                       white = new Color(1, 1, 1, 1),\r
+                       null_color = new Color(0, 0, 0, 0),\r
+                       transparent = new Color(0, 0, 0, 0);\r
 \r
        }\r
 \r
@@ -147,20 +190,50 @@ namespace Psychlops
        {\r
                System.Collections.Generic.List<Figure> list;\r
                System.Windows.Controls.Canvas cnvs;\r
+               System.Windows.Media.TransformGroup trans;\r
+               System.Windows.Media.TransformCollection transF;\r
+               System.Windows.Media.RotateTransform rotateF;\r
+               SimpleProcedure setRotation_;\r
+               System.Windows.Media.ScaleTransform scaleF;\r
+               SimpleProcedure setScaling_;\r
+               System.Windows.Media.TranslateTransform translateF;\r
+\r
                bool AsyncBool;\r
-               public double rotation;\r
-               Point axis, scaling;\r
+               double rotation_;\r
+               public double rotation\r
+               {\r
+                       get { return rotation_; }\r
+                       set { rotation_ = value; rotateF.Dispatcher.BeginInvoke(setRotation_); }\r
+               }               \r
+               public Point axis\r
+               {\r
+                       get;\r
+                       set;\r
+               }\r
+               Point scaling_;\r
+               public Point scaling\r
+               {\r
+                       get { return scaling_; }\r
+                       set { scaling_ = value; scaleF.Dispatcher.BeginInvoke(setScaling_); }\r
+               }\r
+\r
+               AppendFunc1 append_;\r
 \r
                public Group()\r
                {\r
+                       setRotation_ = new SimpleProcedure(setRotation__);\r
+                       setScaling_ = new SimpleProcedure(setScaling__);\r
+                       append_ = new AppendFunc1(append__);\r
                        list = new System.Collections.Generic.List<Figure>();\r
                        AsyncBool = false;\r
                        initialize__();\r
                        while (!AsyncBool) { }\r
                }\r
-               public Group append(Figure fig)\r
+\r
+               public Group append(Internal.PrimitiveFigure fig)\r
                {\r
                        list.Add(fig);\r
+                       cnvs.Dispatcher.BeginInvoke(append_, fig);\r
                        return this;\r
                }\r
 \r