OSDN Git Service

123
authorunknown <hskwk@.(none)>
Fri, 26 Mar 2010 01:44:32 +0000 (10:44 +0900)
committerunknown <hskwk@.(none)>
Fri, 26 Mar 2010 01:44:32 +0000 (10:44 +0900)
dev3/psychlops/core/graphic/canvas.cs
dev3/psychlops/core/graphic/font.cs
dev3/psychlops/extention/standard/widget.cs
test3/PsychlopsMain.cs

index 0df4d7b..9dfe031 100644 (file)
@@ -70,12 +70,12 @@ namespace Psychlops
                        }\r
 \r
                        public void msg(string str, double x, double y) { msg(str, x, y, Color.white); }\r
-                       public virtual void msg(string str, double x, double y, Color col)\r
+                       public virtual void msg(string dstr, double x, double y, Color col)\r
                        {\r
-                               //var let = new Letters(str);\r
-                               //let.locate(x, y);\r
-                               //let.fill = col;\r
-                               //this.letters(let);\r
+                               var let = new Letters(dstr);\r
+                               let.locate(x, y);\r
+                               let.fill = col;\r
+                               this.letters(let);\r
                        }\r
                        public void var<Type>(Type val, double x, double y) { msg(val.ToString(), x, y, Color.white); }\r
                        public void var<Type>(Type val, double x, double y, Color col) { msg(val.ToString(), x, y, col); }\r
@@ -380,7 +380,7 @@ namespace Psychlops
                        LETTERS_H_ALIGN_BRIDGE.Add(Letters.HorizontalAlign.left, TextAlignment.Left);\r
                        LETTERS_H_ALIGN_BRIDGE.Add(Letters.HorizontalAlign.center, TextAlignment.Center);\r
                        LETTERS_H_ALIGN_BRIDGE.Add(Letters.HorizontalAlign.right, TextAlignment.Right);\r
-                       LETTERS_H_ALIGN_BRIDGE.Add(Letters.HorizontalAlign.left, TextAlignment.Left);\r
+                       LETTERS_H_ALIGN_BRIDGE.Add(Letters.HorizontalAlign.not_specified, TextAlignment.Left);\r
                }\r
                #endregion\r
                public Letters clone()\r
index fa54cb5..981b478 100644 (file)
@@ -62,14 +62,14 @@ namespace Psychlops
                public Point datum;\r
 \r
                public enum HorizontalAlign { not_specified=-1, left=0, center, right };\r
-               public const HorizontalAlign NOT_SPECIFIED=HorizontalAlign.not_specified, TEXT_ALIGN_LEFT=HorizontalAlign.left, TEXT_ALIGN_CENTER = HorizontalAlign.center, TEXT_ALIGN_RIGHT=HorizontalAlign.right;\r
+               //public const HorizontalAlign NOT_SPECIFIED=HorizontalAlign.not_specified, TEXT_ALIGN_LEFT=HorizontalAlign.left, TEXT_ALIGN_CENTER = HorizontalAlign.center, TEXT_ALIGN_RIGHT=HorizontalAlign.right;\r
                public HorizontalAlign align;\r
 \r
                public Letters()\r
                {\r
-                       //str_ = "";\r
-                       //font = Font.default_font;\r
-                       //align = HorizontalAlign.left;\r
+                       str_ = "";\r
+                       font = Font.default_font;\r
+                       align = HorizontalAlign.left;\r
                }\r
                public Letters(String init_str)\r
                {\r
@@ -106,6 +106,7 @@ namespace Psychlops
                }\r
                public Figure shift(Point p)\r
                {\r
+                       datum += p;\r
                        return this;\r
                }\r
                public Letters locate(Point p)\r
index 113d114..bb540ec 100644 (file)
@@ -19,10 +19,9 @@ namespace Psychlops
                public class Slider\r
                {\r
                        internal System.Windows.UIElement instance;\r
-                       public string label;\r
-                       public Interval range;\r
-                       public double value { get; set; }\r
-                       public bool changed { get; set; }\r
+                       internal System.Windows.Controls.Slider uislider;\r
+                       internal string label;\r
+                       internal Interval range;\r
 \r
                        public Slider(string l, Interval r)\r
                        {\r
@@ -34,6 +33,11 @@ namespace Psychlops
                        {\r
                                return s.value;\r
                        }\r
+                       public double value {\r
+                               get { return uislider.Value; }\r
+                               set { if(uislider!=null) uislider.Dispatcher.BeginInvoke( new Action<System.Windows.Controls.Slider, double>(Connector.sliderSet) , uislider, value ); }\r
+                       }\r
+                       public bool changed { get; set; }\r
                }\r
 \r
 \r
@@ -63,6 +67,7 @@ namespace Psychlops
                                                Source = slide,\r
                                };\r
                                val.SetBinding(TextBox.TextProperty, b);\r
+                               ss.uislider = slide;\r
                                //var b2 = new System.Windows.Data.Binding\r
                                //{\r
                                //      Path = new PropertyPath("value"),\r
@@ -80,6 +85,10 @@ namespace Psychlops
                                ss.instance = holder;\r
                                Internal.Main.widgetStack.Children.Add(ss.instance);\r
                        }\r
+                       public static void sliderSet(System.Windows.Controls.Slider s, double v)\r
+                       {\r
+                               s.Value = v;\r
+                       }\r
 \r
                }\r
 \r
index b3f4985..bbaf192 100644 (file)
@@ -1,5 +1,30 @@
 using Psychlops;\r
 \r
+namespace Psychlops\r
+{\r
+\r
+       public class RandomDots\r
+       {\r
+               Rectangle dot;\r
+               public Point[] cood;\r
+               public RandomDots()\r
+               {\r
+                       cood = new Point[100];\r
+                       dot = new Rectangle(5, 5);\r
+               }\r
+               public void draw()\r
+               {\r
+                       dot.fill = Color.white;\r
+                       foreach (Point p in cood)\r
+                       {\r
+                               dot.centering(p).draw();\r
+                       }\r
+               }\r
+       }\r
+\r
+}\r
+\r
+\r
 namespace PsychlopsSilverlight3test\r
 {\r
 \r
@@ -13,6 +38,7 @@ namespace PsychlopsSilverlight3test
                int isize = 100;\r
                double tfreq = 1;\r
                int frames;\r
+               RandomDots dots;\r
 \r
                public void psychlops_main()\r
                {\r
@@ -20,8 +46,8 @@ namespace PsychlopsSilverlight3test
                        img = new Image(isize * 2, isize * 2);\r
                        fixation = new Rectangle(10, 10);\r
                        fixation.fill = Color.red;\r
-                       var poly = new Rectangle(100, 100);\r
-                       //var poly = new Letters("日本語");\r
+                       //var poly = new Rectangle(100, 100);\r
+                       var poly = new Letters("日本語");\r
                        //var poly = new Polygon(); poly.append(0, 100); poly.append(-100, 0); poly.append(0, -100); poly.append(100, 0);\r
                        //var poly = new Ellipse(100, 100);\r
                        //var poly = new Line(0,0,100, 0);\r
@@ -30,7 +56,9 @@ namespace PsychlopsSilverlight3test
                        shape = poly;\r
 \r
                        var rng = new Interval();\r
-                       var slider = new Psychlops.Widgets.Slider( "tesrt", 0<=rng<=5 );\r
+                       var slider = new Psychlops.Widgets.Slider("tesrt", 0 <= rng <= 5);\r
+\r
+                       dots = new RandomDots();\r
 \r
 \r
                        while(true) {\r
@@ -52,11 +80,18 @@ namespace PsychlopsSilverlight3test
                                shape.draw();\r
                                if (Keyboard.spc.pressed()) cnvs.var(Mouse.x, 100, 100);\r
 \r
-                               cnvs.var(frames, 10, 20);\r
+                               cnvs.var(frames, 20, 20);\r
+                               slider.value = frames/100.0;\r
 \r
                                fixation.shift(100,100);\r
                                fixation.draw(new Stroke(Color.blue, 3));\r
 \r
+                               for (int i=0; i<dots.cood.Length; i++)\r
+                               {\r
+                                       dots.cood[i].set(Math.random(500), Math.random(500));\r
+                               }\r
+                               dots.draw();\r
+\r
                                cnvs.flip();\r
                        }\r
                }\r