src/FingersDance/MainSurfaceWindow.xaml.cs
changeset 152 46577fd0a294
parent 150 569925b65604
child 156 e16c8c913c65
--- 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) { }