src/FingersDance/MainSurfaceWindow.xaml.cs
changeset 146 dd8ed4d3beb6
parent 141 923687896770
parent 143 9f157d9c725b
child 148 c379899e9c94
equal deleted inserted replaced
145:42cf4dbc473b 146:dd8ed4d3beb6
    16 using Microsoft.Surface.Presentation.Controls;
    16 using Microsoft.Surface.Presentation.Controls;
    17 
    17 
    18 using FingersDance.Control.UserPanel;
    18 using FingersDance.Control.UserPanel;
    19 using FingersDance.Control.Screen;
    19 using FingersDance.Control.Screen;
    20 using FingersDance.Control.Close;
    20 using FingersDance.Control.Close;
       
    21 using FingersDance.ViewModels;
       
    22 using FingersDance.Data;
    21 
    23 
    22 
    24 
    23 namespace FingersDance
    25 namespace FingersDance
    24 {
    26 {
    25     /// <summary>
    27     /// <summary>
    30         /// <summary>
    32         /// <summary>
    31         /// Default constructor.
    33         /// Default constructor.
    32         /// </summary>
    34         /// </summary>
    33         /// 
    35         /// 
    34         #region Variables
    36         #region Variables
       
    37 
    35         private UserControlUserPanel Panel1 = null;
    38         private UserControlUserPanel Panel1 = null;
    36         private UserControlUserPanel Panel2 = null;
    39         private UserControlUserPanel Panel2 = null;
    37         private UserControlUserPanel Panel3 = null;
    40         private UserControlUserPanel Panel3 = null;
    38         private UserControlUserPanel Panel4 = null;
    41         private UserControlUserPanel Panel4 = null;
       
    42         ActionFactory.ActionGenerator _Factory = new FingersDance.ActionFactory.ActionFactory().GetGenerator();
       
    43         private MainViewModel _mainviewmodel = new MainViewModel();      
       
    44 
    39         #endregion
    45         #endregion
    40 
    46 
    41         ActionFactory.ActionGenerator _Factory = new FingersDance.ActionFactory.ActionFactory().GetGenerator();
    47 
    42 
    48         #region Constructor
    43         public SurfaceWindow1()
    49         public SurfaceWindow1()
    44         {
    50         {
    45             InitializeComponent();
    51             InitializeComponent();
    46 
    52 
    47             //Permet d'initialiser l'inertie du Pivot une fois relaché.
    53             //Permet d'initialiser l'inertie du Pivot une fois relaché.
    49             //Permet d'initialiser les quand Grid à la position initiale du pivot
    55             //Permet d'initialiser les quand Grid à la position initiale du pivot
    50             InitGridPositions();
    56             InitGridPositions();
    51             // Add handlers for Application activation events
    57             // Add handlers for Application activation events
    52             AddActivationHandlers();
    58             AddActivationHandlers();
    53         }
    59         }
       
    60         #endregion
       
    61 
       
    62         #region Initialization
    54 
    63 
    55         private void InitPivotInertia()
    64         private void InitPivotInertia()
    56         {
    65         {
    57             try
    66             try
    58             {
    67             {
    81                 Grid4.Height = item.Center.Y;
    90                 Grid4.Height = item.Center.Y;
    82             }
    91             }
    83             catch (Exception ex) { }
    92             catch (Exception ex) { }
    84         }
    93         }
    85 
    94 
       
    95         #endregion
    86 
    96 
    87         /// <summary>
    97         /// <summary>
    88         /// Occurs when the window is about to close. 
    98         /// Occurs when the window is about to close. 
    89         /// </summary>
    99         /// </summary>
    90         /// <param name="e"></param>
   100         /// <param name="e"></param>
   251             catch (Exception) { }
   261             catch (Exception) { }
   252         }
   262         }
   253 
   263 
   254         private void UserControlPivot_EH_SurfaceButtonPlayer_ContactDown(object sender, EventArgs e)
   264         private void UserControlPivot_EH_SurfaceButtonPlayer_ContactDown(object sender, EventArgs e)
   255         {
   265         {
       
   266             //  Si aucune video n'a été sélectionnée et qu'une grid contient un élément (listvideo), on ne fait rien
       
   267             if (_mainviewmodel.Session.VideoPath.Equals("") && (Grid1.Children.Count == 2 || Grid2.Children.Count == 2 || Grid3.Children.Count == 2 || Grid4.Children.Count == 2))
       
   268                 return;
       
   269 
       
   270             //  Traitement du contact down sur le pivot (Création d'un screen ou suppression d'un panel
   256             switch ((int)sender)
   271             switch ((int)sender)
   257             {
   272             {
   258                 case 1:
   273                 case 1:
   259                     if (Panel1 == null && Grid1.Children.Count == 1)
   274                     if (Panel1 == null && Grid1.Children.Count == 1)
   260                     {
   275                     {
   261                         //1-Creation du control Screen
   276                         //1-Creation du control Screen
   262                         UserControlScreen Screen = new UserControlScreen(1);
   277                         UserControlScreen Screen = new UserControlScreen(1, _mainviewmodel);
   263                         Screen.Name = "Screen1";
   278                         Screen.Name = "Screen1";
   264                         Screen.contexteGrid = Grid1.Name.ToString();
   279                         Screen.contexteGrid = Grid1.Name.ToString();
   265                         //2-Rajout du screen dans la grid correspondante
   280                         //2-Rajout du screen dans la grid correspondante
   266                         Grid1.Children.Add(Screen);
   281                         Grid1.Children.Add(Screen);
   267 
   282 
   280                     break;
   295                     break;
   281                 case 2:
   296                 case 2:
   282                     if (Panel2 == null && Grid2.Children.Count == 1)
   297                     if (Panel2 == null && Grid2.Children.Count == 1)
   283                     {
   298                     {
   284                         //1-Creation du control Screen
   299                         //1-Creation du control Screen
   285                         UserControlScreen Screen = new UserControlScreen(2);
   300                         UserControlScreen Screen = new UserControlScreen(2, _mainviewmodel);
   286                         Screen.Name = "Screen2";
   301                         Screen.Name = "Screen2";
   287                         Screen.contexteGrid = Grid2.Name.ToString();
   302                         Screen.contexteGrid = Grid2.Name.ToString();
   288                         //2-Rajout du screen dans la grid correspondante
   303                         //2-Rajout du screen dans la grid correspondante
   289                         Grid2.Children.Add(Screen);
   304                         Grid2.Children.Add(Screen);
   290 
   305 
   303                     break;
   318                     break;
   304                 case 3:
   319                 case 3:
   305                     if (Panel3 == null && Grid3.Children.Count == 1)
   320                     if (Panel3 == null && Grid3.Children.Count == 1)
   306                     {
   321                     {
   307                         //1-Creation du control Screen
   322                         //1-Creation du control Screen
   308                         UserControlScreen Screen = new UserControlScreen(3);
   323                         UserControlScreen Screen = new UserControlScreen(3, _mainviewmodel);
   309                         Screen.Name = "Screen3";
   324                         Screen.Name = "Screen3";
   310                         Screen.contexteGrid = Grid3.Name.ToString();
   325                         Screen.contexteGrid = Grid3.Name.ToString();
   311                         //2-Rajout du screen dans la grid correspondante
   326                         //2-Rajout du screen dans la grid correspondante
   312                         Grid3.Children.Add(Screen);
   327                         Grid3.Children.Add(Screen);
   313 
   328 
   326                     break;
   341                     break;
   327                 case 4:
   342                 case 4:
   328                     if (Panel4 == null && Grid4.Children.Count == 1)
   343                     if (Panel4 == null && Grid4.Children.Count == 1)
   329                     {
   344                     {
   330                         //1-Creation du control Screen
   345                         //1-Creation du control Screen
   331                         UserControlScreen Screen = new UserControlScreen(4);
   346                         UserControlScreen Screen = new UserControlScreen(4, _mainviewmodel);
   332                         Screen.Name = "Screen4";
   347                         Screen.Name = "Screen4";
   333                         Screen.contexteGrid = Grid4.Name.ToString();
   348                         Screen.contexteGrid = Grid4.Name.ToString();
   334                         //2-Rajout du screen dans la grid correspondante
   349                         //2-Rajout du screen dans la grid correspondante
   335                         Grid4.Children.Add(Screen);
   350                         Grid4.Children.Add(Screen);
   336 
   351 
   358             {
   373             {
   359                 //1-Suppression du UC Screen
   374                 //1-Suppression du UC Screen
   360                 Grid root = (Grid)(((UserControlScreen)sender).Parent);
   375                 Grid root = (Grid)(((UserControlScreen)sender).Parent);
   361                 root.Children.Remove(((UserControlScreen)sender));
   376                 root.Children.Remove(((UserControlScreen)sender));
   362                 //2-Creation du User Panel
   377                 //2-Creation du User Panel
       
   378                 Project newProject = _mainviewmodel.CreateProject(((UserControlScreen)sender).User);
       
   379 
       
   380                 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)))
       
   381                     return;
       
   382 
   363                 switch (((UserControlScreen)sender).id)
   383                 switch (((UserControlScreen)sender).id)
   364                 {
   384                 {
   365                     case 1:
   385                     case 1:
   366                         Panel1 = new UserControlUserPanel(((UserControlScreen)sender).Path);
   386                         Panel1 = new UserControlUserPanel(newProject, _mainviewmodel.Session.VideoPath);
   367                         Panel1.Name = "UserPanel1";
   387                         Panel1.Name = "UserPanel1";
   368                         //3-Rajout sur la Grid Root
   388                         //3-Rajout sur la Grid Root
   369                         root.Children.Add(Panel1);
   389                         root.Children.Add(Panel1);
   370                         break;
   390                         break;
   371                     case 2:
   391                     case 2:
   372                         Panel2 = new UserControlUserPanel(((UserControlScreen)sender).Path);
   392                         Panel2 = new UserControlUserPanel(newProject, _mainviewmodel.Session.VideoPath);
   373                         Panel2.Name = "UserPanel2";
   393                         Panel2.Name = "UserPanel2";
   374                         //3-Rajout sur la Grid Root
   394                         //3-Rajout sur la Grid Root
   375                         root.Children.Add(Panel2);
   395                         root.Children.Add(Panel2);
   376                         break;
   396                         break;
   377                     case 3:
   397                     case 3:
   378                         Panel3 = new UserControlUserPanel(((UserControlScreen)sender).Path);
   398                         Panel3 = new UserControlUserPanel(newProject, _mainviewmodel.Session.VideoPath);
   379                         Panel3.Name = "UserPanel3";
   399                         Panel3.Name = "UserPanel3";
   380                         //3-Rajout sur la Grid Root
   400                         //3-Rajout sur la Grid Root
   381                         root.Children.Add(Panel3);
   401                         root.Children.Add(Panel3);
   382                         break;
   402                         break;
   383                     case 4:
   403                     case 4:
   384                         Panel4 = new UserControlUserPanel(((UserControlScreen)sender).Path);
   404                         Panel4 = new UserControlUserPanel(newProject, _mainviewmodel.Session.VideoPath);
   385                         Panel4.Name = "UserPanel4";
   405                         Panel4.Name = "UserPanel4";
   386                         //3-Rajout sur la Grid Root
   406                         //3-Rajout sur la Grid Root
   387                         root.Children.Add(Panel4);
   407                         root.Children.Add(Panel4);
   388                         break;
   408                         break;
   389                 }
   409                 }