equal
deleted
inserted
replaced
21 public String contexteGrid; |
21 public String contexteGrid; |
22 public int id = 0; |
22 public int id = 0; |
23 public event EventHandler UC_Screen_NewCutting; |
23 public event EventHandler UC_Screen_NewCutting; |
24 private MainViewModel _mainViewModel; |
24 private MainViewModel _mainViewModel; |
25 public String AnnotationOrSearchMode; |
25 public String AnnotationOrSearchMode; |
|
26 public Project SearchedProject; |
26 public Cutting Cutting; |
27 public Cutting Cutting; |
27 |
28 |
28 private String videoName; |
29 private String videoName; |
29 private String videoPath; |
30 private String videoPath; |
30 |
31 |
47 this.AddToGrid(ListVideo); |
48 this.AddToGrid(ListVideo); |
48 //3-Creation des Events pour chaque item de la video |
49 //3-Creation des Events pour chaque item de la video |
49 ListVideo.EH_ItemVideo1_ContactDown += new System.EventHandler(ListVideo_EH_ItemVideo_ContactDown); |
50 ListVideo.EH_ItemVideo1_ContactDown += new System.EventHandler(ListVideo_EH_ItemVideo_ContactDown); |
50 } |
51 } |
51 else |
52 else |
52 OpenProject(); |
53 GetAnnotationOrSearchMode(); |
53 } |
54 } |
54 catch (Exception) |
55 catch (Exception) |
55 { |
56 { |
56 Cutting = null; |
57 Cutting = null; |
57 if (UC_Screen_NewCutting != null) |
58 if (UC_Screen_NewCutting != null) |
74 try |
75 try |
75 { |
76 { |
76 // 1- renseigner la video choisie au screen et créer un nouveau projet à partir de ce chemin vidéo |
77 // 1- renseigner la video choisie au screen et créer un nouveau projet à partir de ce chemin vidéo |
77 videoName = ((UserControlListVideo)sender).VideoName; |
78 videoName = ((UserControlListVideo)sender).VideoName; |
78 videoPath = ((UserControlListVideo)sender).path; |
79 videoPath = ((UserControlListVideo)sender).path; |
|
80 // We initialize it in _mainViewModel for it to remembered in every place of the application |
|
81 _mainViewModel.Project.VideoPath = videoPath; |
79 // 2-Supression du UC List Video |
82 // 2-Supression du UC List Video |
80 LayoutRoot.Children.Remove((UserControlListVideo)sender); |
83 LayoutRoot.Children.Remove((UserControlListVideo)sender); |
81 // 3 - Choose between Annotation Or Search Mode |
84 // 3 - Choose between Annotation Or Search Mode |
82 GetAnnotationOrSearchMode(); |
85 GetAnnotationOrSearchMode(); |
83 //OpenProjectList(); |
86 //OpenProjectList(); |
101 { |
104 { |
102 // We remove the UserControlAnnotationOrSearch |
105 // We remove the UserControlAnnotationOrSearch |
103 LayoutRoot.Children.Remove((UserControlAnnotationOrSearch)sender); |
106 LayoutRoot.Children.Remove((UserControlAnnotationOrSearch)sender); |
104 // We show the project list and send the chosen mode |
107 // We show the project list and send the chosen mode |
105 AnnotationOrSearchMode = e.ChosenMode; |
108 AnnotationOrSearchMode = e.ChosenMode; |
106 OpenProjectList(); |
109 if (AnnotationOrSearchMode == "Annotation" && _mainViewModel.Project.Cuttings.Count!=0) |
|
110 OpenProject(); |
|
111 else |
|
112 OpenProjectList(); |
|
113 |
107 } |
114 } |
108 |
115 |
109 private void OpenProjectList() |
116 private void OpenProjectList() |
110 { |
117 { |
111 try |
118 try |
112 { |
119 { |
113 // First We create the project if we are in annotation mode |
|
114 if(AnnotationOrSearchMode=="Annotation") |
|
115 _mainViewModel.CreateProject(videoName, videoPath); |
|
116 // We get all the ldt/project files from the current directory... |
120 // We get all the ldt/project files from the current directory... |
117 List<String> existingProjects = new List<String>(); |
121 List<String> existingProjects = new List<String>(); |
118 foreach (String filename in Directory.GetFiles("./")) |
122 foreach (String filename in Directory.GetFiles("./")) |
119 { |
123 { |
120 if (filename.Substring(filename.Length-4).ToLower()==".ldt") |
124 if (filename.Substring(filename.Length-4).ToLower()==".ldt") |
149 else |
153 else |
150 { |
154 { |
151 // ((UserControlListProject)sender).SelectedItem is the name of the selected project |
155 // ((UserControlListProject)sender).SelectedItem is the name of the selected project |
152 // Now we load the xml/ldt file to load all its datas (cuttings, annotations...) |
156 // Now we load the xml/ldt file to load all its datas (cuttings, annotations...) |
153 XDocument loadedLdt = XDocument.Load(((UserControlListProject)sender).SelectedItem + ".ldt"); |
157 XDocument loadedLdt = XDocument.Load(((UserControlListProject)sender).SelectedItem + ".ldt"); |
154 Project loadedProject = new Project(videoName, videoPath); |
158 Project loadedProject = new Project(videoName, _mainViewModel.Project.VideoPath); // we use this video in the case an other panel was in search mode before annotation mode |
155 loadedProject.Name = loadedLdt.Root.Element("project").Attribute("title").Value; |
159 loadedProject.Name = loadedLdt.Root.Element("project").Attribute("title").Value; |
156 loadedProject.Description = loadedLdt.Root.Element("project").Attribute("abstract").Value; |
160 loadedProject.Description = loadedLdt.Root.Element("project").Attribute("abstract").Value; |
157 loadedProject.Cuttings = new List<Cutting>(); |
161 loadedProject.Cuttings = new List<Cutting>(); |
158 XElement cuttingsParentNode = loadedLdt.Root.Element("annotations").Element("content"); |
162 XElement cuttingsParentNode = loadedLdt.Root.Element("annotations").Element("content"); |
159 foreach (XElement cuttingNode in cuttingsParentNode.Elements()) |
163 foreach (XElement cuttingNode in cuttingsParentNode.Elements()) |
172 Color c = Color.FromRgb(r, g, b); |
176 Color c = Color.FromRgb(r, g, b); |
173 la.Add(new Annotation(aId, begin, dur, gt, c)); |
177 la.Add(new Annotation(aId, begin, dur, gt, c)); |
174 } |
178 } |
175 loadedProject.Cuttings.Add(new Cutting(cuttingNode.Attribute("id").Value,cuttingNode.Element("title").Value,la)); |
179 loadedProject.Cuttings.Add(new Cutting(cuttingNode.Attribute("id").Value,cuttingNode.Element("title").Value,la)); |
176 } |
180 } |
177 // We define the loaded project as the current session's project. |
181 // We define the loaded project as the current session's project in annotation mode or the searched project in search mode |
178 _mainViewModel.Project = new ProjectViewModel(loadedProject); |
182 if (AnnotationOrSearchMode == "Annotation") |
|
183 _mainViewModel.Project = new ProjectViewModel(loadedProject); |
|
184 else |
|
185 SearchedProject = loadedProject; |
179 OpenProject(); |
186 OpenProject(); |
180 } |
187 } |
181 } |
188 } |
182 catch (Exception) |
189 catch (Exception) |
183 { |
190 { |
241 try |
248 try |
242 { |
249 { |
243 LayoutRoot.Children.Remove((UserControlListCutting)sender); |
250 LayoutRoot.Children.Remove((UserControlListCutting)sender); |
244 if (((UserControlListCutting)sender).SelectedItem.Equals("New Cutting")) |
251 if (((UserControlListCutting)sender).SelectedItem.Equals("New Cutting")) |
245 { |
252 { |
246 // "New Uutting" was was selected -> we display the form |
253 // "New Cutting" was was selected -> we display the form |
247 UserControlNewCuttingForm newCutting = new UserControlNewCuttingForm(User); |
254 UserControlNewCuttingForm newCutting = new UserControlNewCuttingForm(User); |
248 newCutting.Name = "newCutting"; |
255 newCutting.Name = "newCutting"; |
249 LayoutRoot.Children.Add(newCutting); |
256 LayoutRoot.Children.Add(newCutting); |
250 newCutting.EH_NewCuttingForm_ContactDown += new EventHandler(newCutting_EH_ContactDown); |
257 newCutting.EH_NewCuttingForm_ContactDown += new EventHandler(newCutting_EH_ContactDown); |
251 } |
258 } |