OSDN Git Service

slider
authorunknown <hskwk@.(none)>
Mon, 22 Mar 2010 06:32:55 +0000 (15:32 +0900)
committerunknown <hskwk@.(none)>
Mon, 22 Mar 2010 06:32:55 +0000 (15:32 +0900)
dev3/psychlops/core/graphic/canvas.cs
dev3/psychlops/core/graphic/font.cs
dev3/psychlops/core/math/matrix.cs
dev3/psychlops/extention/standard/widget.cs
test3/PsychlopsMain.cs

index bffa5c4..0df4d7b 100644 (file)
@@ -72,10 +72,10 @@ namespace Psychlops
                        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
                        {\r
-                               var let = new Letters(str);\r
-                               let.locate(x, y);\r
-                               let.fill = col;\r
-                               this.letters(let);\r
+                               //var let = new Letters(str);\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
@@ -186,7 +186,7 @@ namespace Psychlops
                        rect(back_panel);\r
                }\r
 \r
-               int nextIntervalFrame = 1;\r
+               int nextIntervalFrame = 1, chacked = 0;\r
                public void flip()\r
                {\r
                        //api_canvas.Dispatcher.BeginInvoke(flipexec);\r
@@ -195,6 +195,7 @@ namespace Psychlops
                        lock (this)\r
                        {\r
                                nextIntervalFrame = 1;\r
+                               chacked = 1;\r
                        }\r
                        Internal.Main.canvas_flag.WaitOne();\r
                }\r
@@ -206,18 +207,26 @@ namespace Psychlops
                        }\r
                        if (nextIntervalFrame <= 0)\r
                        {\r
-                               var tmp = new System.Windows.Controls.Canvas();\r
-                               if (stack.Count > 0)\r
+                               //Psychlops.AppState.statusBar = chacked.ToString();\r
+                               if (chacked > 0)\r
                                {\r
-                                       foreach (Internal.PrimitiveFigure f in stack)\r
+                                       var tmp = new System.Windows.Controls.Canvas();\r
+                                       if (stack.Count > 0)\r
                                        {\r
-                                               tmp.Children.Add(f.toNative());\r
+                                               foreach (Internal.PrimitiveFigure f in stack)\r
+                                               {\r
+                                                       tmp.Children.Add(f.toNative());\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
                                }\r
-                               api_canvas.Children.Clear();\r
-                               api_canvas.Children.Add(tmp);\r
-                               stack.Clear();\r
-                               Psychlops.Internal.Main.canvas_flag.Set();\r
                        }\r
                        System.Threading.Thread.Sleep(0);\r
                }\r
index 2d82293..fa54cb5 100644 (file)
@@ -20,7 +20,7 @@ namespace Psychlops
                public double size;\r
                public int weight;\r
                public Style style;\r
-               public string[] family;\r
+               public string family;\r
 \r
                static Font()\r
                {\r
@@ -31,23 +31,23 @@ namespace Psychlops
                        size = 18;\r
                        weight = (int)Weight.normal;\r
                        style = Style.normal;\r
-                       family = new string[1];\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
+                       //family = new string[1];\r
+                       family = 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
+                       //family = new string[1];\r
+                       family = family_;\r
                }\r
                ~Font()\r
                {\r
@@ -67,9 +67,9 @@ namespace Psychlops
 \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
index e16003e..9bd895f 100644 (file)
@@ -12,10 +12,12 @@ namespace Psychlops
                        set;\r
                }\r
 \r
+               /*\r
                public static Matrix operator +(Matrix m, double d)\r
                {\r
-                       return new MatrixExpression;\r
+                       return new Internal.MatrixExpression();\r
                }\r
+               */\r
        }\r
 \r
 \r
index e68e396..113d114 100644 (file)
@@ -16,26 +16,71 @@ namespace Psychlops
        namespace Widgets\r
        {\r
 \r
-               class Slider\r
+               public class Slider\r
                {\r
-                       double val;\r
-                       public Slider()\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
+\r
+                       public Slider(string l, Interval r)\r
                        {\r
+                               range = r;\r
+                               label = l;\r
+                               Psychlops.Widgets.Connector.stackSlider(this);\r
                        }\r
                        public static implicit operator double(Slider s)\r
                        {\r
-                               return s.val;\r
+                               return s.value;\r
                        }\r
                }\r
 \r
 \r
 \r
 \r
-               internal class Connector\r
+               internal static class Connector\r
                {\r
-                       internal void stackSlider()\r
+                       delegate void StackSlider_(Slider s);\r
+                       internal static void stackSlider(Slider s)\r
                        {\r
+                               Internal.Main.widgetStack.Dispatcher.BeginInvoke(new StackSlider_(stackSlider__), s);\r
                        }\r
+                       static void stackSlider__(Slider ss)\r
+                       {\r
+                               var holder = new System.Windows.Controls.Canvas { Width = 200 };\r
+                               var val = new System.Windows.Controls.TextBox { Width = 100 };\r
+                               System.Windows.Controls.Canvas.SetLeft(val, 100);\r
+                               var slide = new System.Windows.Controls.Slider {\r
+                                               Minimum = ss.range.begin.val, Maximum = ss.range.end.val,\r
+                                               Name = ss.label,\r
+                                               Tag = ss, Width = 200,\r
+                               };\r
+                               System.Windows.Controls.Canvas.SetTop(slide, 25);\r
+                               var b = new System.Windows.Data.Binding {\r
+                                               Path = new PropertyPath("Value"),\r
+                                               Mode = System.Windows.Data.BindingMode.TwoWay,\r
+                                               Source = slide,\r
+                               };\r
+                               val.SetBinding(TextBox.TextProperty, b);\r
+                               //var b2 = new System.Windows.Data.Binding\r
+                               //{\r
+                               //      Path = new PropertyPath("value"),\r
+                               //      Mode = System.Windows.Data.BindingMode.TwoWay,\r
+                               //      Source = ss,\r
+                               //};\r
+                               //val.SetBinding(System.Windows.Controls.Slider.ValueProperty, b2);\r
+                               var label = new System.Windows.Controls.TextBlock { Text = ss.label };\r
+                               System.Windows.Controls.Canvas.SetLeft(label, 3);\r
+                               System.Windows.Controls.Canvas.SetTop(label, 3);\r
+\r
+                               holder.Children.Add(label);\r
+                               holder.Children.Add(slide);\r
+                               holder.Children.Add(val);\r
+                               ss.instance = holder;\r
+                               Internal.Main.widgetStack.Children.Add(ss.instance);\r
+                       }\r
+\r
                }\r
 \r
        }\r
index bef253a..b3f4985 100644 (file)
@@ -29,6 +29,9 @@ namespace PsychlopsSilverlight3test
                        poly.stroke = new Stroke { color = Color.yellow, thick = 1 };\r
                        shape = poly;\r
 \r
+                       var rng = new Interval();\r
+                       var slider = new Psychlops.Widgets.Slider( "tesrt", 0<=rng<=5 );\r
+\r
 \r
                        while(true) {\r
                                frames++;\r
@@ -41,7 +44,7 @@ namespace PsychlopsSilverlight3test
 \r
                                //Figures.drawGabor(ref img, 20, 100, 1, 0, frames * 2.0 * Math.PI / tfreq / 60);\r
                                //Figures.drawGaussian(ref img, 20, 1);\r
-                               Figures.drawGrating(ref img, 300, 300, 20, 1, 2, frames * 2.0 * Math.PI / tfreq / 60);\r
+                               Figures.drawGrating(ref img, 30, 30, 20, 1, 2, frames * 2.0 * Math.PI / tfreq / 60);\r
                                img.centering(Mouse.position);\r
                                img.draw();\r
 \r