X-Git-Url: http://git.osdn.jp/view?a=blobdiff_plain;ds=sidebyside;f=test3%2FMainPage.xaml.cs;h=7aa4b92e753551fe4e05e67d5f02a0a982e3d361;hb=e05ab8e68d381f8f5c9a2ddb7c63b89a7bb6371a;hp=d06eb7a9f23b59f5390cca3a8f1c655ffde8446a;hpb=de61bd82025b7cbad753e4b9ea272705ed47cbf6;p=psychlops%2Fsilverlight.git diff --git a/test3/MainPage.xaml.cs b/test3/MainPage.xaml.cs index d06eb7a..7aa4b92 100644 --- a/test3/MainPage.xaml.cs +++ b/test3/MainPage.xaml.cs @@ -4,80 +4,55 @@ 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_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.Application.Current.Host.Settings.EnableCacheVisualization = false; + // 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(); - } - 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(); - trial(); - } + main = new PsychlopsMain(); + Psychlops.Internal.Main.routine = new System.Threading.Thread(main.psychlops_main); + Psychlops.Internal.Main.routine.Start(); + //main.initialize(); + //main_routine = main.psychlops_main(); - 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); + Psychlops.Internal.Main.statusBar = AppStatusBar; + Psychlops.Internal.Main.widgetStack = Controller; + AppStatusBar.Text = System.Windows.Application.Current.Host.Settings.EnableGPUAcceleration.ToString(); } - 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(); + protected void getFocusMouseEnter(object sender, System.Windows.Input.MouseEventArgs e) { + this.Focus(); } - /* - 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() + private void CompositionTarget_Rendering(object sender, System.EventArgs e) { - cnvs.clear(new Color(Mouse.left.pressed() ? 1.0 : 0.5)); - foreach (Rectangle rect in rects) { rect.centering().shift(background,0).draw(); } - cnvs.flip(); + if (Main.canvas != null) Main.canvas.executeFlip(); + //if (nextIntervalFrame-- <= 0) + //{ + // main_routine.MoveNext(); + // nextIntervalFrame = main_routine.Current; + //} } - */ + } }