35
|
1 |
using System; |
|
2 |
using System.IO; |
|
3 |
using System.Net; |
148
|
4 |
using System.Collections.Generic; |
35
|
5 |
using System.Windows; |
|
6 |
using System.Windows.Controls; |
|
7 |
using System.Windows.Data; |
|
8 |
using System.Windows.Media; |
|
9 |
using System.Windows.Media.Animation; |
|
10 |
using System.Windows.Navigation; |
104
|
11 |
using FingersDance.Control.ListVideo; |
|
12 |
using FingersDance.Control.SessionInput; |
143
|
13 |
using FingersDance.ViewModels; |
|
14 |
using FingersDance.Data; |
35
|
15 |
|
|
16 |
namespace FingersDance.Control.Screen |
|
17 |
{ |
|
18 |
public partial class UserControlScreen |
|
19 |
{ |
82
|
20 |
public String contexteGrid; |
112
|
21 |
public int id = 0; |
104
|
22 |
public event EventHandler UC_Screen_NewSession; |
143
|
23 |
public MainViewModel MainViewModel; |
148
|
24 |
public ProjectViewModel Project = new ProjectViewModel(); |
|
25 |
List<Session> sessions = new List<Session>(); |
|
26 |
User User = new User(); |
95
|
27 |
|
143
|
28 |
public UserControlScreen(int id, MainViewModel mvmodel) |
|
29 |
{ |
|
30 |
this.InitializeComponent(); |
112
|
31 |
this.id = id; |
143
|
32 |
MainViewModel = mvmodel; |
|
33 |
if (MainViewModel.Session.VideoPath.Equals("")) |
|
34 |
{ |
|
35 |
//1-Creation de la ListVideo |
|
36 |
UserControlListVideo ListVideo = new UserControlListVideo(); |
|
37 |
ListVideo.Name = "ListVideo1"; |
|
38 |
//2-Ajout de la ListVideo au ControlScreen |
|
39 |
this.AddToGrid(ListVideo); |
|
40 |
//3-Creation des Events pour chaque item de la video |
|
41 |
ListVideo.EH_ItemVideo1_ContactDown += new System.EventHandler(this.ListVideo_EH_ItemVideo_ContactDown); |
|
42 |
} |
|
43 |
else |
148
|
44 |
OpenProject(); |
143
|
45 |
} |
35
|
46 |
|
82
|
47 |
//Rajout un UIElement vers la grid du screen. |
|
48 |
public void AddToGrid(UIElement uie) |
|
49 |
{ |
|
50 |
if (uie != null) |
|
51 |
{ |
|
52 |
try { LayoutRoot.Children.Add(uie); } |
|
53 |
catch(Exception){} |
|
54 |
} |
|
55 |
} |
|
56 |
|
104
|
57 |
private void ListVideo_EH_ItemVideo_ContactDown(object sender, EventArgs e) |
|
58 |
{ |
|
59 |
try |
|
60 |
{ |
148
|
61 |
//1 rensegner la video choisie au screen |
|
62 |
MainViewModel.CreateSession(((UserControlListVideo)sender).VideoName, ((UserControlListVideo)sender).path); |
|
63 |
//2-Supression du UC List Video |
104
|
64 |
LayoutRoot.Children.Remove((UserControlListVideo)sender); |
148
|
65 |
OpenSession(); |
104
|
66 |
} |
|
67 |
catch (Exception ex) { } |
|
68 |
} |
148
|
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 |
|
104
|
123 |
private void SessionInput_EH_SurfaceButtonSubmit_ContactDown(object sender, EventArgs e) |
|
124 |
{ |
|
125 |
try |
|
126 |
{ |
148
|
127 |
MainViewModel.Session.Alias = ((UserControlSessionInput)sender).Alias; |
|
128 |
MainViewModel.Session.Email = ((UserControlSessionInput)sender).Email; |
|
129 |
MainViewModel.Session.Description = ((UserControlSessionInput)sender).Description; |
|
130 |
MainViewModel.Session.Name = ((UserControlSessionInput)sender).Name; |
|
131 |
|
104
|
132 |
//2-Suppression UCSession Input |
|
133 |
LayoutRoot.Children.Remove((UserControlSessionInput)sender); |
148
|
134 |
OpenProject(); |
104
|
135 |
} |
|
136 |
catch (Exception ex) { } |
|
137 |
} |
148
|
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 |
} |
35
|
190 |
} |
|
191 |
} |