/// <summary> /// Import user activity data from file. /// </summary> public List <SessionGroup> ImportFile() { var groups = new List <SessionGroup>(); var openFileDialog = new OpenFileDialog() { Filter = string.Format("UAD-файлы (*.{0})|*.{0}", XmlUserActivityDataContext.UadFileExtension), Multiselect = true, }; bool?result = openFileDialog.ShowDialog(); if (result == true) { foreach (var stream in openFileDialog.OpenFiles()) { using (stream) { var sessionGroup = XmlUserActivityDataContext.LoadSessionGroup(stream); groups.Add(sessionGroup); } } } return(groups); }
private void ExecuteImportDataFromFile() { var openFileDialog = new OpenFileDialog() { Filter = string.Format("UAD-файлы (*.{0})|*.{0}", XmlUserActivityDataContext.UadFileExtension), Multiselect = true, }; bool?result = openFileDialog.ShowDialog(); if (result == true) { var serializer = new XmlSerializer(typeof(SessionGroup)); foreach (var stream in openFileDialog.OpenFiles()) { using (stream) { SessionGroup sessionGroup = XmlUserActivityDataContext.LoadSessionGroup(stream); SessionGroups.Add(sessionGroup); } } var newRegions = new List <RegionImageItemVM>(); foreach (var region in SessionGroups.SelectMany(sg => sg.Sessions).SelectMany(s => s.Regions)) { foreach (var image in region.Variations) { if (newRegions.FirstOrDefault(r => r.RegionName == region.Name && r.ImageName == image.Name) == null) { var newRegion = new RegionImageItemVM() { RegionName = region.Name, Image = image }; newRegions.Add(newRegion); } } } RegionSelector.Clear(); RegionSelector.AddRange(newRegions.OrderBy(r => r.RegionName)); RegionSelector.SelectedItem = RegionSelector.FirstOrDefault(); } }