--- a/src/FingersDance/MainSurfaceWindow.xaml.cs Tue Oct 13 19:09:46 2009 +0200
+++ b/src/FingersDance/MainSurfaceWindow.xaml.cs Tue Oct 13 19:33:13 2009 +0200
@@ -17,6 +17,9 @@
using FingersDance.Control.UserPanel;
using FingersDance.Control.Screen;
+using FingersDance.Control.Close;
+using FingersDance.ViewModels;
+using FingersDance.Data;
namespace FingersDance
@@ -31,14 +34,18 @@
/// </summary>
///
#region Variables
+
private UserControlUserPanel Panel1 = null;
private UserControlUserPanel Panel2 = null;
private UserControlUserPanel Panel3 = null;
private UserControlUserPanel Panel4 = null;
+ ActionFactory.ActionGenerator _Factory = new FingersDance.ActionFactory.ActionFactory().GetGenerator();
+ private MainViewModel _mainviewmodel = new MainViewModel();
+
#endregion
- ActionFactory.ActionGenerator _Factory = new FingersDance.ActionFactory.ActionFactory().GetGenerator();
+ #region Constructor
public SurfaceWindow1()
{
InitializeComponent();
@@ -50,6 +57,9 @@
// Add handlers for Application activation events
AddActivationHandlers();
}
+ #endregion
+
+ #region Initialization
private void InitPivotInertia()
{
@@ -82,6 +92,7 @@
catch (Exception ex) { }
}
+ #endregion
/// <summary>
/// Occurs when the window is about to close.
@@ -125,6 +136,7 @@
private void OnApplicationActivated(object sender, EventArgs e)
{
//TODO: enable audio, animations here
+
}
/// <summary>
@@ -149,6 +161,29 @@
//TODO: disable audio, animations here
}
+ /// <summary>
+ /// This is called when application has been loaded, we change the orientation
+ /// of the application
+ /// </summary>
+ /// <param name="sender"></param>
+ /// <param name="e"></param>
+ private void mainSurfaceWindow_Loaded(object sender, RoutedEventArgs e)
+ {
+
+ if (ApplicationLauncher.InitialOrientation == UserOrientation.Top)
+ {
+ // Rotate the main canvas by 180 degrees.
+ this.MainGrid.LayoutTransform = new RotateTransform(180.0);
+ }
+ else
+ {
+ // Remove the rotate transform on the main canvas.
+ this.MainGrid.LayoutTransform = null;
+ }
+ // Dismiss the loading screen.
+ ApplicationLauncher.SignalApplicationLoadComplete();
+ }
+
private void scaterview_ContactChanged(object sender, ContactEventArgs e)
{ }
@@ -228,13 +263,18 @@
private void UserControlPivot_EH_SurfaceButtonPlayer_ContactDown(object sender, EventArgs e)
{
+ // Si aucune video n'a été sélectionnée et qu'une grid contient un élément (listvideo), on ne fait rien
+ if (_mainviewmodel.Session.VideoPath.Equals("") && (Grid1.Children.Count == 2 || Grid2.Children.Count == 2 || Grid3.Children.Count == 2 || Grid4.Children.Count == 2))
+ return;
+
+ // Traitement du contact down sur le pivot (Création d'un screen ou suppression d'un panel
switch ((int)sender)
{
case 1:
- if (Panel1 == null)
+ if (Panel1 == null && Grid1.Children.Count == 1)
{
//1-Creation du control Screen
- UserControlScreen Screen = new UserControlScreen(1);
+ UserControlScreen Screen = new UserControlScreen(1, _mainviewmodel);
Screen.Name = "Screen1";
Screen.contexteGrid = Grid1.Name.ToString();
//2-Rajout du screen dans la grid correspondante
@@ -242,12 +282,22 @@
Screen.UC_Screen_NewSession += new System.EventHandler(this.SessionInput_EH_SurfaceButtonSubmit_ContactDown);
}
+ else //Affichage du message de confirmation
+ {
+ if (Panel1 != null && Grid1.Children.Count == 2)
+ {
+ UserControlClose UCclose = new UserControlClose(1);
+ UCclose.Name = "CloseAlert1";
+ Grid1.Children.Add(UCclose);
+ UCclose.EH_SurfaceButtonClose_ContactDown += new EventHandler(CloseAlert_EH_SurfaceButton_ContactDown);
+ }
+ }
break;
case 2:
- if (Panel2 == null)
+ if (Panel2 == null && Grid2.Children.Count == 1)
{
//1-Creation du control Screen
- UserControlScreen Screen = new UserControlScreen(2);
+ UserControlScreen Screen = new UserControlScreen(2, _mainviewmodel);
Screen.Name = "Screen2";
Screen.contexteGrid = Grid2.Name.ToString();
//2-Rajout du screen dans la grid correspondante
@@ -255,12 +305,22 @@
Screen.UC_Screen_NewSession += new System.EventHandler(this.SessionInput_EH_SurfaceButtonSubmit_ContactDown);
}
+ else //Affichage du message de confirmation
+ {
+ if (Panel2 != null && Grid2.Children.Count == 2)
+ {
+ UserControlClose UCclose = new UserControlClose(2);
+ UCclose.Name = "CloseAlert2";
+ Grid2.Children.Add(UCclose);
+ UCclose.EH_SurfaceButtonClose_ContactDown += new EventHandler(CloseAlert_EH_SurfaceButton_ContactDown);
+ }
+ }
break;
case 3:
- if (Panel3 == null)
+ if (Panel3 == null && Grid3.Children.Count == 1)
{
//1-Creation du control Screen
- UserControlScreen Screen = new UserControlScreen(3);
+ UserControlScreen Screen = new UserControlScreen(3, _mainviewmodel);
Screen.Name = "Screen3";
Screen.contexteGrid = Grid3.Name.ToString();
//2-Rajout du screen dans la grid correspondante
@@ -268,12 +328,22 @@
Screen.UC_Screen_NewSession += new System.EventHandler(this.SessionInput_EH_SurfaceButtonSubmit_ContactDown);
}
+ else //Affichage du message de confirmation
+ {
+ if (Panel3 != null && Grid3.Children.Count == 2)
+ {
+ UserControlClose UCclose = new UserControlClose(3);
+ UCclose.Name = "CloseAlert3";
+ Grid3.Children.Add(UCclose);
+ UCclose.EH_SurfaceButtonClose_ContactDown += new EventHandler(CloseAlert_EH_SurfaceButton_ContactDown);
+ }
+ }
break;
case 4:
- if (Panel4 == null)
+ if (Panel4 == null && Grid4.Children.Count == 1)
{
//1-Creation du control Screen
- UserControlScreen Screen = new UserControlScreen(4);
+ UserControlScreen Screen = new UserControlScreen(4, _mainviewmodel);
Screen.Name = "Screen4";
Screen.contexteGrid = Grid4.Name.ToString();
//2-Rajout du screen dans la grid correspondante
@@ -281,6 +351,16 @@
Screen.UC_Screen_NewSession += new System.EventHandler(this.SessionInput_EH_SurfaceButtonSubmit_ContactDown);
}
+ else //Affichage du message de confirmation
+ {
+ if (Panel4 != null && Grid4.Children.Count == 2)
+ {
+ UserControlClose UCclose = new UserControlClose(4);
+ UCclose.Name = "CloseAlert4";
+ Grid4.Children.Add(UCclose);
+ UCclose.EH_SurfaceButtonClose_ContactDown += new EventHandler(CloseAlert_EH_SurfaceButton_ContactDown);
+ }
+ }
break;
}
@@ -295,28 +375,33 @@
Grid root = (Grid)(((UserControlScreen)sender).Parent);
root.Children.Remove(((UserControlScreen)sender));
//2-Creation du User Panel
+ Project newProject = _mainviewmodel.CreateProject(((UserControlScreen)sender).User);
+
+ if ((Panel1 != null && Panel1.Project.Equals(newProject)) || (Panel2 != null && Panel2.Project.Equals(newProject)) || (Panel3 != null && Panel3.Project.Equals(newProject)) || (Panel4 != null && Panel4.Project.Equals(newProject)))
+ return;
+
switch (((UserControlScreen)sender).id)
{
case 1:
- Panel1 = new UserControlUserPanel(((UserControlScreen)sender).Path);
+ Panel1 = new UserControlUserPanel(newProject, _mainviewmodel.Session.VideoPath);
Panel1.Name = "UserPanel1";
//3-Rajout sur la Grid Root
root.Children.Add(Panel1);
break;
case 2:
- Panel2 = new UserControlUserPanel(((UserControlScreen)sender).Path);
+ Panel2 = new UserControlUserPanel(newProject, _mainviewmodel.Session.VideoPath);
Panel2.Name = "UserPanel2";
//3-Rajout sur la Grid Root
root.Children.Add(Panel2);
break;
case 3:
- Panel3 = new UserControlUserPanel(((UserControlScreen)sender).Path);
+ Panel3 = new UserControlUserPanel(newProject, _mainviewmodel.Session.VideoPath);
Panel3.Name = "UserPanel3";
//3-Rajout sur la Grid Root
root.Children.Add(Panel3);
break;
case 4:
- Panel4 = new UserControlUserPanel(((UserControlScreen)sender).Path);
+ Panel4 = new UserControlUserPanel(newProject, _mainviewmodel.Session.VideoPath);
Panel4.Name = "UserPanel4";
//3-Rajout sur la Grid Root
root.Children.Add(Panel4);
@@ -326,7 +411,38 @@
catch (Exception ex) { }
}
+ //Actions du boutton Alert selon l'action close OK ou NON
+ private void CloseAlert_EH_SurfaceButton_ContactDown(object sender, EventArgs e)
+ {
+ Grid root = (Grid)(((UserControlClose)sender).Parent);
+ if(((UserControlClose) sender).close)
+ {
+ switch(((UserControlClose)sender).Id)
+ {
+ case 1:
+ root.Children.Remove(Panel1);
+ Panel1 = null;
+ break;
+ case 2:
+ root.Children.Remove(Panel2);
+ Panel2 = null;
+ break;
+ case 3:
+ root.Children.Remove(Panel3);
+ Panel3 = null;
+ break;
+ case 4:
+ root.Children.Remove(Panel4);
+ Panel4 = null;
+ break;
+ }
+ }
+ root.Children.Remove(((UserControlClose)sender));
+ // S'il ne reste aucun panel d'ouvert, on ferme la session
+ if (Panel1 == null && Panel2 == null && Panel3 == null && Panel4 == null)
+ _mainviewmodel.CloseSession();
+ }
}
}
\ No newline at end of file