async private void WordBookInit() { StorageFolder localFolder = ApplicationData.Current.LocalFolder; StorageFile file = await localFolder.GetFileAsync(App.WordBookFileName); String fileText = await FileIO.ReadTextAsync(file); xBook = XDocument.Parse(fileText); XElement xWord = xBook.Root; IEnumerable<XElement> items = xWord.Elements(XName.Get("item")); ObservableCollection<WordItem> myWordList = new ObservableCollection<WordItem>(); foreach(XElement item in items) { WordItem words = new WordItem(); words.Key = item.Element(XName.Get("key")).Value; words.Ps = item.Element(XName.Get("ps")).Value; words.Acception = item.Element(XName.Get("acceptation")).Value; words.Time = item.Element(XName.Get("time")).Value; myWordList.Add(words); } List<WordGroup> Items = (from item in myWordList group item by item.Time into newitems select new WordGroup { TimeTitle = newitems.Key, WordItemContent = new ObservableCollection<WordItem>(newitems) }).ToList(); newItems = new ObservableCollection<WordGroup>(Items); CollectionViewSource ListWordSource = new CollectionViewSource(); ListWordSource.IsSourceGrouped = true; ListWordSource.Source = newItems; ListWordSource.ItemsPath = new PropertyPath("WordItemContent"); outView.ItemsSource = ListWordSource.View.CollectionGroups; inView.ItemsSource = ListWordSource.View; }
private async void WordPlayerInit() { StorageFolder localFolder = ApplicationData.Current.LocalFolder; StorageFile mtWordBook = await localFolder.GetFileAsync(App.WordBookFileName); String fileText = await FileIO.ReadTextAsync(mtWordBook); xWordbook = XDocument.Parse(fileText); XElement xWord = xWordbook.Root; IEnumerable<XElement> items = xWord.Elements(XName.Get("item")); myWordList = new ObservableCollection<WordItem>(); foreach (XElement item in items) { WordItem words = new WordItem(); words.Key = item.Element(XName.Get("key")).Value; words.Ps = item.Element(XName.Get("ps")).Value; words.Acception = item.Element(XName.Get("acceptation")).Value; myWordList.Add(words); } flipView.ItemsSource = myWordList; }
private async void GetHistory() { StorageFolder localFolder = ApplicationData.Current.LocalFolder; StorageFile wordHistory = await localFolder.GetFileAsync(App.HistoryFileName); string fileText = await FileIO.ReadTextAsync(wordHistory); XDocument xBook = XDocument.Parse(fileText); XElement root = xBook.Root; IEnumerable<XElement> items = root.Elements(XName.Get("item")); ObservableCollection<WordItem> historyList = new ObservableCollection<WordItem>(); foreach (XElement item in items) { WordItem history = new WordItem(); XElement xkey= item.Element(XName.Get("key")); history.Key = xkey.Value; historyList.Add(history); } lvHistory.ItemsSource = historyList; }