src/FingersDance.Control.Screen/UserControlScreen.xaml.cs
changeset 229 05aba5def1fc
parent 225 b60e13ed75c8
equal deleted inserted replaced
226:c0661ecf943e 229:05aba5def1fc
   116 
   116 
   117         private void OpenProjectList()
   117         private void OpenProjectList()
   118         {
   118         {
   119             try
   119             try
   120             {
   120             {
   121                     // We get all the ldt/project files from the current directory...
   121                 // We get all the ldt/project files from the current directory...
   122                     List<String> existingProjects = new List<String>();
   122                 List<String> existingProjects = new List<String>();
   123                     String path = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments);
   123                 String path = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments);
   124                     String ext = ".ldt";
   124                 String ext = ".ldt";
   125                     foreach (String filename in Directory.GetFiles(path))
   125                 foreach (String filename in Directory.GetFiles(path))
   126                     {
   126                 {
   127                         if (filename.Substring(filename.Length-4).ToLower()==ext)
   127                     if (filename.Substring(filename.Length-4).ToLower()==ext)
   128                             existingProjects.Add(filename.Substring(path.Length + 1, filename.Length - ext.Length - path.Length - 1));
   128                         existingProjects.Add(filename.Substring(path.Length + 1, filename.Length - ext.Length - path.Length - 1));
   129                     }
   129                 }
   130                     // ... and display them the the select box UserControlListProject
   130                 // ... and display them the the select box UserControlListProject
   131                     UserControlListProject listProject = new UserControlListProject(existingProjects, AnnotationOrSearchMode);
   131                 UserControlListProject listProject = new UserControlListProject(existingProjects, AnnotationOrSearchMode);
   132                     listProject.Name = "ListProject";
   132                 listProject.Name = "ListProject";
   133                     LayoutRoot.Children.Add(listProject);
   133                 LayoutRoot.Children.Add(listProject);
   134                     listProject.EH_ListProject_ContactDown += new EventHandler(listProject_EH_ListProject_ContactDown);
   134                 listProject.EH_ListProject_ContactDown += new EventHandler(listProject_EH_ListProject_ContactDown);
   135             }
   135             }
   136             catch (Exception)
   136             catch (Exception)
   137             {
   137             {
   138                 Cutting = null;
   138                 Cutting = null;
   139                 if (UC_Screen_NewCutting != null)
   139                 if (UC_Screen_NewCutting != null)
   141             }
   141             }
   142         }
   142         }
   143 
   143 
   144         void listProject_EH_ListProject_ContactDown(object sender, EventArgs e)
   144         void listProject_EH_ListProject_ContactDown(object sender, EventArgs e)
   145         {
   145         {
   146             try
   146             //try
   147             {
   147             //{
   148                 LayoutRoot.Children.Remove((UserControlListProject)sender);
   148                 LayoutRoot.Children.Remove((UserControlListProject)sender);
   149                 if (((UserControlListProject)sender).SelectedItem.Equals("New Project"))
   149                 if (((UserControlListProject)sender).SelectedItem.Equals("New Project"))
   150                 {
   150                 {
   151                     UserControlNewProjectForm ProjectInput = new UserControlNewProjectForm();
   151                     UserControlNewProjectForm ProjectInput = new UserControlNewProjectForm();
   152                     ProjectInput.Name = "ProjectInput";
   152                     ProjectInput.Name = "ProjectInput";
   183                             Color c = Color.FromRgb(r, g, b);
   183                             Color c = Color.FromRgb(r, g, b);
   184                             Annotation Annotation = new Annotation(aId, begin, dur, gtList, c);
   184                             Annotation Annotation = new Annotation(aId, begin, dur, gtList, c);
   185                             la.Add(Annotation);
   185                             la.Add(Annotation);
   186                             Data.AddAnnotation(Annotation);
   186                             Data.AddAnnotation(Annotation);
   187                         }
   187                         }
   188                         loadedProject.Cuttings.Add(new Cutting(cuttingNode.Attribute("id").Value,cuttingNode.Element("title").Value,la));
   188                         String cutColorString = cuttingNode.Attribute("color").Value; // is type 0xRRGGBB
       
   189                         Byte rCut = Convert.ToByte(cutColorString.Substring(2, 2), 16);
       
   190                         Byte gCut = Convert.ToByte(cutColorString.Substring(4, 2), 16);
       
   191                         Byte bCut = Convert.ToByte(cutColorString.Substring(6, 2), 16);
       
   192                         Color cCut = Color.FromRgb(rCut, gCut, bCut);
       
   193                         // We take off the loaded color from the reference color list.
       
   194                         ColorFactory.TakeOffColor(cCut);
       
   195                         // We add the cutting to the loaded project
       
   196                         loadedProject.Cuttings.Add(new Cutting(cuttingNode.Attribute("id").Value, cuttingNode.Element("title").Value, la, cCut));
   189                     }
   197                     }
   190                     // We define the loaded project as the current session's project in annotation mode or the searched project in search mode
   198                     // We define the loaded project as the current session's project in annotation mode or the searched project in search mode
   191                     if (AnnotationOrSearchMode == "Annotation")
   199                     if (AnnotationOrSearchMode == "Annotation")
   192                         _mainViewModel.Project = new ProjectViewModel(loadedProject);
   200                         _mainViewModel.Project = new ProjectViewModel(loadedProject);
   193                     else
   201                     else
   194                         SearchedProject = loadedProject;
   202                         SearchedProject = loadedProject;
   195                     OpenProject();
   203                     OpenProject();
   196                 }
   204                 }
   197             }
   205             //}
   198             catch (Exception)
   206             //catch (Exception)
   199             {
   207             //{
   200                 Cutting = null;
   208             //    Cutting = null;
   201                 if (UC_Screen_NewCutting != null)
   209             //    if (UC_Screen_NewCutting != null)
   202                     UC_Screen_NewCutting(this, new EventArgs());
   210             //        UC_Screen_NewCutting(this, new EventArgs());
   203             }
   211             //}
   204         }
   212         }
   205 
   213 
   206         private void ProjectInput_EH_NewProjectForm_ContactDown(object sender, EventArgs e)
   214         private void ProjectInput_EH_NewProjectForm_ContactDown(object sender, EventArgs e)
   207         {
   215         {
   208             try
   216             try