OSDN Git Service

7aa4b92e753551fe4e05e67d5f02a0a982e3d361
[psychlops/silverlight.git] / test4 / MainPage.xaml.cs
1 using Psychlops;\r
2 \r
3 namespace PsychlopsSilverlight3test\r
4 {\r
5         public partial class MainPage : System.Windows.Controls.UserControl\r
6         {\r
7                 //System.Collections.Generic.IEnumerator<int> main_routine;\r
8                 public System.Windows.Controls.Image master;\r
9                 public PsychlopsMain main;\r
10 #if DEBUG\r
11                 public System.Windows.Controls.TextBlock DebugConsole;\r
12 #endif\r
13                 public MainPage()\r
14                 {\r
15                         InitializeComponent();\r
16                         // Show fps counter\r
17 \r
18                         Canvas.default_api_canvas = LayoutRoot;\r
19                         Canvas.default_panel = this;\r
20                         this.IsTabStop = true;\r
21                         this.IsEnabled = true;\r
22                         this.MouseEnter += getFocusMouseEnter;\r
23                         System.Windows.Application.Current.Host.Settings.MaxFrameRate = 60;\r
24                         System.Windows.Application.Current.Host.Settings.EnableFrameRateCounter = true;\r
25                         System.Windows.Application.Current.Host.Settings.EnableCacheVisualization = false;\r
26                         //<param name="enableGPUAcceleration" value="true"/>\r
27                         System.Windows.Media.CompositionTarget.Rendering += new System.EventHandler(CompositionTarget_Rendering);\r
28                         //main_routine =  new System.ComponentModel.BackgroundWorker();\r
29                         //main_routine.DoWork += new System.ComponentModel.DoWorkEventHandler(psychlops_main);\r
30                         //main_routine.RunWorkerAsync();\r
31 \r
32                         main = new PsychlopsMain();\r
33                         Psychlops.Internal.Main.routine = new System.Threading.Thread(main.psychlops_main);\r
34                         Psychlops.Internal.Main.routine.Start();\r
35                         //main.initialize();\r
36                         //main_routine = main.psychlops_main();\r
37 \r
38                         Psychlops.Internal.Main.statusBar = AppStatusBar;\r
39                         Psychlops.Internal.Main.widgetStack = Controller;\r
40                         AppStatusBar.Text = System.Windows.Application.Current.Host.Settings.EnableGPUAcceleration.ToString();\r
41                 }\r
42                 protected void getFocusMouseEnter(object sender, System.Windows.Input.MouseEventArgs e) {\r
43                         this.Focus();\r
44                 }\r
45 \r
46                 private void CompositionTarget_Rendering(object sender, System.EventArgs e)\r
47                 {\r
48                         if (Main.canvas != null) Main.canvas.executeFlip();\r
49                         //if (nextIntervalFrame-- <= 0)\r
50                         //{\r
51                         //      main_routine.MoveNext();\r
52                         //      nextIntervalFrame = main_routine.Current;\r
53                         //}\r
54                 }\r
55 \r
56         }\r
57 }\r
58 \r