18 public partial class UserControlScreen |
18 public partial class UserControlScreen |
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 private MainViewModel _mainViewModel; |
24 public CuttingViewModel CuttingVM; |
24 public Cutting Cutting; |
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 User.Name = "User " + id; |
35 MainViewModel = mvmodel; |
35 _mainViewModel = mvmodel; |
36 if (MainViewModel.Project.VideoPath.Equals("")) |
36 if (_mainViewModel.Project.VideoPath.Equals("")) |
37 { |
37 { |
38 //1-Creation de la ListVideo |
38 //1-Creation de la ListVideo |
39 UserControlListVideo ListVideo = new UserControlListVideo(); |
39 UserControlListVideo ListVideo = new UserControlListVideo(); |
40 ListVideo.Name = "ListVideo1"; |
40 ListVideo.Name = "ListVideo1"; |
41 //2-Ajout de la ListVideo au ControlScreen |
41 //2-Ajout de la ListVideo au ControlScreen |
67 private void ListVideo_EH_ItemVideo_ContactDown(object sender, EventArgs e) |
67 private void ListVideo_EH_ItemVideo_ContactDown(object sender, EventArgs e) |
68 { |
68 { |
69 try |
69 try |
70 { |
70 { |
71 //1 renseigner la video choisie au screen et créer un nouveau projet à partir de ce chemin vidéo |
71 //1 renseigner la video choisie au screen et créer un nouveau projet à partir de ce chemin vidéo |
72 MainViewModel.CreateProject(((UserControlListVideo)sender).VideoName, ((UserControlListVideo)sender).path); |
72 _mainViewModel.CreateProject(((UserControlListVideo)sender).VideoName, ((UserControlListVideo)sender).path); |
73 //2-Supression du UC List Video |
73 //2-Supression du UC List Video |
74 LayoutRoot.Children.Remove((UserControlListVideo)sender); |
74 LayoutRoot.Children.Remove((UserControlListVideo)sender); |
75 OpenProjectList(); |
75 OpenProjectList(); |
76 } |
76 } |
77 catch (Exception ex) |
77 catch (Exception ex) |
78 { |
78 { |
79 CuttingVM = null; |
79 Cutting = null; |
80 if (UC_Screen_NewCutting != null) |
80 if (UC_Screen_NewCutting != null) |
81 UC_Screen_NewCutting(this, new EventArgs()); |
81 UC_Screen_NewCutting(this, new EventArgs()); |
82 } |
82 } |
83 } |
83 } |
84 |
84 |
85 private void OpenProjectList() |
85 private void OpenProjectList() |
86 { |
86 { |
87 try |
87 try |
88 { |
88 { |
89 existingProjects = LoadProjects(MainViewModel.Project.VideoPath); |
89 existingProjects = LoadProjects(_mainViewModel.Project.VideoPath); |
90 UserControlListProject listProject = new UserControlListProject(existingProjects); |
90 UserControlListProject listProject = new UserControlListProject(existingProjects); |
91 listProject.Name = "ListProject"; |
91 listProject.Name = "ListProject"; |
92 LayoutRoot.Children.Add(listProject); |
92 LayoutRoot.Children.Add(listProject); |
93 listProject.EH_ListProject_ContactDown += new EventHandler(listProject_EH_ListProject_ContactDown); |
93 listProject.EH_ListProject_ContactDown += new EventHandler(listProject_EH_ListProject_ContactDown); |
94 } |
94 } |
95 catch (Exception) |
95 catch (Exception) |
96 { |
96 { |
97 CuttingVM = null; |
97 Cutting = null; |
98 if (UC_Screen_NewCutting != null) |
98 if (UC_Screen_NewCutting != null) |
99 UC_Screen_NewCutting(this, new EventArgs()); |
99 UC_Screen_NewCutting(this, new EventArgs()); |
100 } |
100 } |
101 } |
101 } |
102 |
102 |
129 { |
129 { |
130 foreach (Project elt in existingProjects) |
130 foreach (Project elt in existingProjects) |
131 { |
131 { |
132 if (elt.Name.Equals(((UserControlListProject)sender).SelectedItem)) |
132 if (elt.Name.Equals(((UserControlListProject)sender).SelectedItem)) |
133 { |
133 { |
134 MainViewModel.Project.Project = elt; |
134 _mainViewModel.Project.Project = elt; |
135 OpenProject(); |
135 OpenProject(); |
136 return; |
136 return; |
137 } |
137 } |
138 } |
138 } |
139 } |
139 } |
140 } |
140 } |
141 catch (Exception) |
141 catch (Exception) |
142 { |
142 { |
143 CuttingVM = null; |
143 Cutting = null; |
144 if (UC_Screen_NewCutting != null) |
144 if (UC_Screen_NewCutting != null) |
145 UC_Screen_NewCutting(this, new EventArgs()); |
145 UC_Screen_NewCutting(this, new EventArgs()); |
146 } |
146 } |
147 } |
147 } |
148 |
148 |
150 { |
150 { |
151 try |
151 try |
152 { |
152 { |
153 //MainViewModel.Project.Alias = ((UserControlNewProjectForm)sender).Alias; |
153 //MainViewModel.Project.Alias = ((UserControlNewProjectForm)sender).Alias; |
154 //MainViewModel.Project.Email = ((UserControlNewProjectForm)sender).Email; |
154 //MainViewModel.Project.Email = ((UserControlNewProjectForm)sender).Email; |
155 MainViewModel.Project.Description = ((UserControlNewProjectForm)sender).Description; |
155 _mainViewModel.Project.Description = ((UserControlNewProjectForm)sender).Description; |
156 MainViewModel.Project.Name = ((UserControlNewProjectForm)sender).SessionName; |
156 _mainViewModel.Project.Name = ((UserControlNewProjectForm)sender).SessionName; |
157 |
157 |
158 |
158 |
159 //2-Suppression UCSession Input |
159 //2-Suppression UCSession Input |
160 LayoutRoot.Children.Remove((UserControlNewProjectForm)sender); |
160 LayoutRoot.Children.Remove((UserControlNewProjectForm)sender); |
161 OpenProject(); |
161 OpenProject(); |
162 } |
162 } |
163 catch (Exception ex) |
163 catch (Exception ex) |
164 { |
164 { |
165 CuttingVM = null; |
165 Cutting = null; |
166 if (UC_Screen_NewCutting != null) |
166 if (UC_Screen_NewCutting != null) |
167 UC_Screen_NewCutting(this, new EventArgs()); |
167 UC_Screen_NewCutting(this, new EventArgs()); |
168 } |
168 } |
169 } |
169 } |
170 |
170 |
171 private void OpenProject() |
171 private void OpenProject() |
172 { |
172 { |
173 try |
173 try |
174 { |
174 { |
175 UserControlListCutting listCuttings = new UserControlListCutting(MainViewModel.Project.CuttingsDict); |
175 UserControlListCutting listCuttings = new UserControlListCutting(_mainViewModel.Project.CuttingsDict); |
176 listCuttings.Name = "listCuttings"; |
176 listCuttings.Name = "listCuttings"; |
177 LayoutRoot.Children.Add(listCuttings); |
177 LayoutRoot.Children.Add(listCuttings); |
178 listCuttings.EH_Item_ContactDown += new EventHandler(listCuttings_EH_Item_ContactDown); |
178 listCuttings.EH_Item_ContactDown += new EventHandler(listCuttings_EH_Item_ContactDown); |
179 } |
179 } |
180 catch (Exception) |
180 catch (Exception) |
181 { |
181 { |
182 CuttingVM = null; |
182 Cutting = null; |
183 if (UC_Screen_NewCutting != null) |
183 if (UC_Screen_NewCutting != null) |
184 UC_Screen_NewCutting(this, new EventArgs()); |
184 UC_Screen_NewCutting(this, new EventArgs()); |
185 } |
185 } |
186 } |
186 } |
187 |
187 |
197 LayoutRoot.Children.Add(newCutting); |
197 LayoutRoot.Children.Add(newCutting); |
198 newCutting.EH_NewCuttingForm_ContactDown += new EventHandler(newCutting_EH_ContactDown); |
198 newCutting.EH_NewCuttingForm_ContactDown += new EventHandler(newCutting_EH_ContactDown); |
199 } |
199 } |
200 else |
200 else |
201 { |
201 { |
202 foreach(KeyValuePair<string, Cutting> elt in MainViewModel.Project.CuttingsDict) |
202 foreach(KeyValuePair<string, Cutting> elt in _mainViewModel.Project.CuttingsDict) |
203 if (elt.Key.Equals(((UserControlListCutting)sender).SelectedItem)) |
203 if (elt.Key.Equals(((UserControlListCutting)sender).SelectedItem)) |
204 { |
204 { |
205 CuttingVM = new CuttingViewModel(elt.Value, 815); |
205 Cutting = elt.Value; |
206 if (UC_Screen_NewCutting != null) |
206 if (UC_Screen_NewCutting != null) |
207 UC_Screen_NewCutting(this, new EventArgs()); |
207 UC_Screen_NewCutting(this, new EventArgs()); |
208 return; |
208 return; |
209 } |
209 } |
210 } |
210 } |
211 } |
211 } |
212 catch (Exception) |
212 catch (Exception) |
213 { |
213 { |
214 CuttingVM = null; |
214 Cutting = null; |
215 if (UC_Screen_NewCutting != null) |
215 if (UC_Screen_NewCutting != null) |
216 UC_Screen_NewCutting(this, new EventArgs()); |
216 UC_Screen_NewCutting(this, new EventArgs()); |
217 } |
217 } |
218 } |
218 } |
219 |
219 |
220 void newCutting_EH_ContactDown(object sender, EventArgs e) |
220 void newCutting_EH_ContactDown(object sender, EventArgs e) |
221 { |
221 { |
222 try |
222 try |
223 { |
223 { |
224 LayoutRoot.Children.Remove((UserControlNewCuttingForm)sender); |
224 LayoutRoot.Children.Remove((UserControlNewCuttingForm)sender); |
225 CuttingVM = new CuttingViewModel(((UserControlNewCuttingForm)sender).Cutting, 850); |
225 Cutting = ((UserControlNewCuttingForm)sender).Cutting; |
226 MainViewModel.Project.CuttingsDict.Add(CuttingVM.Title, ((UserControlNewCuttingForm)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; |
|
233 if (UC_Screen_NewCutting != null) |
232 if (UC_Screen_NewCutting != null) |
234 UC_Screen_NewCutting(this, new EventArgs()); |
233 UC_Screen_NewCutting(this, new EventArgs()); |
235 } |
234 } |
236 } |
235 } |
237 } |
236 } |