public async void PopulateActivityList(ListVM instance) { FileHelper.FileReader fr = new FileHelper.FileReader(); var xmlDoc = XElement.Load(fr.ReadFile()); List <XElement> activityNodes = xmlDoc.Descendants().Where(x => x.Name.ToString().Equals("Activity")).ToList(); for (var i = 0; i > activityNodes.Count; i++) { var activity = new ActivityVM(); activity.Name = activityNodes[i].Descendants("Name").ToString(); activity.Example_wav_path = activityNodes[i].Descendants("Example_wav_path").ToString(); activity.Pitch = Convert.ToInt32(activityNodes[i].Descendants("Pitch").ToString()); activity.PitchEvaluated = Convert.ToBoolean(activityNodes[i].Descendants("PitchEvaluated").ToString()); activity.Intensity = Convert.ToInt32(activityNodes[i].Descendants("Intensity").ToString()); activity.IntensityEvaluated = Convert.ToBoolean(activityNodes[i].Descendants("IntensityEvaluated").ToString()); activity.F0_exact = Convert.ToInt32(activityNodes[i].Descendants("F0_exact").ToString()); activity.F0_exactEvaluated = Convert.ToBoolean(activityNodes[i].Descendants("F0_exactEvaluated").ToString()); activity.F0_stable = Convert.ToInt32(activityNodes[i].Descendants("F0_stable").ToString()); activity.F0_stableEvaluated = Convert.ToBoolean(activityNodes[i].Descendants("F0_stableEvaluated").ToString()); activity.Intensite_stable = Convert.ToInt32(activityNodes[i].Descendants("Intensite_stable").ToString()); activity.Intensite_stableEvaluated = Convert.ToBoolean(activityNodes[i].Descendants("Intensite_stableEvaluated").ToString()); activity.Courbe_f0_exacte = Convert.ToInt32(activityNodes[i].Descendants("Courbe_f0_exacte").ToString()); activity.Courbe_f0_exacteEvaluated = Convert.ToBoolean(activityNodes[i].Descendants("Courbe_f0_exacteEvaluated").ToString()); activity.Duree_exacte = Convert.ToInt32(activityNodes[i].Descendants("Duree_exacte").ToString()); activity.Duree_exacteEvaluated = Convert.ToBoolean(activityNodes[i].Descendants("Duree_exacteEvaluated").ToString()); activity.Jitter = Convert.ToInt32(activityNodes[i].Descendants("Jitter").ToString()); activity.JitterEvaluated = Convert.ToBoolean(activityNodes[i].Descendants("JitterEvaluated").ToString()); instance.Add(activity); } }
private void populateExerciceList(string path, ListVM activityList) { XDocument xml = XDocument.Load(path + "\\config.xml"); var activities = xml.Descendants("Activity"); foreach (XElement activity in activities) { ActivityVM newSuiviVM = new ActivityVM { Name = activity.Descendants("Name").First().Value, Example_wav_path = path + "\\" + activity.Descendants("Exercice_wav_file_name").First().Value, PitchMin = Convert.ToInt32(activity.Descendants("Pitch_min").First().Value), PitchMax = Convert.ToInt32(activity.Descendants("Pitch_max").First().Value), IntensityThreshold = Convert.ToInt32(activity.Descendants("Intensity_threshold").First().Value), F0_exactEvaluated = Convert.ToBoolean(activity.Descendants("F0_exactEvaluated").First().Value), F0_stableEvaluated = Convert.ToBoolean(activity.Descendants("F0_stableEvaluated").First().Value), Intensite_stableEvaluated = Convert.ToBoolean(activity.Descendants("Intensite_stableEvaluated").First().Value), Courbe_f0_exacteEvaluated = Convert.ToBoolean(activity.Descendants("Courbe_f0_exacteEvaluated").First().Value), Duree_exacteEvaluated = Convert.ToBoolean(activity.Descendants("Duree_exacteEvaluated").First().Value), JitterEvaluated = Convert.ToBoolean(activity.Descendants("JitterEvaluated").First().Value) }; ICollection <DataLineItem> points = activity.Descendants("point").Select(x => new DataLineItem { Time = double.Parse(x.Descendants("time").First().Value), Intensity = double.Parse(x.Descendants("frequency").First().Value), Pitch = double.Parse(x.Descendants("pitch").First().Value) }).ToList(); newSuiviVM.Exercice = points; activityList.Add(newSuiviVM); } }
public void CheckReentrancyThrowsInvalidOperationException() { var dl = new List <TestItemDM> { new TestItemDM(0), new TestItemDM(1), new TestItemDM(2) }; var bl = new ListBM <TestItemBM> { Metadata = { DataProvider = { Data = dl } } }; var vl = new ListVM <TestItemVM> { Metadata = { DataProvider = { Data = bl } } }; vl.CollectionChanged += OnViewModelCollectionChangedCallInvalid; vl.Add(TestItemVM.New()); vl.CollectionChanged -= OnViewModelCollectionChangedCallInvalid; }
private void FillNavigation() { var lines = File.ReadAllLines("Data\\Navigation.txt"); foreach (var line in lines) { Add(line); } void Add(string key) { key = key.Trim(); var pattern = @"(?mnx-is)^" + Regex.Escape(key) + @"(\x20|\r\n|\n)"; NavigationItems.Add(new NavigationItemVM { DisplayName = key.StartsWith("-- ") ? key.Substring(3) : " " + key, RegexPattern = key.StartsWith("-- ") ? null : pattern, Regex = new Regex(pattern, RegexOptions.Compiled) }); } }
public void ListVM_Contains_Empty_BusinessList() { var dl = new List <TestItemDM>(); var bl = new ListBM <TestItemBM> { Metadata = { DataProvider = { Data = dl } } }; var vl = new ListVM <TestItemVM> { Metadata = { DataProvider = { Data = bl } } }; var di = (TestItemDM)null; var vi = (TestItemVM)null; Assert.AreEqual(false, vl.IsReadOnly); Assert.AreEqual(false, ((IList)vl).IsFixedSize); vl.Add(vi = new TestItemVM { Metadata = { DataProvider = { Data = new TestItemBM { Metadata = { DataProvider= { Data= di = new TestItemDM(0) } } } } } }); Assert.AreEqual(1, bl.Count); Assert.AreEqual(1, dl.Count); Assert.AreEqual(0, vl.IndexOf(vi)); Assert.AreEqual(0, ((IList)vl).IndexOf(vi)); Assert.AreEqual(true, ((IList)vl).Contains(vi)); Assert.AreEqual(vi, vl[0]); Assert.AreEqual(vi, ((IList)vl)[0]); vl.Add(new TestItemVM { Metadata = { DataProvider = { Data = new TestItemBM { Metadata = { DataProvider= { Data= new TestItemDM(1) } } } } } }); Assert.AreEqual(2, dl.Count); vl.Add(new TestItemVM { Metadata = { DataProvider = { Data = new TestItemBM { Metadata = { DataProvider= { Data= new TestItemDM(2) } } } } } }); Assert.AreEqual(3, dl.Count); vl.RemoveAt(1); Assert.AreEqual(2, dl.Count); vl.Remove(vi); Assert.AreEqual(1, dl.Count); vl.Clear(); Assert.AreEqual(0, dl.Count); vl.Insert(0, new TestItemVM { Metadata = { DataProvider = { Data = new TestItemBM { Metadata = { DataProvider= { Data= new TestItemDM(0) } } } } } }); vl.Insert(0, new TestItemVM { Metadata = { DataProvider = { Data = new TestItemBM { Metadata = { DataProvider= { Data= new TestItemDM(1) } } } } } }); vl.Insert(2, new TestItemVM { Metadata = { DataProvider = { Data = new TestItemBM { Metadata = { DataProvider= { Data= new TestItemDM(2) } } } } } }); Assert.AreEqual(3, dl.Count); foreach (var item in vl) { Assert.IsTrue(vl.Contains(item)); } foreach (var item in (IEnumerable)vl) { Assert.IsTrue(vl.Contains(item)); } vl.CopyTo(new TestItemVM[3], 0); vl[0] = TestItemVM.New(); ((IList)vl)[0] = TestItemVM.New(); vl.Move(0, 2); vl.Dispose(); }