}\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
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
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
}\r
public Figure shift(Point p)\r
{\r
+ datum += p;\r
return this;\r
}\r
public Letters locate(Point p)\r
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
{\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
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
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
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
int isize = 100;\r
double tfreq = 1;\r
int frames;\r
+ RandomDots dots;\r
\r
public void psychlops_main()\r
{\r
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
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
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