# HG changeset patch # User sarias # Date 1253026665 -7200 # Node ID b4008a356f90da0be11ca8299e19a183c623dce3 # Parent 1043e7c13ffc8988fb96da930211397e05dbd3bc Resolution Inertie du Pivot. Creation des Events pour les bouttons du Pivot diff -r 1043e7c13ffc -r b4008a356f90 src/FingersDance.Control.Pivot/UserControlPivot.xaml --- a/src/FingersDance.Control.Pivot/UserControlPivot.xaml Tue Sep 15 16:09:45 2009 +0200 +++ b/src/FingersDance.Control.Pivot/UserControlPivot.xaml Tue Sep 15 16:57:45 2009 +0200 @@ -38,8 +38,8 @@ - - + + @@ -49,7 +49,7 @@ - + @@ -59,7 +59,7 @@ - + diff -r 1043e7c13ffc -r b4008a356f90 src/FingersDance.Control.Pivot/UserControlPivot.xaml.cs --- a/src/FingersDance.Control.Pivot/UserControlPivot.xaml.cs Tue Sep 15 16:09:45 2009 +0200 +++ b/src/FingersDance.Control.Pivot/UserControlPivot.xaml.cs Tue Sep 15 16:57:45 2009 +0200 @@ -12,11 +12,60 @@ { public partial class UserControlPivot { + public event EventHandler EH_SurfaceButtonPlayer1_ContactDown; + public event EventHandler EH_SurfaceButtonPlayer2_ContactDown; + public event EventHandler EH_SurfaceButtonPlayer3_ContactDown; + public event EventHandler EH_SurfaceButtonPlayer4_ContactDown; + public UserControlPivot() { this.InitializeComponent(); // Insert code required on object creation below this point. } + + private void SurfaceButtonPlayer1_ContactDown(object sender, Microsoft.Surface.Presentation.ContactEventArgs e) + { + if(EH_SurfaceButtonPlayer1_ContactDown!=null) + EH_SurfaceButtonPlayer1_ContactDown(this, new EventArgs()); + } + + private void SurfaceButtonPlayer2_ContactDown(object sender, Microsoft.Surface.Presentation.ContactEventArgs e) + { + if (EH_SurfaceButtonPlayer2_ContactDown != null) + EH_SurfaceButtonPlayer2_ContactDown(this, new EventArgs()); + } + + private void SurfaceButtonPlayer3_ContactDown(object sender, Microsoft.Surface.Presentation.ContactEventArgs e) + { + if (EH_SurfaceButtonPlayer3_ContactDown != null) + EH_SurfaceButtonPlayer3_ContactDown(this, new EventArgs()); + } + + private void SurfaceButtonPlayer4_ContactDown(object sender, Microsoft.Surface.Presentation.ContactEventArgs e) + { + if (EH_SurfaceButtonPlayer4_ContactDown != null) + EH_SurfaceButtonPlayer4_ContactDown(this, new EventArgs()); + } + + private void SurfaceButtonPlayer1_Click(object sender, RoutedEventArgs e) + { + SurfaceButtonPlayer1_ContactDown(this,null); + } + + private void SurfaceButtonPlayer2_Click(object sender, RoutedEventArgs e) + { + SurfaceButtonPlayer2_ContactDown(this, null); + } + + private void SurfaceButtonPlayer3_Click(object sender, RoutedEventArgs e) + { + SurfaceButtonPlayer3_ContactDown(this, null); + } + + private void SurfaceButtonPlayer4_Click(object sender, RoutedEventArgs e) + { + SurfaceButtonPlayer4_ContactDown(this, null); + } } } \ No newline at end of file diff -r 1043e7c13ffc -r b4008a356f90 src/FingersDance/MainSurfaceWindow.xaml --- a/src/FingersDance/MainSurfaceWindow.xaml Tue Sep 15 16:09:45 2009 +0200 +++ b/src/FingersDance/MainSurfaceWindow.xaml Tue Sep 15 16:57:45 2009 +0200 @@ -31,10 +31,10 @@ - + - + @@ -43,14 +43,10 @@ - + - - - - - + @@ -60,11 +56,15 @@ - + + + + + - - + + diff -r 1043e7c13ffc -r b4008a356f90 src/FingersDance/MainSurfaceWindow.xaml.cs --- a/src/FingersDance/MainSurfaceWindow.xaml.cs Tue Sep 15 16:09:45 2009 +0200 +++ b/src/FingersDance/MainSurfaceWindow.xaml.cs Tue Sep 15 16:57:45 2009 +0200 @@ -15,6 +15,8 @@ using Microsoft.Surface.Presentation; using Microsoft.Surface.Presentation.Controls; +using FingersDance.Control.UserPanel; + namespace FingersDance { /// @@ -26,6 +28,12 @@ /// Default constructor. /// /// + #region Variables + private bool isCreatedP1 = false; + private bool isCreatedP2 = false; + private bool isCreatedP3 = false; + private bool isCreatedP4 = false; + #endregion ActionFactory.ActionGenerator _Factory = new FingersDance.ActionFactory.ActionFactory().GetGenerator(); @@ -33,12 +41,24 @@ { InitializeComponent(); + //Permet d'initialiser l'inertie du Pivot une fois relaché. + InitPivotInertia(); //Permet d'initialiser les quand Grid à la position initiale du pivot InitGridPositions(); // Add handlers for Application activation events AddActivationHandlers(); } + private void InitPivotInertia() + { + try + { + ScatterViewItem item = (ScatterViewItem)ScaterView.Items.GetItemAt(0); + item.DecelerationRate = double.NaN; + } + catch (Exception ex) { } + } + private void InitGridPositions() { //Initialise les 4 Grids à la positions initiale du Pivot. @@ -135,16 +155,60 @@ 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.Width = e.GetPosition(mainSurfaceWindow).X; Grid3.Height = 768 - e.GetPosition(mainSurfaceWindow).Y; Grid4.Width = 1024 - e.GetPosition(mainSurfaceWindow).X; - Grid4.Height = e.GetPosition(mainSurfaceWindow).Y; + Grid4.Height = 768 - e.GetPosition(mainSurfaceWindow).Y; + + Grid2.Width = 1024 - e.GetPosition(mainSurfaceWindow).X; + Grid2.Height = e.GetPosition(mainSurfaceWindow).Y; } catch (Exception ex) { } } + + private void UserControlPivot_EH_SurfaceButtonPlayer1_ContactDown(object sender, EventArgs e) + { + if (!isCreatedP1) + { + UserControlUserPanel UserPanel1 = new UserControlUserPanel(); + UserPanel1.Name = "UserPanel1"; + Grid1.Children.Add(UserPanel1); + isCreatedP1 = true; + } + } + + private void UserControlPivot_EH_SurfaceButtonPlayer2_ContactDown(object sender, EventArgs e) + { + if (!isCreatedP2) + { + UserControlUserPanel UserPanel2 = new UserControlUserPanel(); + UserPanel2.Name = "UserPanel2"; + Grid2.Children.Add(UserPanel2); + isCreatedP2 = true; + } + } + + private void UserControlPivot_EH_SurfaceButtonPlayer3_ContactDown(object sender, EventArgs e) + { + if (!isCreatedP3) + { + UserControlUserPanel UserPanel3 = new UserControlUserPanel(); + UserPanel3.Name = "UserPanel3"; + Grid3.Children.Add(UserPanel3); + isCreatedP3 = true; + } + } + + private void UserControlPivot_EH_SurfaceButtonPlayer4_ContactDown(object sender, EventArgs e) + { + if (!isCreatedP4) + { + UserControlUserPanel UserPanel4 = new UserControlUserPanel(); + UserPanel4.Name = "UserPanel4"; + Grid4.Children.Add(UserPanel4); + isCreatedP4 = true; + } + } } } \ No newline at end of file