X-Git-Url: http://git.osdn.jp/view?a=blobdiff_plain;ds=sidebyside;f=test3%2FMainPage.xaml.cs;h=8bb50a00615992205ccdf23a115536a48ed228e2;hb=0d510ea424330e5e8c71dbc4576611e5f256d956;hp=d06eb7a9f23b59f5390cca3a8f1c655ffde8446a;hpb=de61bd82025b7cbad753e4b9ea272705ed47cbf6;p=psychlops%2Fsilverlight.git diff --git a/test3/MainPage.xaml.cs b/test3/MainPage.xaml.cs index d06eb7a..8bb50a0 100644 --- a/test3/MainPage.xaml.cs +++ b/test3/MainPage.xaml.cs @@ -4,14 +4,22 @@ namespace PsychlopsSilverlight3test { public partial class MainPage : System.Windows.Controls.UserControl { - public System.ComponentModel.BackgroundWorker main_routine; + //System.Collections.Generic.IEnumerator main_routine; public System.Windows.Controls.Image master; + public PsychlopsMain main; +#if DEBUG + public System.Windows.Controls.TextBlock DebugConsole; +#endif public MainPage() { InitializeComponent(); - initialize(); // Show fps counter - Canvas.default_instance = image; + //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; @@ -19,65 +27,31 @@ namespace PsychlopsSilverlight3test //main_routine = new System.ComponentModel.BackgroundWorker(); //main_routine.DoWork += new System.ComponentModel.DoWorkEventHandler(psychlops_main); //main_routine.RunWorkerAsync(); + + main = new PsychlopsMain(); + //main.initialize(); + Psychlops.Internal.Main.routine = new System.Threading.Thread(main.psychlops_main); + Psychlops.Internal.Main.routine.Start(); + //main_routine = main.psychlops_main(); +#if DEBUG + DebugConsole = new System.Windows.Controls.TextBlock(); + TotalRoot.Children.Add(DebugConsole); +#endif } - int background; - private void backgroundWorker_DoWork(object sender, System.ComponentModel.DoWorkEventArgs args) - { - while (true) - { - System.Threading.Thread.Sleep(10); - background++; - } + protected void getFocusMouseEnter(object sender, System.Windows.Input.MouseEventArgs e) { + this.Focus(); } - int frame; private void CompositionTarget_Rendering(object sender, System.EventArgs e) { - frame++; - //Canvas.default_buffer.Invalidate(); - trial(); + if (Main.canvas != null) Main.canvas.executeFlip(); + //if (nextIntervalFrame-- <= 0) + //{ + // main_routine.MoveNext(); + // nextIntervalFrame = main_routine.Current; + //} } - Canvas cnvs; - Image img; - int isize = 100; - double tfreq = 1; - public void initialize() - { - cnvs = new Canvas(500, 500, image, this); - img = new Image(isize*2, isize*2); - cnvs.clear(Color.gray); - } - public void trial() - { - cnvs.clear(new Color(Mouse.left.pressed() ? 1.0 : 0.5)); - img.field( - (x, y) => new Color(.5 + Math.gaussian(Math.radius(x - isize, y - isize), isize / 8.0) * .5 * Math.sin(frame*2*Math.PI/tfreq/60 + x / 3.0)) - ); - img.centering(Mouse.position); - //img.shift(1,0); - img.draw(); - cnvs.flip(); - } - /* - 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(); - } - */ } }