using Psychlops; namespace PsychlopsSilverlight3test { public partial class MainPage : System.Windows.Controls.UserControl { public System.ComponentModel.BackgroundWorker main_routine; public System.Windows.Controls.Image master; public PsychlopsMain main; public MainPage() { InitializeComponent(); // Show fps counter Canvas.default_buffer_frame = main_buffer; Canvas.default_api_canvas = LayoutRoot; Canvas.default_panel = this; this.IsTabStop = true; this.IsEnabled = true; this.MouseEnter += getFocusMouseEnter; System.Windows.Application.Current.Host.Settings.MaxFrameRate = 60; System.Windows.Application.Current.Host.Settings.EnableFrameRateCounter = true; System.Windows.Application.Current.Host.Settings.EnableCacheVisualization = true; System.Windows.Media.CompositionTarget.Rendering += new System.EventHandler(CompositionTarget_Rendering); //main_routine = new System.ComponentModel.BackgroundWorker(); //main_routine.DoWork += new System.ComponentModel.DoWorkEventHandler(psychlops_main); //main_routine.RunWorkerAsync(); main = new PsychlopsMain(); main.initialize(); } protected void getFocusMouseEnter(object sender, System.Windows.Input.MouseEventArgs e) { this.Focus(); } int background; private void backgroundWorker_DoWork(object sender, System.ComponentModel.DoWorkEventArgs args) { while (true) { System.Threading.Thread.Sleep(10); background++; } } int frame; private void CompositionTarget_Rendering(object sender, System.EventArgs e) { frame++; //Canvas.default_buffer.Invalidate(); main.each_frames(); } /* Canvas cnvs; Rectangle[] rects; double tfreq = 1; public void initialize() { cnvs = new Canvas(500, 500, image, this); rects = new Rectangle[100]; for (int i = 0; i < rects.Length; i++) { rects[i] = new Rectangle(10,10); } cnvs.clear(Color.gray); } public void trial() { cnvs.clear(new Color(Mouse.left.pressed() ? 1.0 : 0.5)); foreach (Rectangle rect in rects) { rect.centering().shift(background,0).draw(); } cnvs.flip(); } */ } }