private void ImportExistingExercices() { ListAvailable.SelectedIndex = -1; ListSelected.SelectedIndex = -1; activityListInstance.ClearItems(); activityListInstance.ClearSelectedItems(); if (Directory.Exists(EXERCICES_FOLDER)) { FileHelper.FileReader fileReader = new FileHelper.FileReader(); fileReader.ReadAllExercicesIntoExerciceVMList(EXERCICES_FOLDER, activityListInstance.getActivityList()); if (activityListInstance.getActivityList().Count > 0) { lblAucunExercice.Visibility = Visibility.Hidden; } else { lblAucunExercice.Visibility = Visibility.Visible; } } else { lblAucunExercice.Visibility = Visibility.Visible; //TODO: message indiquant qu'aucun exercice n'existe dans l'application } }
private void ImportExistingExercices() { ListActivities.SelectedIndex = -1; ActivityListInstance.ClearItems(); if (Directory.Exists(EXERCICES_FOLDER)) { FileHelper.FileReader fileReader = new FileHelper.FileReader(); fileReader.ReadAllExercicesIntoExerciceVMList(EXERCICES_FOLDER, ActivityListInstance.getActivityList()); } }
private void BtnImporter_Click(object sender, RoutedEventArgs e) { string path = ""; OpenFileDialog file = new OpenFileDialog(); if (file.ShowDialog() != null) { path = file.FileName; } FileHelper.FileReader fileReader = new FileHelper.FileReader(); fileReader.zipToExerciceList(path, activityListInstance); activityScores.Clear(); activityListInstance.ActivityList.ToList().ForEach(_ => activityScores.Add(null)); }
private void BtnImporter_Click(object sender, RoutedEventArgs e) { string path = ""; OpenFileDialog file = new OpenFileDialog(); if (file.ShowDialog() != null) { path = file.FileName; } FileHelper.FileReader fileReader = new FileHelper.FileReader(); fileReader.zipToExerciceList(path, activityListInstance); /* * * string currentDir = Environment.CurrentDirectory; * activityListInstance.ClearItems(); * * // Create OpenFileDialog * Microsoft.Win32.OpenFileDialog dlg = new Microsoft.Win32.OpenFileDialog(); * * // Set filter for file extension and default file extension * dlg.DefaultExt = ".xml"; * * // Display OpenFileDialog by calling ShowDialog method * Nullable<bool> fileSelected = dlg.ShowDialog(); * * if (fileSelected == true) * { * string data; * //Create a StreamReader to read selected xml file * var streamReader = new StreamReader(dlg.FileName, Encoding.UTF8); * * //Trim and clean the read data to ease parsing * data = streamReader.ReadToEnd(); * data.Trim(); * data = data.Replace("\n", String.Empty).Replace("\t", String.Empty).Replace("\r", String.Empty); * * //create instance of our model * ListeResultatsModel result = new ListeResultatsModel(); * * //Setup our xml serializer and read xml data into our class * var serializer = new XmlSerializer(typeof(ListeResultatsModel)); * var stream = new StringReader(data); * var reader = XmlReader.Create(stream); * { * result = (ListeResultatsModel)serializer.Deserialize(reader); * } * * //create an object of type SuiviVM from the collected data * foreach(ExerciceResultat ex in result.Liste_exercices_resultats) * { * ExerciceVM newExerciceVM = new ExerciceVM * { * Example_wav_path = currentDir + @"\Ressources\" + ex.Exercice_wav_file_name, * Result_wav_path = currentDir + @"\Ressources\" + ex.Resultat_wav_file_name, * Name = ex.Name, * PitchMin = ex.PitchMin, * PitchMax = ex.PitchMax, * IntensityThreshold = ex.IntensityThreshold * }; * * activityListInstance.Add(newExerciceVM); * } * * } */ }