src/FingersDance.Control.Screen/UserControlScreen.xaml.cs
changeset 186 83615722dbab
parent 182 25b49d4f1635
child 187 b266af50744c
equal deleted inserted replaced
185:9b62e08d6167 186:83615722dbab
    19 	{
    19 	{
    20         public String contexteGrid;
    20         public String contexteGrid;
    21         public int id = 0;
    21         public int id = 0;
    22         public event EventHandler UC_Screen_NewCutting;
    22         public event EventHandler UC_Screen_NewCutting;
    23         public MainViewModel MainViewModel;
    23         public MainViewModel MainViewModel;
    24         public CuttingViewModel Cutting;
    24         public CuttingViewModel CuttingVM;
    25         private List<Project> existingProjects = new List<Project>();
    25         private List<Project> existingProjects = new List<Project>();
    26         User User = new User();
    26         User User = new User();
    27 
    27 
    28         public UserControlScreen(int id, MainViewModel mvmodel)
    28         public UserControlScreen(int id, MainViewModel mvmodel)
    29         {
    29         {
    30             try
    30             try
    31             {
    31             {
    32                 this.InitializeComponent();
    32                 this.InitializeComponent();
    33                 this.id = id;
    33                 this.id = id;
       
    34                 User.Name = "User " + id;
    34                 MainViewModel = mvmodel;
    35                 MainViewModel = mvmodel;
    35                 if (MainViewModel.Project.VideoPath.Equals(""))
    36                 if (MainViewModel.Project.VideoPath.Equals(""))
    36                 {
    37                 {
    37                     //1-Creation de la ListVideo
    38                     //1-Creation de la ListVideo
    38                     UserControlListVideo ListVideo = new UserControlListVideo();
    39                     UserControlListVideo ListVideo = new UserControlListVideo();
    45                 else
    46                 else
    46                     OpenProject();
    47                     OpenProject();
    47             }
    48             }
    48             catch (Exception)
    49             catch (Exception)
    49             {
    50             {
    50                 Cutting = null;
    51                 CuttingVM = null;
    51                 if (UC_Screen_NewCutting != null)
    52                 if (UC_Screen_NewCutting != null)
    52                     UC_Screen_NewCutting(this, new EventArgs());
    53                     UC_Screen_NewCutting(this, new EventArgs());
    53             }
    54             }
    54         }
    55         }
    55 
    56 
    73                 LayoutRoot.Children.Remove((UserControlListVideo)sender);
    74                 LayoutRoot.Children.Remove((UserControlListVideo)sender);
    74                 OpenProjectList();
    75                 OpenProjectList();
    75             }
    76             }
    76             catch (Exception ex)
    77             catch (Exception ex)
    77             {
    78             {
    78                 Cutting = null;
    79                 CuttingVM = null;
    79                 if (UC_Screen_NewCutting != null)
    80                 if (UC_Screen_NewCutting != null)
    80                     UC_Screen_NewCutting(this, new EventArgs());
    81                     UC_Screen_NewCutting(this, new EventArgs());
    81             }
    82             }
    82         }
    83         }
    83 
    84 
    91                 LayoutRoot.Children.Add(listProject);
    92                 LayoutRoot.Children.Add(listProject);
    92                 listProject.EH_List_ContactDown += new EventHandler(listProject_EH_List_ContactDown);
    93                 listProject.EH_List_ContactDown += new EventHandler(listProject_EH_List_ContactDown);
    93             }
    94             }
    94             catch (Exception)
    95             catch (Exception)
    95             {
    96             {
    96                 Cutting = null;
    97                 CuttingVM = null;
    97                 if (UC_Screen_NewCutting != null)
    98                 if (UC_Screen_NewCutting != null)
    98                     UC_Screen_NewCutting(this, new EventArgs());
    99                     UC_Screen_NewCutting(this, new EventArgs());
    99             }
   100             }
   100         }
   101         }
   101 
   102 
   137                     }
   138                     }
   138                 }
   139                 }
   139             }
   140             }
   140             catch (Exception)
   141             catch (Exception)
   141             {
   142             {
   142                 Cutting = null;
   143                 CuttingVM = null;
   143                 if (UC_Screen_NewCutting != null)
   144                 if (UC_Screen_NewCutting != null)
   144                     UC_Screen_NewCutting(this, new EventArgs());
   145                     UC_Screen_NewCutting(this, new EventArgs());
   145             }
   146             }
   146         }
   147         }
   147 
   148 
   152                 //MainViewModel.Project.Alias = ((UserControlSessionInput)sender).Alias;
   153                 //MainViewModel.Project.Alias = ((UserControlSessionInput)sender).Alias;
   153                 //MainViewModel.Project.Email = ((UserControlSessionInput)sender).Email;
   154                 //MainViewModel.Project.Email = ((UserControlSessionInput)sender).Email;
   154                 MainViewModel.Project.Description = ((UserControlSessionInput)sender).Description;
   155                 MainViewModel.Project.Description = ((UserControlSessionInput)sender).Description;
   155                 MainViewModel.Project.Name = ((UserControlSessionInput)sender).SessionName;
   156                 MainViewModel.Project.Name = ((UserControlSessionInput)sender).SessionName;
   156                 
   157                 
       
   158                 
   157                 //2-Suppression UCSession Input
   159                 //2-Suppression UCSession Input
   158                 LayoutRoot.Children.Remove((UserControlSessionInput)sender);
   160                 LayoutRoot.Children.Remove((UserControlSessionInput)sender);
   159                 OpenProject();
   161                 OpenProject();
   160             }
   162             }
   161             catch (Exception ex) 
   163             catch (Exception ex) 
   162             {
   164             {
   163                 Cutting = null;
   165                 CuttingVM = null;
   164                 if (UC_Screen_NewCutting != null)
   166                 if (UC_Screen_NewCutting != null)
   165                     UC_Screen_NewCutting(this, new EventArgs());
   167                     UC_Screen_NewCutting(this, new EventArgs());
   166             }
   168             }
   167         }
   169         }
   168 
   170 
   175                 LayoutRoot.Children.Add(listCuttings);
   177                 LayoutRoot.Children.Add(listCuttings);
   176                 listCuttings.EH_Item_ContactDown += new EventHandler(listCuttings_EH_Item_ContactDown);
   178                 listCuttings.EH_Item_ContactDown += new EventHandler(listCuttings_EH_Item_ContactDown);
   177             }
   179             }
   178             catch (Exception) 
   180             catch (Exception) 
   179             {
   181             {
   180                 Cutting = null;
   182                 CuttingVM = null;
   181                 if (UC_Screen_NewCutting != null)
   183                 if (UC_Screen_NewCutting != null)
   182                     UC_Screen_NewCutting(this, new EventArgs());
   184                     UC_Screen_NewCutting(this, new EventArgs());
   183             }
   185             }
   184         }
   186         }
   185 
   187 
   191                 if (((UserControlListProject)sender).SelectedItem.Equals("New Cutting"))
   193                 if (((UserControlListProject)sender).SelectedItem.Equals("New Cutting"))
   192                 {
   194                 {
   193                     UserControlNewProject newCutting = new UserControlNewProject(User);
   195                     UserControlNewProject newCutting = new UserControlNewProject(User);
   194                     newCutting.Name = "newCutting";
   196                     newCutting.Name = "newCutting";
   195                     LayoutRoot.Children.Add(newCutting);
   197                     LayoutRoot.Children.Add(newCutting);
   196                     newCutting.EH_NewCutting_ContactDown += new EventHandler(newCutting_EH_NewProject_ContactDown);
   198                     newCutting.EH_NewCutting_ContactDown += new EventHandler(newCutting_EH_ContactDown);
   197                 }
   199                 }
   198                 else
   200                 else
   199                 {
   201                 {
   200                     foreach(KeyValuePair<string, Cutting> elt in MainViewModel.Project.CuttingsDict)
   202                     foreach(KeyValuePair<string, Cutting> elt in MainViewModel.Project.CuttingsDict)
   201                         if (elt.Key.Equals(((UserControlListProject)sender).SelectedItem))
   203                         if (elt.Key.Equals(((UserControlListProject)sender).SelectedItem))
   202                         {
   204                         {
   203                             Cutting = new CuttingViewModel(elt.Value, 815);
   205                             CuttingVM = new CuttingViewModel(elt.Value, 815);
   204                             if (UC_Screen_NewCutting != null)
   206                             if (UC_Screen_NewCutting != null)
   205                                 UC_Screen_NewCutting(this, new EventArgs());
   207                                 UC_Screen_NewCutting(this, new EventArgs());
   206                             return;
   208                             return;
   207                         }
   209                         }
   208                 }
   210                 }
   209             }
   211             }
   210             catch (Exception)
   212             catch (Exception)
   211             {
   213             {
   212                 Cutting = null;
   214                 CuttingVM = null;
   213                 if (UC_Screen_NewCutting != null)
   215                 if (UC_Screen_NewCutting != null)
   214                     UC_Screen_NewCutting(this, new EventArgs());
   216                     UC_Screen_NewCutting(this, new EventArgs());
   215             }
   217             }
   216         }
   218         }
   217 
   219 
   218         void newCutting_EH_NewProject_ContactDown(object sender, EventArgs e)
   220         void newCutting_EH_ContactDown(object sender, EventArgs e)
   219         {
   221         {
   220             try
   222             try
   221             {
   223             {
   222                 Console.WriteLine("newCutting_EH_NewProject_ContactDown");
       
   223                 LayoutRoot.Children.Remove((UserControlNewProject)sender);
   224                 LayoutRoot.Children.Remove((UserControlNewProject)sender);
   224                 Cutting = new CuttingViewModel(((UserControlNewProject)sender).Cutting, 850);
   225                 CuttingVM = new CuttingViewModel(((UserControlNewProject)sender).Cutting, 850);
   225                 MainViewModel.Project.CuttingsDict.Add(Cutting.Title, ((UserControlNewProject)sender).Cutting);
   226                 MainViewModel.Project.CuttingsDict.Add(CuttingVM.Title, ((UserControlNewProject)sender).Cutting);
   226                 if (UC_Screen_NewCutting != null)
   227                 if (UC_Screen_NewCutting != null)
   227                     UC_Screen_NewCutting(this, new EventArgs());
   228                     UC_Screen_NewCutting(this, new EventArgs());
   228             }
   229             }
   229             catch (Exception)
   230             catch (Exception)
   230             {
   231             {
   231                 Cutting = null;
   232                 CuttingVM = null;
   232                 if (UC_Screen_NewCutting != null)
   233                 if (UC_Screen_NewCutting != null)
   233                     UC_Screen_NewCutting(this, new EventArgs());
   234                     UC_Screen_NewCutting(this, new EventArgs());
   234             }
   235             }
   235         }
   236         }
   236 	}
   237 	}