// 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
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
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
Internal.Main.canvas_flag.WaitOne();\r
}\r
+ #region version modifyNative\r
public void executeFlip()\r
{\r
- #region version modifyNative\r
Line lineS;\r
Rectangle rectS;\r
Ellipse ellipseS;\r
System.Windows.Shapes.Polygon polygonP;\r
System.Windows.Controls.TextBlock lettersP;\r
System.Windows.Controls.Image imageP;\r
- #endregion\r
\r
lock (this)\r
{\r
\r
var en = masterPool.Children.GetEnumerator();\r
bool full = en.MoveNext();\r
- UIElementPoolN = 0;\r
if (nextIntervalFrame <= 0)\r
{\r
if (chacked > 0)\r
{\r
for (int i = 0; i < stackN - 2; i++)\r
{\r
- UIElementPool[UIElementPoolN] = stack[i].poolNative(this);\r
- UIElementPool[UIElementPoolN].Visibility = Visibility.Visible;\r
- UIElementPoolN++;\r
-\r
- #region version modifyNative\r
- /*\r
if (full == false)\r
{\r
masterPool.Children.Add(stack[i].poolNative(this));\r
{\r
if( null != (rectS = stack[i] as Rectangle) )\r
{\r
- if ( null != (rectP = en.Current as System.Windows.Shapes.Rectangle) )\r
+ if (null != (rectP = en.Current as System.Windows.Shapes.Rectangle))\r
{\r
rectS.modifyNative(rectP, this);\r
}\r
}\r
full = en.MoveNext();\r
}\r
- * */\r
- #endregion\r
+ }\r
+ stackN = 0;\r
+ }\r
+ lock (this)\r
+ {\r
+ chacked = 0;\r
+ }\r
+ Psychlops.Internal.Main.canvas_flag.Set();\r
+ }\r
+ }\r
+ System.Threading.Thread.Sleep(0);\r
+ }\r
+ #endregion\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
+ //masterPool.Children.Clear();\r
+ if (stackN > 0)\r
+ {\r
+ for (int i = 0; i < stackN - 2; i++)\r
+ {\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
}\r
System.Threading.Thread.Sleep(0);\r
}\r
-\r
+ #endregion\r
+ */\r
\r
\r
#region Properties\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
+ System.Windows.Controls.Canvas.SetTop(tmp, top);\r
tmp.Visibility = Visibility.Visible;\r
d.ellipsePoolN++;\r
return tmp;\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
+ System.Windows.Controls.Canvas.SetTop(tmp, top);\r
tmp.Visibility = Visibility.Visible;\r
}\r
}\r
tmp.Points.Add(v);\r
}\r
System.Windows.Controls.Canvas.SetLeft(tmp, datum.x);\r
- System.Windows.Controls.Canvas.SetTop(d.rectPool[d.rectPoolN], datum.y);\r
+ System.Windows.Controls.Canvas.SetTop(tmp, datum.y);\r
tmp.Visibility = Visibility.Visible;\r
d.polygonPoolN++;\r
return tmp;\r
tmp.Points.Add(v);\r
}\r
System.Windows.Controls.Canvas.SetLeft(tmp, datum.x);\r
- System.Windows.Controls.Canvas.SetTop(d.rectPool[d.rectPoolN], datum.y);\r
+ System.Windows.Controls.Canvas.SetTop(tmp, datum.y);\r
tmp.Visibility = Visibility.Visible;\r
}\r
\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(d.rectPool[d.rectPoolN], datum.y);\r
+ System.Windows.Controls.Canvas.SetTop(tmp, datum.y);\r
tmp.Visibility = Visibility.Visible;\r
d.lettersPoolN++;\r
return tmp;\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(d.rectPool[d.rectPoolN], datum.y);\r
+ System.Windows.Controls.Canvas.SetTop(tmp, datum.y);\r
tmp.Visibility = Visibility.Visible;\r
}\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(d.rectPool[d.rectPoolN], datum.y);\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
- throw new Exception("Image.modifyNative");\r
tmp.Source = buffer;\r
System.Windows.Controls.Canvas.SetLeft(tmp, datum.x);\r
- System.Windows.Controls.Canvas.SetTop(d.rectPool[d.rectPoolN], datum.y);\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<Figure> func);\r
+ public void append__(Shape fig)\r
+ {\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
void polygon(Polygon drawee);\r
void letters(Letters drawee);\r
void image(Image drawee);\r
+ void group(Group drawee);\r
void msg(string s, double x, double y, Color c);\r
}\r
\r
UIElement poolNative(Canvas c);\r
}\r
}\r
+\r
+ public partial class Group : Internal.PrimitiveFigure\r
+ {\r
+ System.Collections.Generic.List<Figure> list;\r
+ System.Windows.Controls.Canvas cnvs;\r
+ bool AsyncBool;\r
+ public double rotation;\r
+ Point axis, scaling;\r
+\r
+ public Group()\r
+ {\r
+ list = new System.Collections.Generic.List<Figure>();\r
+ AsyncBool = false;\r
+ initialize__();\r
+ while (!AsyncBool) { }\r
+ }\r
+ public Group append(Figure fig)\r
+ {\r
+ list.Add(fig);\r
+ return this;\r
+ }\r
+\r
+ public Point datum { get; set; }\r
+ public Figure shift(Point p)\r
+ {\r
+ datum = datum + p;\r
+ return this;\r
+ }\r
+ public Figure centering(Point p)\r
+ {\r
+ datum = p;\r
+ return this;\r
+ }\r
+ public void draw()\r
+ {\r
+ Main.drawable.group(this);\r
+ }\r
+ }\r
+\r
}
\ No newline at end of file
namespace Psychlops\r
{\r
\r
+ /*\r
+ class Widget : public Figure {\r
+ public:\r
+ class Event {\r
+ public:\r
+ };\r
+ };\r
+ * */\r
+\r
namespace Widgets\r
{\r
+ /*\r
+ struct Theme {\r
+ static bool initialized__;\r
+ static Image default_button, default_horiz_grad;\r
+ enum TYPE_TAG { NORMAL, ALERT };\r
+ public:\r
+ Color normal_foreground[2], active_foreground[2];\r
+ Color normal_background[2], active_background[2], over_background[2];\r
+ Stroke normal_stroke[2], active_stroke[2];\r
+ Image button_back, *horiz_grad;\r
+\r
+ static Theme current;\r
+ static void initialize();\r
+ };\r
+ * */\r
+\r
+ /*\r
+ class WidgetRect : Widget\r
+ {\r
+ protected:\r
+ HumanInterfaceDevice::ButtonStateHolder mleft;\r
+ bool pushed_;\r
+\r
+ public:\r
+ //Theme *theme;\r
+ //Theme::TYPE_TAG theme_type;\r
+ public Rectangle area;\r
+ public Letters label;\r
+\r
+ public abstract WidgetRect();\r
+ public virtual const Point getDatum() const;\r
+ public virtual WidgetRect& setDatum(const Point&);\r
+ public virtual WidgetRect& centering(const Point&);\r
+ public double getWidth() const;\r
+ public double getHeight() const;\r
+ public double getLeft() const;\r
+ public double getTop() const;\r
+ public double getRight() const;\r
+ public double getBottom() const;\r
+ public WidgetRect& alignLeft(const double lef);\r
+ public WidgetRect& alignTop(const double to_);\r
+ public WidgetRect& alignRight(const double rig);\r
+ public WidgetRect& alignBottom(const double bot);\r
+\r
+ public virtual WidgetRect& set(double wid, double hei);\r
+ public virtual WidgetRect& set(std::wstring name);\r
+ public virtual WidgetRect& set(std::wstring name, double hei);\r
+ public virtual WidgetRect& setLabel(std::wstring s);\r
+ public virtual WidgetRect& draw(Drawable &target = *Drawable::prime);\r
+ public bool pushed();\r
+ public WidgetRect& pushThis();\r
+ };\r
+ */\r
+ /*\r
+ public class Slider\r
+ {\r
+ public Rectangle outer;\r
+ }\r
+ */\r
\r
public class Slider\r
{\r
</StackPanel>\r
<Canvas x:Name="LayoutRoot" Grid.Column="1"></Canvas>\r
</Grid>\r
- <TextBlock x:Name="AppStatusBar" Height="20">Status OK</TextBlock>\r
+ <TextBlock x:Name="AppStatusBar" Height="20">Loading...</TextBlock>\r
</StackPanel>\r
</UserControl>\r
//main_routine.RunWorkerAsync();\r
\r
main = new PsychlopsMain();\r
+// Psychlops.AppState.statusBar.\r
Psychlops.Internal.Main.routine = new System.Threading.Thread(main.psychlops_main);\r
Psychlops.Internal.Main.routine.Start();\r
//main.initialize();\r
\r
Psychlops.Internal.Main.statusBar = AppStatusBar;\r
Psychlops.Internal.Main.widgetStack = Controller;\r
- AppStatusBar.Text = System.Windows.Application.Current.Host.Settings.EnableGPUAcceleration.ToString();\r
+ AppStatusBar.Text = "Now starting Psychlops environment... please wait a minute";\r
}\r
protected void getFocusMouseEnter(object sender, System.Windows.Input.MouseEventArgs e) {\r
this.Focus();\r
-\r
-/*\r
-using Psychlops;\r
+using Psychlops;\r
\r
namespace PsychlopsSilverlight4test\r
{\r
- \r
\r
public class PsychlopsMain\r
{\r
\r
- Canvas cnvs;\r
+ Psychlops.Canvas cnvs;\r
int i;\r
- object xxx;\r
double x, y, z, t, p, temp, xx, yy;\r
\r
//Set Target Initial Value\r
\r
//Set Background Initial Value\r
double DotNumber = 50, thetaSpeed = 3.0, Axis = 0.0, BGRadii = 150, BGSize = 5.0;\r
- Psychlops.Widgets.Slider DotNumberS;\r
\r
public void psychlops_main()\r
{\r
- //DotNumberS = new Psychlops.Widgets.Slider("test", new Interval(10, 500));\r
- //Independent ind = new Independent();\r
-\r
cnvs = new Canvas(500, 500);\r
\r
- Image img = new Image(100, 100);\r
- img.field(delegate(int x, int y) { return new Color(0.5 + 0.5 * Math.sin(x + y)); });\r
- Image img2 = new Image(100, 100);\r
- img2.field(delegate(int x, int y) { return new Color(0.5 + 0.5 * Math.sin(x + y)); });\r
- /*\r
- for (int x = 0; x < 20; x++)\r
- {\r
- for (int y = 0; y < 20; y++)\r
- {\r
-// img.pix(x, y, new Color(Math.sin(x + y)));\r
- }\r
- }\r
-\r
-\r
//Declare background dots and target\r
Rectangle[] BGDot = new Rectangle[2048];\r
for(int i=0; i<2048; i++){\r
for(int i=0; i<10; i++)Target[i].set(TargetSize, TargetSize);\r
\r
double COS, SIN;\r
- DotNumber = 100;\r
+ DotNumber = 200;\r
//Main stimulus loop\r
while(true){\r
//Clear the main window\r
//Set Dotsize and Draw them\r
BGDot[i].set(BGSize, BGSize);\r
BGDot[i].centering().shift(xx,yy);\r
- BGDot[i].draw( Color.blue);\r
+ BGDot[i].draw( Color.blue );\r
}\r
\r
//Calculate positions of targets and set them\r
temp=Rotate*2*Math.PI/360.0;\r
- cnvs.msg(TargetNumber.ToString(), 0, 30);\r
for (int i = 0; i < 5; i++)\r
{\r
- cnvs.msg(i.ToString(), 50+50*i, 30);\r
t = 2.0 * Math.PI/TargetNumber;\r
- x = 10.0 * i;//TargetEcce*Math.cos(i*t+temp);\r
- y = 10.0 * i;//TargetEcce*Math.sin(i*t+temp);\r
+ x = TargetEcce*Math.cos(i*t+temp);\r
+ y = TargetEcce*Math.sin(i*t+temp);\r
Target[i].centering().shift(x,y);\r
Target[i].fill = Color.yellow;\r
Target[i].draw();\r
}\r
\r
- img.centering().draw();\r
- img2.centering().draw();\r
//Reflect drawing at the next frame;\r
cnvs.flip();\r
}\r
\r
}\r
\r
-\r
/*\r
using Psychlops;\r
\r
\r
}\r
\r
-\r
- * \r
- * */\r
+*/\r
\r
\r
+/*\r
using Psychlops;\r
\r
namespace Psychlops\r
\r
\r
\r
-\r
namespace PsychlopsSilverlight4test\r
{\r
\r
\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, 30, 30, 20, 1, 2, frames * 2.0 * Math.PI / tfreq / 60);\r
+ Figures.drawGrating(ref img, 200, 200, 20, 1, 2, frames * 2.0 * Math.PI / tfreq / 60);\r
img.centering(Mouse.position);\r
img.draw();\r
\r
shape.draw();\r
if (Keyboard.spc.pressed()) cnvs.var(Mouse.x, 100, 100);\r
\r
- cnvs.var(frames, 20, 20);\r
+ cnvs.var(frames, 0, 20);\r
slider.value = frames / 100.0;\r
\r
fixation.shift(100, 100);\r
}\r
\r
}\r
+*/\r