PlayerPause en resize
authorPAMPHILE Jonathan <pamphile@efrei.fr>
Thu, 15 Oct 2009 02:29:22 +0200
changeset 152 46577fd0a294
parent 151 5f011a5ce421
child 153 3636bb5f4b67
PlayerPause en resize
src/FingersDance.Control.Menu/UserControlMenu.xaml.cs
src/FingersDance.Control.Screen/UserControlScreen.xaml.cs
src/FingersDance.Control.SyncSource/UserControlSyncSource.xaml.cs
src/FingersDance.Control.UserPanel/UserControlUserPanel.xaml.cs
src/FingersDance/MainSurfaceWindow.xaml.cs
--- a/src/FingersDance.Control.Menu/UserControlMenu.xaml.cs	Wed Oct 14 17:42:22 2009 +0200
+++ b/src/FingersDance.Control.Menu/UserControlMenu.xaml.cs	Thu Oct 15 02:29:22 2009 +0200
@@ -145,146 +145,5 @@
          {
              MessageBox.Show(((CustomSurfaceButton)sender).Action);
          }
-
-        #region Events
-
-     /*    
-        //Annotation
-        private void ButtonAnnotation_Click(object sender, RoutedEventArgs e)
-        {
-            if (PanelAnnotation.Visibility == Visibility.Collapsed)
-            {
-                PanelAnnotation.Visibility = Visibility.Visible;
-            }
-            else
-            {
-                PanelAnnotation.Visibility = Visibility.Collapsed;
-            }
-        }
-        //Recherche
-        private void ButtonRecherche_ContactDown(object sender, Microsoft.Surface.Presentation.ContactEventArgs e)
-        {
-            if (PanelRecherche.Visibility == Visibility.Collapsed)
-            {
-                PanelRecherche.Visibility = Visibility.Visible;
-            }
-            else
-            {
-                PanelRecherche.Visibility = Visibility.Collapsed;
-            }
-        }           
-        
-        private void ButtonRecherche_Click(object sender, RoutedEventArgs e)
-        {
-            if (PanelRecherche.Visibility == Visibility.Collapsed)
-            {
-                PanelRecherche.Visibility = Visibility.Visible;
-            }
-            else
-            {
-                PanelRecherche.Visibility = Visibility.Collapsed;
-            }
-        }
-        //ChildCine
-        private void ButtonChildCine_ContactDown(object sender, Microsoft.Surface.Presentation.ContactEventArgs e)
-        {
-            if (PanelChildCine.Visibility == Visibility.Collapsed)
-            {
-                PanelChildCine.Visibility = Visibility.Visible;
-            }
-            else
-            {
-                PanelChildCine.Visibility = Visibility.Collapsed;
-            } 
-        }
-
-        private void ButtonChildCine_Click(object sender, RoutedEventArgs e)
-        {
-            if (PanelChildCine.Visibility == Visibility.Collapsed)
-            {
-                PanelChildCine.Visibility = Visibility.Visible;
-            }
-            else
-            {
-                PanelChildCine.Visibility = Visibility.Collapsed;
-            }
-        }
-        //ChildCore
-        private void ButtonChildChore_Click(object sender, RoutedEventArgs e)
-        {
-            if (PanelChildChore.Visibility == Visibility.Collapsed)
-            {
-                PanelChildChore.Visibility = Visibility.Visible;
-            }
-            else
-            {
-                PanelChildChore.Visibility = Visibility.Collapsed;
-            }
-        }
-
-        private void ButtonChildChore_ContactDown(object sender, Microsoft.Surface.Presentation.ContactEventArgs e)
-        {
-            if (PanelChildChore.Visibility == Visibility.Collapsed)
-            {
-                PanelChildChore.Visibility = Visibility.Visible;
-            }
-            else
-            {
-                PanelChildChore.Visibility = Visibility.Collapsed;
-            }
-        }
-        //Child1MouvCam
-        private void ButtonChild1MouvCam_Click(object sender, RoutedEventArgs e)
-        {
-            if (PanelChild1MouvCam.Visibility == Visibility.Collapsed)
-            {
-                PanelChild1MouvCam.Visibility = Visibility.Visible;
-            }
-            else
-            {
-                PanelChild1MouvCam.Visibility = Visibility.Collapsed;
-            }
-        }
-
-        private void ButtonChild1MouvCam_ContactDown(object sender, Microsoft.Surface.Presentation.ContactEventArgs e)
-        {
-            if (PanelChild1MouvCam.Visibility == Visibility.Collapsed)
-            {
-                PanelChild1MouvCam.Visibility = Visibility.Visible;
-            }
-            else
-            {
-                PanelChild1MouvCam.Visibility = Visibility.Collapsed;
-            }
-        }
-        //Child1AxeCam
-        private void buttonChild1AxeCam_Click(object sender, RoutedEventArgs e)
-        {
-            if (PanelChild1AxeCam.Visibility == Visibility.Collapsed)
-            {
-                PanelChild1AxeCam.Visibility = Visibility.Visible;
-            }
-            else
-            {
-                PanelChild1AxeCam.Visibility = Visibility.Collapsed;
-            }
-        }
-
-        private void buttonChild1AxeCam_ContactDown(object sender, Microsoft.Surface.Presentation.ContactEventArgs e)
-        {
-            if (PanelChild1AxeCam.Visibility == Visibility.Collapsed)
-            {
-                PanelChild1AxeCam.Visibility = Visibility.Visible;
-            }
-            else
-            {
-                PanelChild1AxeCam.Visibility = Visibility.Collapsed;
-            }
-        }
-        */
-        
-        #endregion
-
-    
     }
 }
\ No newline at end of file
--- a/src/FingersDance.Control.Screen/UserControlScreen.xaml.cs	Wed Oct 14 17:42:22 2009 +0200
+++ b/src/FingersDance.Control.Screen/UserControlScreen.xaml.cs	Thu Oct 15 02:29:22 2009 +0200
@@ -27,21 +27,30 @@
 
         public UserControlScreen(int id, MainViewModel mvmodel)
         {
-            this.InitializeComponent();
-            this.id = id;
-            MainViewModel = mvmodel;
-            if (MainViewModel.Session.VideoPath.Equals(""))
+            try
             {
-                //1-Creation de la ListVideo
-                UserControlListVideo ListVideo = new UserControlListVideo();
-                ListVideo.Name = "ListVideo1";
-                //2-Ajout de la ListVideo au ControlScreen
-                this.AddToGrid(ListVideo);
-                //3-Creation des Events pour chaque item de la video
-                ListVideo.EH_ItemVideo1_ContactDown += new System.EventHandler(this.ListVideo_EH_ItemVideo_ContactDown);
+                this.InitializeComponent();
+                this.id = id;
+                MainViewModel = mvmodel;
+                if (MainViewModel.Session.VideoPath.Equals(""))
+                {
+                    //1-Creation de la ListVideo
+                    UserControlListVideo ListVideo = new UserControlListVideo();
+                    ListVideo.Name = "ListVideo1";
+                    //2-Ajout de la ListVideo au ControlScreen
+                    this.AddToGrid(ListVideo);
+                    //3-Creation des Events pour chaque item de la video
+                    ListVideo.EH_ItemVideo1_ContactDown += new System.EventHandler(this.ListVideo_EH_ItemVideo_ContactDown);
+                }
+                else
+                    OpenProject();
             }
-            else
-                OpenProject();
+            catch (Exception)
+            {
+                Project = null;
+                if (UC_Screen_NewSession != null)
+                    UC_Screen_NewSession(this, new EventArgs());
+            }
         }
 
         //Rajout un UIElement vers la grid du screen.
@@ -64,7 +73,12 @@
                 LayoutRoot.Children.Remove((UserControlListVideo)sender);
                 OpenSession();
             }
-            catch (Exception ex) { }
+            catch (Exception ex)
+            {
+                Project = null;
+                if (UC_Screen_NewSession != null)
+                    UC_Screen_NewSession(this, new EventArgs());
+            }
         }
 
         private void OpenSession()
@@ -77,7 +91,12 @@
                 LayoutRoot.Children.Add(listSession);
                 listSession.EH_List_ContactDown += new EventHandler(listSession_EH_List_ContactDown);
             }
-            catch (Exception) { }
+            catch (Exception)
+            {
+                Project = null;
+                if (UC_Screen_NewSession != null)
+                    UC_Screen_NewSession(this, new EventArgs());
+            }
         }
 
         private List<Session> LoadSessions(string name)
@@ -117,7 +136,12 @@
                     }
                 }
             }
-            catch (Exception) { }
+            catch (Exception)
+            {
+                Project = null;
+                if (UC_Screen_NewSession != null)
+                    UC_Screen_NewSession(this, new EventArgs());
+            }
         }
 
         private void SessionInput_EH_SurfaceButtonSubmit_ContactDown(object sender, EventArgs e)
@@ -133,7 +157,12 @@
                 LayoutRoot.Children.Remove((UserControlSessionInput)sender);
                 OpenProject();
             }
-            catch (Exception ex) { }
+            catch (Exception ex) 
+            {
+                Project = null;
+                if (UC_Screen_NewSession != null)
+                    UC_Screen_NewSession(this, new EventArgs());
+            }
         }
 
         private void OpenProject()
@@ -145,7 +174,12 @@
                 LayoutRoot.Children.Add(listProjects);
                 listProjects.EH_Item_ContactDown += new EventHandler(listProjects_EH_Item_ContactDown);
             }
-            catch (Exception) { }
+            catch (Exception) 
+            {
+                Project = null;
+                if (UC_Screen_NewSession != null)
+                    UC_Screen_NewSession(this, new EventArgs());
+            }
         }
 
         void listProjects_EH_Item_ContactDown(object sender, EventArgs e)
@@ -172,7 +206,12 @@
                         }
                 }
             }
-            catch (Exception) { }
+            catch (Exception)
+            {
+                Project = null;
+                if (UC_Screen_NewSession != null)
+                    UC_Screen_NewSession(this, new EventArgs());
+            }
         }
 
         void newProject_EH_NewProject_ContactDown(object sender, EventArgs e)
@@ -185,7 +224,12 @@
                 if (UC_Screen_NewSession != null)
                     UC_Screen_NewSession(this, new EventArgs());
             }
-            catch (Exception) { }
+            catch (Exception) 
+            {
+                Project = null;
+                if (UC_Screen_NewSession != null)
+                    UC_Screen_NewSession(this, new EventArgs());
+            }
         }
 	}
 }
\ No newline at end of file
--- a/src/FingersDance.Control.SyncSource/UserControlSyncSource.xaml.cs	Wed Oct 14 17:42:22 2009 +0200
+++ b/src/FingersDance.Control.SyncSource/UserControlSyncSource.xaml.cs	Thu Oct 15 02:29:22 2009 +0200
@@ -79,5 +79,10 @@
         {
             get { return this.UCTimeLine; }
         }
+
+        public void PlayerPause()
+        {
+            UserControlPlayer.playerPause();
+        }
     }
 }
\ No newline at end of file
--- a/src/FingersDance.Control.UserPanel/UserControlUserPanel.xaml.cs	Wed Oct 14 17:42:22 2009 +0200
+++ b/src/FingersDance.Control.UserPanel/UserControlUserPanel.xaml.cs	Thu Oct 15 02:29:22 2009 +0200
@@ -36,5 +36,10 @@
             _Project = p;
             this.UserControlSyncSource.Load(path, intColor);
         }
+
+        public void PlayerPause()
+        {
+            UserControlSyncSource.PlayerPause();
+        }
 	}
 }
\ No newline at end of file
--- a/src/FingersDance/MainSurfaceWindow.xaml.cs	Wed Oct 14 17:42:22 2009 +0200
+++ b/src/FingersDance/MainSurfaceWindow.xaml.cs	Thu Oct 15 02:29:22 2009 +0200
@@ -209,52 +209,76 @@
                 if (Grid1.Width < (1024 / 4) || Grid2.Height < (768 / 4))
                 {
                     try
-                    {Grid1.Children[1].Visibility = Visibility.Hidden;}
+                    {
+                        if (Panel1 != null)
+                            Panel1.PlayerPause();
+                        Grid1.Children[1].Visibility = Visibility.Hidden;
+                    }
                     catch (Exception) { }
                 }
                 else
                 {
                     try
-                    { Grid1.Children[1].Visibility = Visibility.Visible; }
+                    { 
+                        Grid1.Children[1].Visibility = Visibility.Visible; 
+                    }
                     catch (Exception) { }
                 }
                 //Grid2
                 if (Grid2.Width < (1024 / 4) || Grid2.Height < (768 / 4))
                 {
                     try
-                    { Grid2.Children[1].Visibility = Visibility.Hidden; }
+                    {
+                        if (Panel2 != null)
+                            Panel2.PlayerPause();
+                        Grid2.Children[1].Visibility = Visibility.Hidden; 
+                    }
                     catch (Exception) { }
                 }
                 else
                 {
                     try
-                    { Grid2.Children[1].Visibility = Visibility.Visible; }
+                    {
+                        Grid2.Children[1].Visibility = Visibility.Visible; 
+                    }
                     catch (Exception) { }
                 }
                 //Grid3
                 if (Grid3.Width < (1024 / 4) || Grid3.Height < (768 / 4))
                 {
                     try
-                    { Grid3.Children[1].Visibility = Visibility.Hidden; }
+                    {
+                        if (Panel3 != null)
+                            Panel3.PlayerPause();
+                        Grid3.Children[1].Visibility = Visibility.Hidden;
+                    }
                     catch (Exception) { }
                 }
                 else
                 {
                     try
-                    { Grid3.Children[1].Visibility = Visibility.Visible; }
+                    {
+                        Grid3.Children[1].Visibility = Visibility.Visible; 
+                    }
                     catch (Exception) { }
                 }
                 //Grid4
                 if (Grid4.Width < (1024 / 4) || Grid4.Height < (768 / 4))
                 {
                     try
-                    { Grid4.Children[1].Visibility = Visibility.Hidden; }
+                    {
+                        if (Panel4 != null)
+                            Panel4.PlayerPause();
+                        Grid4.Children[1].Visibility = Visibility.Hidden;
+                    }
                     catch (Exception) { }
                 }
                 else
                 {
                     try
-                    { Grid4.Children[1].Visibility = Visibility.Visible; }
+                    { 
+                        Grid4.Children[1].Visibility = Visibility.Visible;
+                    }
                     catch (Exception) { }
                 }
             }
@@ -264,7 +288,7 @@
         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))
+            if (_mainviewmodel.Session.Name.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
@@ -374,38 +398,42 @@
                 //1-Suppression du UC Screen
                 Grid root = (Grid)(((UserControlScreen)sender).Parent);
                 root.Children.Remove(((UserControlScreen)sender));
-                //2-Creation du User Panel
-                Project newProject = ((UserControlScreen)sender).Project.Project;
 
-                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)
+                if (((UserControlScreen)sender).Project != null)
                 {
-                    case 1:
-                        Panel1 = new UserControlUserPanel(1, 0xFF5A0FC8, newProject, _mainviewmodel.Session.VideoPath);
-                        Panel1.Name = "UserPanel1";
-                        //3-Rajout sur la Grid Root
-                        root.Children.Add(Panel1);
-                        break;
-                    case 2:
-                        Panel2 = new UserControlUserPanel(2, 0xFFC80FA0, newProject, _mainviewmodel.Session.VideoPath);
-                        Panel2.Name = "UserPanel2";
-                        //3-Rajout sur la Grid Root
-                        root.Children.Add(Panel2);
-                        break;
-                    case 3:
-                        Panel3 = new UserControlUserPanel(3, 0xFFFFFF00, newProject, _mainviewmodel.Session.VideoPath);
-                        Panel3.Name = "UserPanel3";
-                        //3-Rajout sur la Grid Root
-                        root.Children.Add(Panel3);
-                        break;
-                    case 4:
-                        Panel4 = new UserControlUserPanel(4, 0xFF0096FF, newProject, _mainviewmodel.Session.VideoPath);
-                        Panel4.Name = "UserPanel4";
-                        //3-Rajout sur la Grid Root
-                        root.Children.Add(Panel4);
-                        break;
+                    //2-Creation du User Panel
+                    Project newProject = ((UserControlScreen)sender).Project.Project;
+
+                    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(1, 0xFF5A0FC8, newProject, _mainviewmodel.Session.VideoPath);
+                            Panel1.Name = "UserPanel1";
+                            //3-Rajout sur la Grid Root
+                            root.Children.Add(Panel1);
+                            break;
+                        case 2:
+                            Panel2 = new UserControlUserPanel(2, 0xFFC80FA0, newProject, _mainviewmodel.Session.VideoPath);
+                            Panel2.Name = "UserPanel2";
+                            //3-Rajout sur la Grid Root
+                            root.Children.Add(Panel2);
+                            break;
+                        case 3:
+                            Panel3 = new UserControlUserPanel(3, 0xFFFFFF00, newProject, _mainviewmodel.Session.VideoPath);
+                            Panel3.Name = "UserPanel3";
+                            //3-Rajout sur la Grid Root
+                            root.Children.Add(Panel3);
+                            break;
+                        case 4:
+                            Panel4 = new UserControlUserPanel(4, 0xFF0096FF, newProject, _mainviewmodel.Session.VideoPath);
+                            Panel4.Name = "UserPanel4";
+                            //3-Rajout sur la Grid Root
+                            root.Children.Add(Panel4);
+                            break;
+                    }
                 }
             }
             catch (Exception ex) { }