OSDN Git Service

Merge branch 'master' of git.sourceforge.jp:/gitroot/psychlops/silverlight
[psychlops/silverlight.git] / test4 / PsychlopsMain.cs
1 \r
2 ///+ Prefix\r
3 //// Lines for set up Psychlops environment\r
4 using Psychlops;\r
5 \r
6 namespace PsychlopsSilverlightApp\r
7 {\r
8 \r
9         public class PsychlopsMain\r
10         {///- Prefix\r
11 \r
12                 ///+ Main Routine\r
13                 //// Psychlops runs at the first line of this function psychlops_main().\r
14                 public void psychlops_main()\r
15                 {\r
16                         ///+ 1\r
17                         //// Set a window for drawing stimulus\r
18                         Canvas window = new Canvas(300, 300); //Create a window. Here, window variables are preset mode.\r
19                         // You can write this statement as" Canvas window = new Canvas(Canvas.fullscreen); " for fullscreen mode\r
20                         // or as " Canvas window = new Canvas(1024, 768, 32, 60.0); " This statement changes screenmode to 1024 x 768, 32bit color, 60 Hz refresh.\r
21                         ///- 1\r
22 \r
23                         var FIGURE = Psychlops.Widgets.Browser.Element.byID("FIGURE");\r
24                         var SIZE_X = Psychlops.Widgets.Browser.Element.byID("SIZE_X");\r
25                         var SIZE_Y = Psychlops.Widgets.Browser.Element.byID("SIZE_Y");\r
26                         var SHIFT_X = Psychlops.Widgets.Browser.Element.byID("SHIFT_X");\r
27                         var SHIFT_Y = Psychlops.Widgets.Browser.Element.byID("SHIFT_Y");\r
28                         var COLOR_R = Psychlops.Widgets.Browser.Element.byID("COLOR_R");\r
29                         var COLOR_G = Psychlops.Widgets.Browser.Element.byID("COLOR_G");\r
30                         var COLOR_B = Psychlops.Widgets.Browser.Element.byID("COLOR_B");\r
31 \r
32 \r
33                         ///+ 2\r
34                         ////  Set a figure size, position and color.\r
35                         Rectangle figure = new Rectangle();\r
36                         Ellipse figure2 = new Ellipse();\r
37 \r
38                         window.flip(); // Reflect the drawing for the display by flipping frame buffers.\r
39                         // Till this point, you will not see drawn figures.\r
40                         ///- 2\r
41 \r
42                         ///+ 3 \r
43                         //// Detect a Keyboard input\r
44                         while (!Keyboard.esc.pushed())\r
45                         {\r
46 \r
47                                 window.clear();\r
48 \r
49                                 if ("Rectangle".Equals(FIGURE))\r
50                                 {\r
51                                         figure.set(SIZE_X, SIZE_Y); // Set the size of figure.\r
52                                         figure.centering();   // Centering the figure in the window\r
53                                         figure.shift(SHIFT_X, SHIFT_Y); // Displacing the figure by designated vector.    \r
54                                         figure.draw(new Color(COLOR_R, COLOR_G, COLOR_B)); // Drawing the rectangle with a designated color.\r
55                                 }\r
56                                 else\r
57                                 {\r
58                                         figure2.set(SIZE_X, SIZE_Y); // Set the size of figure.\r
59                                         figure2.centering();   // Centering the figure in the window\r
60                                         figure2.shift(SHIFT_X, SHIFT_Y); // Displacing the figure by designated vector.    \r
61                                         figure2.draw(new Color(COLOR_R, COLOR_G, COLOR_B)); // Drawing the rectangle with a designated color.\r
62                                 }\r
63 \r
64                                 window.flip();\r
65 \r
66                         } //exit a program when the escape key is pressed down.\r
67                         ///- 3\r
68 \r
69                 }\r
70                 ///- Main Routine\r
71 \r
72         }\r
73 \r
74 }\r
75 \r
76 \r