18 { |
19 { |
19 public String contexteGrid; |
20 public String contexteGrid; |
20 public int id = 0; |
21 public int id = 0; |
21 public event EventHandler UC_Screen_NewSession; |
22 public event EventHandler UC_Screen_NewSession; |
22 public MainViewModel MainViewModel; |
23 public MainViewModel MainViewModel; |
23 public User User = new User(); |
24 public ProjectViewModel Project = new ProjectViewModel(); |
|
25 List<Session> sessions = new List<Session>(); |
|
26 User User = new User(); |
24 |
27 |
25 public UserControlScreen(int id, MainViewModel mvmodel) |
28 public UserControlScreen(int id, MainViewModel mvmodel) |
26 { |
29 { |
27 this.InitializeComponent(); |
30 this.InitializeComponent(); |
28 this.id = id; |
31 this.id = id; |
29 MainViewModel = mvmodel; |
32 MainViewModel = mvmodel; |
30 |
|
31 if (MainViewModel.Session.VideoPath.Equals("")) |
33 if (MainViewModel.Session.VideoPath.Equals("")) |
32 { |
34 { |
33 //1-Creation de la ListVideo |
35 //1-Creation de la ListVideo |
34 UserControlListVideo ListVideo = new UserControlListVideo(); |
36 UserControlListVideo ListVideo = new UserControlListVideo(); |
35 ListVideo.Name = "ListVideo1"; |
37 ListVideo.Name = "ListVideo1"; |
36 |
|
37 //2-Ajout de la ListVideo au ControlScreen |
38 //2-Ajout de la ListVideo au ControlScreen |
38 this.AddToGrid(ListVideo); |
39 this.AddToGrid(ListVideo); |
39 |
|
40 //3-Creation des Events pour chaque item de la video |
40 //3-Creation des Events pour chaque item de la video |
41 ListVideo.EH_ItemVideo1_ContactDown += new System.EventHandler(this.ListVideo_EH_ItemVideo_ContactDown); |
41 ListVideo.EH_ItemVideo1_ContactDown += new System.EventHandler(this.ListVideo_EH_ItemVideo_ContactDown); |
42 } |
42 } |
43 else |
43 else |
44 ListVideo_EH_ItemVideo_ContactDown(null, null); |
44 OpenProject(); |
45 } |
45 } |
46 |
46 |
47 //Rajout un UIElement vers la grid du screen. |
47 //Rajout un UIElement vers la grid du screen. |
48 public void AddToGrid(UIElement uie) |
48 public void AddToGrid(UIElement uie) |
49 { |
49 { |
54 } |
54 } |
55 } |
55 } |
56 |
56 |
57 private void ListVideo_EH_ItemVideo_ContactDown(object sender, EventArgs e) |
57 private void ListVideo_EH_ItemVideo_ContactDown(object sender, EventArgs e) |
58 { |
58 { |
59 //1-Creation d'une nouvelle seance. |
|
60 UserControlSessionInput SessionInput = new UserControlSessionInput(); |
|
61 SessionInput.Name = "SessionInput"; |
|
62 |
|
63 try |
59 try |
64 { |
60 { |
65 //2-Recuperer la Grid (Layout root du UC screen)qui contient le UCListVideo et l'ajouter. |
61 //1 rensegner la video choisie au screen |
66 |
62 MainViewModel.CreateSession(((UserControlListVideo)sender).VideoName, ((UserControlListVideo)sender).path); |
67 LayoutRoot.Children.Add(SessionInput); |
63 //2-Supression du UC List Video |
68 |
|
69 //2.5 rensegner la video choisie au screen |
|
70 if (sender != null) |
|
71 MainViewModel.CreateSession(((UserControlListVideo)sender).VideoName, ((UserControlListVideo)sender).path); |
|
72 |
|
73 //3-Creation des Events |
|
74 SessionInput.EH_SurfaceButtonSubmit_ContactDown += new System.EventHandler(this.SessionInput_EH_SurfaceButtonSubmit_ContactDown); |
|
75 //4-Supression du UC List Video |
|
76 LayoutRoot.Children.Remove((UserControlListVideo)sender); |
64 LayoutRoot.Children.Remove((UserControlListVideo)sender); |
|
65 OpenSession(); |
77 } |
66 } |
78 catch (Exception ex) { } |
67 catch (Exception ex) { } |
79 } |
68 } |
80 |
69 |
|
70 private void OpenSession() |
|
71 { |
|
72 try |
|
73 { |
|
74 sessions = LoadSessions(MainViewModel.Session.VideoPath); |
|
75 UserControlListSession listSession = new UserControlListSession(sessions); |
|
76 listSession.Name = "ListSession"; |
|
77 LayoutRoot.Children.Add(listSession); |
|
78 listSession.EH_List_ContactDown += new EventHandler(listSession_EH_List_ContactDown); |
|
79 } |
|
80 catch (Exception) { } |
|
81 } |
|
82 |
|
83 private List<Session> LoadSessions(string name) |
|
84 { |
|
85 try |
|
86 { |
|
87 return new List<Session>(); |
|
88 } |
|
89 catch (Exception) |
|
90 { |
|
91 return new List<Session>(); |
|
92 } |
|
93 } |
|
94 |
|
95 void listSession_EH_List_ContactDown(object sender, EventArgs e) |
|
96 { |
|
97 try |
|
98 { |
|
99 LayoutRoot.Children.Remove((UserControlListSession)sender); |
|
100 if (((UserControlListSession)sender).SelectedItem.Equals("New Session")) |
|
101 { |
|
102 UserControlSessionInput SessionInput = new UserControlSessionInput(); |
|
103 SessionInput.Name = "SessionInput"; |
|
104 LayoutRoot.Children.Add(SessionInput); |
|
105 SessionInput.EH_SurfaceButtonSubmit_ContactDown += new System.EventHandler(this.SessionInput_EH_SurfaceButtonSubmit_ContactDown); |
|
106 } |
|
107 else |
|
108 { |
|
109 foreach (Session elt in sessions) |
|
110 { |
|
111 if (elt.Name.Equals(((UserControlListSession)sender).SelectedItem)) |
|
112 { |
|
113 MainViewModel.Session.Projects = elt.Projects; |
|
114 OpenProject(); |
|
115 return; |
|
116 } |
|
117 } |
|
118 } |
|
119 } |
|
120 catch (Exception) { } |
|
121 } |
|
122 |
81 private void SessionInput_EH_SurfaceButtonSubmit_ContactDown(object sender, EventArgs e) |
123 private void SessionInput_EH_SurfaceButtonSubmit_ContactDown(object sender, EventArgs e) |
82 { |
124 { |
83 try |
125 try |
84 { |
126 { |
85 //1-Creation du projet |
127 MainViewModel.Session.Alias = ((UserControlSessionInput)sender).Alias; |
86 User = ((UserControlSessionInput)sender).User; |
128 MainViewModel.Session.Email = ((UserControlSessionInput)sender).Email; |
87 MainViewModel.CreateProject(User); |
129 MainViewModel.Session.Description = ((UserControlSessionInput)sender).Description; |
|
130 MainViewModel.Session.Name = ((UserControlSessionInput)sender).Name; |
|
131 |
88 //2-Suppression UCSession Input |
132 //2-Suppression UCSession Input |
89 LayoutRoot.Children.Remove((UserControlSessionInput)sender); |
133 LayoutRoot.Children.Remove((UserControlSessionInput)sender); |
90 //3-Suppression du UC Screen |
134 OpenProject(); |
91 if(UC_Screen_NewSession!=null) |
|
92 UC_Screen_NewSession(this, new EventArgs()); |
|
93 } |
135 } |
94 catch (Exception ex) { } |
136 catch (Exception ex) { } |
95 } |
137 } |
|
138 |
|
139 private void OpenProject() |
|
140 { |
|
141 try |
|
142 { |
|
143 UserControlListProject listProjects = new UserControlListProject(MainViewModel.Session.Projects); |
|
144 listProjects.Name = "ListProjects"; |
|
145 LayoutRoot.Children.Add(listProjects); |
|
146 listProjects.EH_Item_ContactDown += new EventHandler(listProjects_EH_Item_ContactDown); |
|
147 } |
|
148 catch (Exception) { } |
|
149 } |
|
150 |
|
151 void listProjects_EH_Item_ContactDown(object sender, EventArgs e) |
|
152 { |
|
153 try |
|
154 { |
|
155 LayoutRoot.Children.Remove((UserControlListProject)sender); |
|
156 if (((UserControlListProject)sender).SelectedItem.Equals("New Project")) |
|
157 { |
|
158 UserControlNewProject newProject = new UserControlNewProject(User); |
|
159 newProject.Name = "newProject"; |
|
160 LayoutRoot.Children.Add(newProject); |
|
161 newProject.EH_NewProject_ContactDown += new EventHandler(newProject_EH_NewProject_ContactDown); |
|
162 } |
|
163 else |
|
164 { |
|
165 foreach(KeyValuePair<string, Project> elt in MainViewModel.Session.Projects) |
|
166 if (elt.Key.Equals(((UserControlListProject)sender).SelectedItem)) |
|
167 { |
|
168 Project = new ProjectViewModel(elt.Value); |
|
169 if (UC_Screen_NewSession != null) |
|
170 UC_Screen_NewSession(this, new EventArgs()); |
|
171 return; |
|
172 } |
|
173 } |
|
174 } |
|
175 catch (Exception) { } |
|
176 } |
|
177 |
|
178 void newProject_EH_NewProject_ContactDown(object sender, EventArgs e) |
|
179 { |
|
180 try |
|
181 { |
|
182 LayoutRoot.Children.Remove((UserControlNewProject)sender); |
|
183 Project = new ProjectViewModel(((UserControlNewProject)sender).Project); |
|
184 MainViewModel.Session.Projects.Add(Project.Name, Project.Project); |
|
185 if (UC_Screen_NewSession != null) |
|
186 UC_Screen_NewSession(this, new EventArgs()); |
|
187 } |
|
188 catch (Exception) { } |
|
189 } |
96 } |
190 } |
97 } |
191 } |