OSDN Git Service

123
[psychlops/silverlight.git] / dev4 / psychlops / core / graphic / canvas.cs
index 7f6360c..5a1a7c9 100644 (file)
@@ -56,7 +56,7 @@ namespace Psychlops
                                {\r
                                        polygonStack[i] = new Polygon();\r
                                        lettersStack[i] = new Letters();\r
-                                       //imageStack[i] = new Image();\r
+                                       imageStack[i] = new Image(1,1);\r
                                }\r
                        }\r
 \r
@@ -75,7 +75,8 @@ namespace Psychlops
 \r
                        public virtual void line(Line drawee)\r
                        {\r
-//                             stack.Enqueue(drawee.clone());\r
+                               //                              stack.Enqueue(drawee.clone());\r
+                               drawee.copyToStack(this);\r
                        }\r
 \r
                        public virtual void rect(Rectangle drawee)\r
@@ -108,6 +109,10 @@ namespace Psychlops
                                //                              stack.Enqueue(drawee.clone());\r
                                drawee.copyToStack(this);\r
                        }\r
+                       public virtual void group(Group drawee)\r
+                       {\r
+                               drawee.copyToStack(this);\r
+                       }\r
 \r
                        public void msg(string str, double x, double y) { msg(str, x, y, Color.white); }\r
                        public virtual void msg(string dstr, double x, double y, Color col)\r
@@ -133,6 +138,10 @@ namespace Psychlops
                internal int pointPoolN;\r
                internal SolidColorBrush[] brushPool;\r
                internal int brushPoolN;\r
+\r
+               internal System.Windows.UIElement[] UIElementPool;\r
+               internal int UIElementPoolN;\r
+\r
                internal System.Windows.Shapes.Line[] linePool;\r
                internal int linePoolN;\r
                internal System.Windows.Shapes.Rectangle[] rectPool;\r
@@ -141,6 +150,10 @@ namespace Psychlops
                internal int ellipsePoolN;\r
                internal System.Windows.Shapes.Polygon[] polygonPool;\r
                internal int polygonPoolN;\r
+               internal System.Windows.Controls.TextBlock[] lettersPool;\r
+               internal int lettersPoolN;\r
+               internal System.Windows.Controls.Image[] imagePool;\r
+               internal int imagePoolN;\r
 \r
                #region initializer\r
 \r
@@ -171,11 +184,17 @@ namespace Psychlops
                        api_canvas = apicnvs;\r
                        initialize(wid, hei);\r
                }\r
+\r
+               protected bool AsyncInitBool;\r
                protected void initialize(int wid, int hei)\r
                {\r
+                       AsyncInitBool = false;\r
                        width_ = wid;\r
                        height_ = hei;\r
                        api_canvas.Dispatcher.BeginInvoke(new TwoIntProcedure(initialize__), wid, hei);\r
+                       while(!AsyncInitBool)\r
+                       {\r
+                       }\r
                        Mouse._prime = api_canvas;\r
                        Main.drawable = this;\r
                        Main.canvas = this;\r
@@ -183,6 +202,7 @@ namespace Psychlops
                        back_panel = new Rectangle(wid, hei);\r
 \r
                        flipexec = new SimpleProcedure(executeFlip);\r
+                       AppState.statusBar = "";\r
                }\r
                protected void initialize__(int wid, int hei)\r
                {\r
@@ -201,27 +221,47 @@ namespace Psychlops
                        htmlHost.SetStyleAttribute("height", (20+hei).ToString() + "px");\r
                        htmlHost.SetStyleAttribute("margin", "2em auto auto auto");\r
 \r
-\r
+                       UIElementPool = new System.Windows.UIElement[10000];\r
                        pointPool = new System.Windows.Point[10000];\r
                        brushPool = new SolidColorBrush[10000];\r
                        linePool = new System.Windows.Shapes.Line[10000];\r
                        rectPool = new System.Windows.Shapes.Rectangle[10000];\r
+                       ellipsePool = new System.Windows.Shapes.Ellipse[10000];\r
                        for (int i = 0; i < 10000; i++)\r
                        {\r
                                pointPool[i] = new System.Windows.Point();\r
                                brushPool[i] = new SolidColorBrush();\r
                                linePool[i] = new System.Windows.Shapes.Line();\r
                                rectPool[i] = new System.Windows.Shapes.Rectangle();\r
+                               ellipsePool[i] = new System.Windows.Shapes.Ellipse();\r
+                       }\r
+                       polygonPool = new System.Windows.Shapes.Polygon[1000];\r
+                       lettersPool = new System.Windows.Controls.TextBlock[1000];\r
+                       for (int i = 0; i < 1000; i++)\r
+                       {\r
+                               polygonPool[i] = new System.Windows.Shapes.Polygon();\r
+                               lettersPool[i] = new System.Windows.Controls.TextBlock();\r
                        }\r
-                       for (int i = 0; i < 300; i++)\r
+                       imagePool = new System.Windows.Controls.Image[100];\r
+                       for (int i = 0; i < 100; i++)\r
                        {\r
-                               api_canvas.Children.Add(rectStack[i].poolNative(this));\r
-                               api_canvas.Children.Add(rectStack[i].poolNative(this));\r
+                               imagePool[i] = new System.Windows.Controls.Image();\r
                        }\r
 \r
                        masterPool = new System.Windows.Controls.Canvas();\r
                        prevPool = new System.Windows.Controls.Canvas();\r
-//                     masterPool.Children.Add()\r
+                       api_canvas.Children.Add(masterPool);\r
+                       //api_canvas.Children.Remove(Internal.Main.widgetStack);\r
+\r
+                       /*\r
+                       for (int i = 0; i < 10000; i++)\r
+                       {\r
+                               masterPool.Children.Add(UIElementPool[i]);\r
+                       }\r
+                        * */\r
+\r
+\r
+                       AsyncInitBool = true;\r
                }\r
 \r
                #endregion\r
@@ -258,116 +298,170 @@ namespace Psychlops
                public override void clear(Color col)\r
                {\r
                        back_panel.fill = col;\r
-//                     stack.Clear();\r
                        stackN = 0;\r
                        rect(back_panel);\r
                }\r
 \r
                int nextIntervalFrame = 1, chacked = 0;\r
-               /*\r
+               public void flip(int n)\r
+               {\r
+                       flip();\r
+               }\r
                public void flip()\r
                {\r
-                       //api_canvas.Dispatcher.BeginInvoke(flipexec);\r
-                       //flipexec();\r
-                       //System.Threading.Thread.Sleep(System.Threading.Timeout.Infinite);\r
                        lock (this)\r
                        {\r
                                nextIntervalFrame = 1;\r
                                chacked = 1;\r
                        }\r
-//                     pointPoolN = 0;\r
-//                     brushPoolN = 0;\r
-//                     linePoolN = 0;\r
-                       rectPoolN = 0;\r
+                       //pointStackN = 0;\r
+                       //brushStackN = 0;\r
                        lineStackN = 0;\r
                        rectStackN = 0;\r
+                       polygonStackN = 0;\r
+                       ellipseStackN = 0;\r
+                       lettersStackN = 0;\r
+                       imageStackN = 0;\r
+\r
+                       pointPoolN = 0;\r
+                       brushPoolN = 0;\r
+                       linePoolN = 0;\r
+                       rectPoolN = 0;\r
+                       ellipsePoolN = 0;\r
+                       polygonPoolN = 0;\r
+                       lettersPoolN = 0;\r
+                       imagePoolN = 0;\r
+\r
                        Internal.Main.canvas_flag.WaitOne();\r
                }\r
+               #region version modifyNative\r
                public void executeFlip()\r
                {\r
+                       Line lineS;\r
+                       Rectangle rectS;\r
+                       Ellipse ellipseS;\r
+                       Polygon polygonS;\r
+                       Letters lettersS;\r
+                       Image imageS;\r
+                       System.Windows.Shapes.Line lineP;\r
+                       System.Windows.Shapes.Rectangle rectP;\r
+                       System.Windows.Shapes.Ellipse ellipseP;\r
+                       System.Windows.Shapes.Polygon polygonP;\r
+                       System.Windows.Controls.TextBlock lettersP;\r
+                       System.Windows.Controls.Image imageP;\r
+\r
                        lock (this)\r
                        {\r
                                nextIntervalFrame--;\r
                        }\r
+\r
+                       var en = masterPool.Children.GetEnumerator();\r
+                       bool full = en.MoveNext();\r
                        if (nextIntervalFrame <= 0)\r
                        {\r
-                               var rr = new Random();\r
-                               //Psychlops.AppState.statusBar = chacked.ToString();\r
                                if (chacked > 0)\r
                                {\r
-               //                      prevPool.Children.Clear();\r
-                                       var tmp = new System.Windows.Controls.Canvas();\r
-                                       if (stack.Count > 0)\r
-               //                      if (stackN > 0)\r
+                                       //masterPool.Children.Clear();\r
+                                       if (stackN > 0)\r
                                        {\r
-                                               //foreach (UIElement e in api_canvas.Children)\r
-                                               //{\r
-                                               //}\r
-//                                             foreach (Internal.PrimitiveFigure f in stack)\r
                                                for (int i = 0; i < stackN - 2; i++)\r
                                                {\r
-                                                       //                                                      tmp.Children.Add(f.toNative());\r
-//                                                     tmp.Children.Add(f.poolNative(this));\r
-                                                       tmp.Children.Add(stack[i].poolNative(this));\r
-               //                                      System.Windows.Controls.Canvas.SetLeft(api_canvas.Children[i + 1], rectStack[i].left);\r
-               //                                      api_canvas.Children[0] = api_canvas.Children[0];\r
+                                                       if (full == false)\r
+                                                       {\r
+                                                               masterPool.Children.Add(stack[i].poolNative(this));\r
+                                                       }\r
+                                                       else\r
+                                                       {\r
+                                                               if( null != (rectS = stack[i] as Rectangle) )\r
+                                                               {\r
+                                                                       if (null != (rectP = en.Current as System.Windows.Shapes.Rectangle))\r
+                                                                       {\r
+                                                                               rectS.modifyNative(rectP, this);\r
+                                                                       }\r
+                                                               }\r
+                                                               else if (null != (lineS = stack[i] as Line))\r
+                                                               {\r
+                                                                       if (null != (lineP = en.Current as System.Windows.Shapes.Line))\r
+                                                                       {\r
+                                                                               lineS.modifyNative(lineP, this);\r
+                                                                       }\r
+                                                               }\r
+                                                               else if (null != (ellipseS = stack[i] as Ellipse))\r
+                                                               {\r
+                                                                       if (null != (ellipseP = en.Current as System.Windows.Shapes.Ellipse))\r
+                                                                       {\r
+                                                                               ellipseS.modifyNative(ellipseP, this);\r
+                                                                       }\r
+                                                               }\r
+                                                               else if (null != (polygonS = stack[i] as Polygon))\r
+                                                               {\r
+                                                                       if (null != (polygonP = en.Current as System.Windows.Shapes.Polygon))\r
+                                                                       {\r
+                                                                               polygonS.modifyNative(polygonP, this);\r
+                                                                       }\r
+                                                               }\r
+                                                               else if (null != (lettersS = stack[i] as Letters))\r
+                                                               {\r
+                                                                       if (null != (lettersP = en.Current as System.Windows.Controls.TextBlock))\r
+                                                                       {\r
+                                                                               lettersS.modifyNative(lettersP, this);\r
+                                                                       }\r
+                                                               }\r
+                                                               else if (null != (imageS = stack[i] as Image))\r
+                                                               {\r
+                                                                       if (null != (imageP = en.Current as System.Windows.Controls.Image))\r
+                                                                       {\r
+                                                                               imageS.modifyNative(imageP, this);\r
+                                                                       }\r
+                                                               }\r
+                                                               full = en.MoveNext();\r
+                                                       }\r
                                                }\r
                                                stackN = 0;\r
-\r
                                        }\r
-                                       api_canvas.Children.Clear();\r
-                                       api_canvas.Children.Add(tmp);\r
-               //                      stack.Clear();\r
                                        lock (this)\r
                                        {\r
                                                chacked = 0;\r
                                        }\r
                                        Psychlops.Internal.Main.canvas_flag.Set();\r
-               //                      prevPool = tmp;\r
                                }\r
                        }\r
                        System.Threading.Thread.Sleep(0);\r
                }\r
-               */\r
+               #endregion\r
 \r
-               public void flip()\r
-               {\r
-                       lock (this)\r
-                       {\r
-                               nextIntervalFrame = 1;\r
-                               chacked = 1;\r
-                       }\r
-                       //                      pointPoolN = 0;\r
-                       //                      brushPoolN = 0;\r
-                       //                      linePoolN = 0;\r
-                       rectPoolN = 0;\r
-                       lineStackN = 0;\r
-                       rectStackN = 0;\r
-                       Internal.Main.canvas_flag.WaitOne();\r
-               }\r
+               /*\r
+               #region version poolNative 2\r
                public void executeFlip()\r
                {\r
+\r
                        lock (this)\r
                        {\r
                                nextIntervalFrame--;\r
                        }\r
+                       UIElementPoolN = 0;\r
                        if (nextIntervalFrame <= 0)\r
                        {\r
                                if (chacked > 0)\r
                                {\r
-                                       //api_canvas.Children.Clear();\r
-                                       //var tmp = new System.Windows.Controls.Canvas();\r
+                                       //masterPool.Children.Clear();\r
                                        if (stackN > 0)\r
                                        {\r
                                                for (int i = 0; i < stackN - 2; i++)\r
                                                {\r
-                                                       //api_canvas.Children.Add(stack[i].poolNative(this));\r
-                                                       api_canvas.Children.Add(stack[i].poolNative(this));\r
+                                                       UIElementPool[UIElementPoolN] = stack[i].poolNative(this);\r
+                                                       UIElementPool[UIElementPoolN].Visibility = Visibility.Visible;\r
+                                                       UIElementPoolN++;\r
+\r
+                                               }\r
+                                               for (int i = stackN - 2; i < 10000; i++)\r
+                                               {\r
+                                                       UIElementPool[UIElementPoolN] = rectPool[i];\r
+                                                       UIElementPool[UIElementPoolN].Visibility = Visibility.Collapsed;\r
+                                                       UIElementPoolN++;\r
                                                }\r
                                                stackN = 0;\r
                                        }\r
-                                       //api_canvas.Children.Clear();\r
-                                       //api_canvas.Children.Add(tmp);\r
                                        lock (this)\r
                                        {\r
                                                chacked = 0;\r
@@ -377,7 +471,8 @@ namespace Psychlops
                        }\r
                        System.Threading.Thread.Sleep(0);\r
                }\r
-\r
+               #endregion\r
+               */\r
 \r
 \r
                #region Properties\r
@@ -454,6 +549,19 @@ namespace Psychlops
                }\r
                public UIElement toNative() { return this; }\r
 \r
+               public void copyToStack(Templates.StackableDrawable d)\r
+               {\r
+                       var tmp = d.lineStack[d.lineStackN];\r
+                       tmp.begin.x = begin.x;\r
+                       tmp.begin.y = begin.y;\r
+                       tmp.end.x = end.x;\r
+                       tmp.end.y = end.y;\r
+                       tmp.fill = fill;\r
+                       tmp.stroke = stroke;\r
+                       d.stack[d.stackN] = tmp;\r
+                       d.lineStackN++;\r
+                       d.stackN++;\r
+               }\r
                public UIElement poolNative(Canvas d)\r
                {\r
                        var tmp = d.linePool[d.linePoolN];\r
@@ -469,6 +577,18 @@ namespace Psychlops
                        d.linePoolN++;\r
                        return tmp;\r
                }\r
+               public void modifyNative(System.Windows.Shapes.Line tmp, Canvas d)\r
+               {\r
+                       tmp.X1 = begin.x;\r
+                       tmp.Y1 = begin.y;\r
+                       tmp.X2 = end.x;\r
+                       tmp.Y2 = end.y;\r
+                       if (stroke.thick == 0.0) tmp.Stroke = fill;\r
+                       else stroke.apply(tmp);\r
+                       System.Windows.Controls.Canvas.SetLeft(tmp, left);\r
+                       System.Windows.Controls.Canvas.SetTop(tmp, top);\r
+                       tmp.Visibility = Visibility.Visible;\r
+               }\r
        }\r
 \r
        partial class Rectangle\r
@@ -517,6 +637,15 @@ namespace Psychlops
                        d.rectPoolN++;\r
                        return tmp;\r
                }\r
+               public void modifyNative(System.Windows.Shapes.Rectangle tmp, Canvas d)\r
+               {\r
+                       tmp.Width = width;\r
+                       tmp.Height = height;\r
+                       tmp.Fill = fill;\r
+                       System.Windows.Controls.Canvas.SetLeft(tmp, left);\r
+                       System.Windows.Controls.Canvas.SetTop(tmp, top);\r
+                       tmp.Visibility = Visibility.Visible;\r
+               }\r
        }\r
 \r
        partial class Ellipse\r
@@ -548,7 +677,7 @@ namespace Psychlops
                        tmp.ydiameter = ydiameter;\r
                        tmp.fill = fill;\r
                        d.stack[d.stackN] = tmp;\r
-                       d.rectStackN++;\r
+                       d.ellipseStackN++;\r
                        d.stackN++;\r
                }\r
                public UIElement poolNative(Canvas d)\r
@@ -558,10 +687,19 @@ namespace Psychlops
                        tmp.Height = height;\r
                        tmp.Fill = fill;\r
                        System.Windows.Controls.Canvas.SetLeft(tmp, left);\r
-                       System.Windows.Controls.Canvas.SetTop(d.rectPool[d.rectPoolN], top);\r
+                       System.Windows.Controls.Canvas.SetTop(tmp, top);\r
                        tmp.Visibility = Visibility.Visible;\r
                        d.ellipsePoolN++;\r
-                       return this;\r
+                       return tmp;\r
+               }\r
+               public void modifyNative(System.Windows.Shapes.Ellipse tmp, Canvas d)\r
+               {\r
+                       tmp.Width = width;\r
+                       tmp.Height = height;\r
+                       tmp.Fill = fill;\r
+                       System.Windows.Controls.Canvas.SetLeft(tmp, left);\r
+                       System.Windows.Controls.Canvas.SetTop(tmp, top);\r
+                       tmp.Visibility = Visibility.Visible;\r
                }\r
        }\r
 \r
@@ -600,20 +738,35 @@ namespace Psychlops
                        }\r
                        tmp.fill = fill;\r
                        d.stack[d.stackN] = tmp;\r
-                       d.rectStackN++;\r
+                       d.polygonStackN++;\r
                        d.stackN++;\r
                }\r
                public UIElement poolNative(Canvas d)\r
                {\r
                        var tmp = d.polygonPool[d.polygonPoolN];\r
                        tmp.Fill = fill;\r
-                       /*\r
-                       System.Windows.Controls.Canvas.SetLeft(tmp, left);\r
-                       System.Windows.Controls.Canvas.SetTop(d.rectPool[d.rectPoolN], top);\r
-                       */ \r
+                       tmp.Points.Clear();\r
+                       foreach (var v in vertices)\r
+                       {\r
+                               tmp.Points.Add(v);\r
+                       }\r
+                       System.Windows.Controls.Canvas.SetLeft(tmp, datum.x);\r
+                       System.Windows.Controls.Canvas.SetTop(tmp, datum.y);\r
                        tmp.Visibility = Visibility.Visible;\r
                        d.polygonPoolN++;\r
-                       return this;\r
+                       return tmp;\r
+               }\r
+               public void modifyNative(System.Windows.Shapes.Polygon tmp, Canvas d)\r
+               {\r
+                       tmp.Fill = fill;\r
+                       tmp.Points.Clear();\r
+                       foreach (var v in vertices)\r
+                       {\r
+                               tmp.Points.Add(v);\r
+                       }\r
+                       System.Windows.Controls.Canvas.SetLeft(tmp, datum.x);\r
+                       System.Windows.Controls.Canvas.SetTop(tmp, datum.y);\r
+                       tmp.Visibility = Visibility.Visible;\r
                }\r
 \r
        }\r
@@ -675,25 +828,46 @@ namespace Psychlops
 \r
                public void copyToStack(Templates.StackableDrawable d)\r
                {\r
-                       var tmp = d.polygonStack[d.polygonStackN];\r
+                       var tmp = d.lettersStack[d.lettersStackN];\r
+                       tmp.str = str;\r
                        tmp.datum = datum;\r
                        tmp.fill = fill;\r
                        d.stack[d.stackN] = tmp;\r
-                       d.rectStackN++;\r
+                       d.lettersStackN++;\r
                        d.stackN++;\r
                }\r
                public UIElement poolNative(Canvas d)\r
                {\r
-                       /*                      var tmp = d.rectPool[d.rectPoolN];\r
-                                               tmp.Width = width;\r
-                                               tmp.Height = height;\r
-                                               tmp.Fill = fill;\r
-                                               System.Windows.Controls.Canvas.SetLeft(tmp, left);\r
-                                               System.Windows.Controls.Canvas.SetTop(d.rectPool[d.rectPoolN], top);\r
-                                               tmp.Visibility = Visibility.Visible;\r
-                                               d.rectPoolN++;\r
-*/\r
-                       return this;\r
+                       var tmp = d.lettersPool[d.lettersPoolN];\r
+                       tmp.Text = str;\r
+                       tmp.Width = 500;\r
+                       tmp.Height = 500;\r
+                       tmp.FontSize = font.size;\r
+                       //tmp.FontFamily = ,\r
+                       tmp.FontStyle = FONT_STYLE_BRIDGE[font.style];\r
+                       tmp.FontWeight = FONT_WEIGHT_BRIDGE[font.weight];\r
+                       tmp.TextAlignment = LETTERS_H_ALIGN_BRIDGE[align];\r
+                       tmp.Foreground = fill;\r
+                       System.Windows.Controls.Canvas.SetLeft(tmp, datum.x);\r
+                       System.Windows.Controls.Canvas.SetTop(tmp, datum.y);\r
+                       tmp.Visibility = Visibility.Visible;\r
+                       d.lettersPoolN++;\r
+                       return tmp;\r
+               }\r
+               public void modifyNative(System.Windows.Controls.TextBlock tmp, Canvas d)\r
+               {\r
+                       tmp.Text = str;\r
+                       tmp.Width = 500;\r
+                       tmp.Height = 500;\r
+                       tmp.FontSize = font.size;\r
+                       //tmp.FontFamily = ,\r
+                       tmp.FontStyle = FONT_STYLE_BRIDGE[font.style];\r
+                       tmp.FontWeight = FONT_WEIGHT_BRIDGE[font.weight];\r
+                       tmp.TextAlignment = LETTERS_H_ALIGN_BRIDGE[align];\r
+                       tmp.Foreground = fill;\r
+                       System.Windows.Controls.Canvas.SetLeft(tmp, datum.x);\r
+                       System.Windows.Controls.Canvas.SetTop(tmp, datum.y);\r
+                       tmp.Visibility = Visibility.Visible;\r
                }\r
        }\r
 \r
@@ -707,6 +881,7 @@ namespace Psychlops
                internal void create__(int wid, int hei)\r
                {\r
                        buffer = new WriteableBitmap(wid, hei);\r
+                       AsyncBool = true;\r
                }\r
                delegate void FieldFunc1(System.Func<int, int, System.Windows.Media.Color> func);\r
                delegate void FieldFunc2(System.Func<int, int, System.Windows.Media.Color, System.Windows.Media.Color> func);\r
@@ -743,22 +918,102 @@ namespace Psychlops
                }\r
                public UIElement toNative() { return this; }\r
 \r
+               public void copyToStack(Templates.StackableDrawable d)\r
+               {\r
+                       var tmp = d.imageStack[d.imageStackN];\r
+                       tmp.datum = datum;\r
+                       tmp.buffer = buffer;\r
+                       tmp.self_rect = self_rect;\r
+                       d.stack[d.stackN] = tmp;\r
+                       d.imageStackN++;\r
+                       d.stackN++;\r
+               }\r
                public UIElement poolNative(Canvas d)\r
                {\r
-                       /*                      var tmp = d.rectPool[d.rectPoolN];\r
-                                               tmp.Width = width;\r
-                                               tmp.Height = height;\r
-                                               tmp.Fill = fill;\r
-                                               System.Windows.Controls.Canvas.SetLeft(tmp, left);\r
-                                               System.Windows.Controls.Canvas.SetTop(d.rectPool[d.rectPoolN], top);\r
-                                               tmp.Visibility = Visibility.Visible;\r
-                                               d.rectPoolN++;\r
-*/\r
+                       var tmp = d.imagePool[d.imagePoolN];\r
+                       tmp.Source = buffer;\r
+                       System.Windows.Controls.Canvas.SetLeft(tmp, datum.x);\r
+                       System.Windows.Controls.Canvas.SetTop(tmp, datum.y);\r
+                       tmp.Visibility = Visibility.Visible;\r
+                       d.imagePoolN++;\r
                        return this;\r
                }\r
+               public void modifyNative(System.Windows.Controls.Image tmp, Canvas d)\r
+               {\r
+                       tmp.Source = buffer;\r
+                       System.Windows.Controls.Canvas.SetLeft(tmp, datum.x);\r
+                       System.Windows.Controls.Canvas.SetTop(tmp, datum.y);\r
+                       tmp.Visibility = Visibility.Visible;\r
+               }\r
 \r
        }\r
 \r
+\r
+       partial class Group\r
+       {\r
+               internal void initialize__()\r
+               {\r
+                       Canvas.default_api_canvas.Dispatcher.BeginInvoke(new Canvas.SimpleProcedure(create__));\r
+               }\r
+               internal void create__()\r
+               {\r
+                       cnvs = new System.Windows.Controls.Canvas();\r
+                       AsyncBool = true;\r
+               }\r
+               delegate void AppendFunc1(System.Func<Internal.PrimitiveFigure> func);\r
+               public void append__(Internal.PrimitiveFigure fig)\r
+               {\r
+                       cnvs.Children.Add(fig.toNative());\r
+               }\r
+\r
+               public Group clone()\r
+               {\r
+                       return (Group)MemberwiseClone();\r
+               }\r
+\r
+               public static implicit operator System.Windows.Controls.Canvas(Group d)\r
+               {\r
+                       var tmp = new System.Windows.Controls.Canvas();\r
+/*                     foreach (var item in list)\r
+                       {\r
+                               tmp.Children.Add(d.);\r
+                       }\r
+                       System.Windows.Controls.Canvas.SetLeft(tmp, d.datum.x);\r
+                       System.Windows.Controls.Canvas.SetTop(tmp, d.datum.y);\r
+*/                     return tmp;\r
+               }\r
+               public UIElement toNative() { return this; }\r
+\r
+               public void copyToStack(Templates.StackableDrawable d)\r
+               {\r
+/*                     var tmp = d.imageStack[d.imageStackN];\r
+                       tmp.datum = datum;\r
+                       tmp.buffer = buffer;\r
+                       tmp.self_rect = self_rect;\r
+                       d.stack[d.stackN] = tmp;\r
+                       d.imageStackN++;\r
+                       d.stackN++;\r
+*/             }\r
+               public UIElement poolNative(Canvas d)\r
+               {\r
+/*                     var tmp = d.imagePool[d.imagePoolN];\r
+                       tmp.Source = buffer;\r
+                       System.Windows.Controls.Canvas.SetLeft(tmp, datum.x);\r
+                       System.Windows.Controls.Canvas.SetTop(tmp, datum.y);\r
+                       tmp.Visibility = Visibility.Visible;\r
+                       d.imagePoolN++;\r
+*/                     return this;\r
+               }\r
+               public void modifyNative(System.Windows.Controls.Canvas tmp, Canvas d)\r
+               {\r
+/*                     tmp.Source = buffer;\r
+                       System.Windows.Controls.Canvas.SetLeft(tmp, datum.x);\r
+                       System.Windows.Controls.Canvas.SetTop(tmp, datum.y);\r
+                       tmp.Visibility = Visibility.Visible;\r
+*/             }\r
+\r
+       }\r
+       \r
        #endregion\r
 \r
 \r