From 1039acb96a3affaa1bab45f2f8110883f1dc41c3 Mon Sep 17 00:00:00 2001 From: Michael Gordeev Date: Mon, 30 Jul 2018 01:08:25 +0300 Subject: [PATCH] Inbox development 2 --- FoxTube/Assets/Data/Patchnotes.xml | 5 +- FoxTube/Classes/InboxItem.cs | 9 +-- FoxTube/Pages/Inbox.xaml | 100 +++++++++-------------------- FoxTube/Pages/Inbox.xaml.cs | 71 ++++++++++++++++++-- FoxTube/Pages/Settings.xaml | 7 ++ FoxTube/Pages/Settings.xaml.cs | 8 +++ 6 files changed, 121 insertions(+), 79 deletions(-) diff --git a/FoxTube/Assets/Data/Patchnotes.xml b/FoxTube/Assets/Data/Patchnotes.xml index d474cca..4d69fb2 100644 --- a/FoxTube/Assets/Data/Patchnotes.xml +++ b/FoxTube/Assets/Data/Patchnotes.xml @@ -1,6 +1,9 @@  - + Announcement body (beware of special characters) + diff --git a/FoxTube/Classes/InboxItem.cs b/FoxTube/Classes/InboxItem.cs index b1e1dbb..7e99901 100644 --- a/FoxTube/Classes/InboxItem.cs +++ b/FoxTube/Classes/InboxItem.cs @@ -8,7 +8,7 @@ namespace FoxTube.Classes public class InboxItem { public InboxItemType Type { get; set; } = InboxItemType.Default; - DateTime TimeStamp { get; set; } + public DateTime TimeStamp { get; set; } public string PatchVersion { get; set; } public string Subject { get; set; } @@ -19,9 +19,9 @@ namespace FoxTube.Classes get { if (Type == InboxItemType.PatchNote) - return @""; + return "\xE728"; else - return @""; + return "\xE119"; } } public string Subtitle @@ -52,13 +52,14 @@ namespace FoxTube.Classes Type = InboxItemType.PatchNote; PatchVersion = version; Content = content; - TimeStamp = XmlConvert.ToDateTime(timeStamp, XmlDateTimeSerializationMode.Unspecified); + TimeStamp = DateTime.Parse(timeStamp); } public InboxItem(string title, string content, DateTime timeStamp) { Type = InboxItemType.Default; Content = content; + Subject = title; TimeStamp = timeStamp; } } diff --git a/FoxTube/Pages/Inbox.xaml b/FoxTube/Pages/Inbox.xaml index 74287bd..c6de091 100644 --- a/FoxTube/Pages/Inbox.xaml +++ b/FoxTube/Pages/Inbox.xaml @@ -16,91 +16,53 @@ - + - + + + + - - - - - - - - - - - - - - - - + + + + + + + + + - + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + diff --git a/FoxTube/Pages/Inbox.xaml.cs b/FoxTube/Pages/Inbox.xaml.cs index a046d8c..5ce6108 100644 --- a/FoxTube/Pages/Inbox.xaml.cs +++ b/FoxTube/Pages/Inbox.xaml.cs @@ -14,6 +14,7 @@ using Windows.UI.Xaml.Media; using Windows.UI.Xaml.Navigation; using FoxTube.Classes; using System.Xml; +using Windows.Storage; // The Blank Page item template is documented at https://go.microsoft.com/fwlink/?LinkId=234238 @@ -24,6 +25,7 @@ namespace FoxTube.Pages /// public sealed partial class Inbox : Page { + List backup = new List(); List items = new List(); public Inbox() { @@ -31,11 +33,16 @@ namespace FoxTube.Pages LoadItems(); } - public void LoadItems() + public async void LoadItems() { XmlDocument doc = new XmlDocument(); - doc.Load("ms-appx:///Assets/Data/Patchnotes.xml"); + string path = @"Assets\Data\Patchnotes.xml"; + StorageFolder InstallationFolder = Windows.ApplicationModel.Package.Current.InstalledLocation; + StorageFile file = await InstallationFolder.GetFileAsync(path); + Stream Countries = await file.OpenStreamForReadAsync(); + + doc.Load(Countries); foreach (XmlElement e in doc["items"].ChildNodes) items.Add(new InboxItem( e.GetAttribute("version"), @@ -44,14 +51,68 @@ namespace FoxTube.Pages )); doc.Load("http://foxgame.hol.es/ftp.xml"); - foreach (XmlElement e in doc["items"].ChildNodes) + foreach (XmlElement e in doc["posts"].ChildNodes) items.Add(new InboxItem( e["header"].InnerText, e["content"].InnerText, - XmlConvert.ToDateTime(e.GetAttribute("time"), XmlDateTimeSerializationMode.Unspecified) + DateTime.Parse(e.GetAttribute("time")) )); - items.Sort(); + items.OrderBy(item => item.TimeStamp); + + foreach (InboxItem i in items) + backup.Add(i); + + list.ItemsSource = items; + } + + private void filter_SelectionChanged(object sender, SelectionChangedEventArgs e) + { + try + { + items.Clear(); + switch (filter.SelectedIndex) + { + case 0: + foreach (InboxItem i in backup) + items.Add(i); + break; + + case 1: + foreach (InboxItem i in backup) + if(i.Type == InboxItemType.Default) + items.Add(i); + break; + + case 2: + foreach (InboxItem i in backup) + if (i.Type == InboxItemType.PatchNote) + items.Add(i); + break; + } + list.ItemsSource = items; + } + catch(NullReferenceException) { } + } + + private void list_SelectionChanged(object sender, SelectionChangedEventArgs e) + { + InboxItem item = list.SelectedItem as InboxItem; + OpenView(item.Title, item.Content); + } + + void CloseView() + { + content.Text = ""; + title.Text = ""; + block.Visibility = Visibility.Visible; + } + + void OpenView(string header, string body) + { + content.Text = body; + title.Text = header; + block.Visibility = Visibility.Collapsed; } } } diff --git a/FoxTube/Pages/Settings.xaml b/FoxTube/Pages/Settings.xaml index 7ecbf4e..d8c76eb 100644 --- a/FoxTube/Pages/Settings.xaml +++ b/FoxTube/Pages/Settings.xaml @@ -5,6 +5,7 @@ xmlns:local="using:FoxTube" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" + xmlns:pages="using:FoxTube.Pages" mc:Ignorable="d"> @@ -127,6 +128,9 @@ + + + @@ -146,6 +150,9 @@ + + + diff --git a/FoxTube/Pages/Settings.xaml.cs b/FoxTube/Pages/Settings.xaml.cs index b877a07..1390136 100644 --- a/FoxTube/Pages/Settings.xaml.cs +++ b/FoxTube/Pages/Settings.xaml.cs @@ -116,6 +116,7 @@ namespace FoxTube toFeedback.FontWeight = FontWeights.Normal; toAbout.FontWeight = FontWeights.Normal; toTranslate.FontWeight = FontWeights.Normal; + toInbox.FontWeight = FontWeights.Normal; if (content.SelectedIndex == 0) toGeneral.FontWeight = FontWeights.Bold; @@ -127,6 +128,8 @@ namespace FoxTube toAbout.FontWeight = FontWeights.Bold; else if (content.SelectedIndex == 4) toTranslate.FontWeight = FontWeights.Bold; + else if (content.SelectedIndex == 5) + toInbox.FontWeight = FontWeights.Bold; } private void toAccount_Click(object sender, RoutedEventArgs e) @@ -148,5 +151,10 @@ namespace FoxTube { settings.Values["safeSearch"] = safeSearch.SelectedIndex; } + + private void toInbox_Click(object sender, RoutedEventArgs e) + { + content.SelectedIndex = 5; + } } }