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