diff -r 9c6ea1f246da -r f003ae353cd7 src/FingersDance/MainSurfaceWindow.xaml.cs --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/FingersDance/MainSurfaceWindow.xaml.cs Fri Sep 11 10:58:35 2009 +0200 @@ -0,0 +1,122 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Windows; +using System.Windows.Controls; +using System.Windows.Data; +using System.Windows.Documents; +using System.Windows.Input; +using System.Windows.Media; +using System.Windows.Media.Imaging; +using System.Windows.Shapes; +using System.Windows.Threading; +using Microsoft.Surface; +using Microsoft.Surface.Presentation; +using Microsoft.Surface.Presentation.Controls; + +namespace FingersDance +{ + /// + /// Interaction logic for SurfaceWindow1.xaml + /// + public partial class SurfaceWindow1 : SurfaceWindow + { + /// + /// Default constructor. + /// + public SurfaceWindow1() + { + InitializeComponent(); + + // Add handlers for Application activation events + AddActivationHandlers(); + } + + + /// + /// Occurs when the window is about to close. + /// + /// + protected override void OnClosed(EventArgs e) + { + base.OnClosed(e); + + // Remove handlers for Application activation events + RemoveActivationHandlers(); + } + + /// + /// Adds handlers for Application activation events. + /// + private void AddActivationHandlers() + { + // Subscribe to surface application activation events + ApplicationLauncher.ApplicationActivated += OnApplicationActivated; + ApplicationLauncher.ApplicationPreviewed += OnApplicationPreviewed; + ApplicationLauncher.ApplicationDeactivated += OnApplicationDeactivated; + } + + /// + /// Removes handlers for Application activation events. + /// + private void RemoveActivationHandlers() + { + // Unsubscribe from surface application activation events + ApplicationLauncher.ApplicationActivated -= OnApplicationActivated; + ApplicationLauncher.ApplicationPreviewed -= OnApplicationPreviewed; + ApplicationLauncher.ApplicationDeactivated -= OnApplicationDeactivated; + } + + /// + /// This is called when application has been activated. + /// + /// + /// + private void OnApplicationActivated(object sender, EventArgs e) + { + //TODO: enable audio, animations here + } + + /// + /// This is called when application is in preview mode. + /// + /// + /// + private void OnApplicationPreviewed(object sender, EventArgs e) + { + //TODO: Disable audio here if it is enabled + + //TODO: optionally enable animations here + } + + /// + /// This is called when application has been deactivated. + /// + /// + /// + private void OnApplicationDeactivated(object sender, EventArgs e) + { + //TODO: disable audio, animations here + } + + private void ScaterView_ContactChanged(object sender, ContactEventArgs e) + { + try + { + Grid1.Width = e.GetPosition(mainSurfaceWindow).X; + Grid1.Height = e.GetPosition(mainSurfaceWindow).Y; + + Grid2.Width = e.GetPosition(mainSurfaceWindow).X; + Grid2.Height = 768 - e.GetPosition(mainSurfaceWindow).Y; + + Grid3.Width = 1024 - e.GetPosition(mainSurfaceWindow).X; + Grid3.Height = 768 - e.GetPosition(mainSurfaceWindow).Y; + + Grid4.Width = 1024 - e.GetPosition(mainSurfaceWindow).X; + Grid4.Height = e.GetPosition(mainSurfaceWindow).Y; + } + catch (Exception ex) { } + } + } +} \ No newline at end of file