Archived
1
0

Settings rebuild

This commit is contained in:
Michael Gordeev
2018-08-01 19:04:12 +03:00
parent 00981c67c0
commit ba02a37760
18 changed files with 276 additions and 328 deletions
+56
View File
@@ -0,0 +1,56 @@
<Page
x:Class="FoxTube.Pages.SettingsPages.About"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:FoxTube.Pages.SettingsPages"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d"
Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
<Grid Padding="10" Name="grid">
<VisualStateManager.VisualStateGroups>
<VisualStateGroup>
<VisualState>
<VisualState.StateTriggers>
<AdaptiveTrigger MinWindowWidth="600"/>
</VisualState.StateTriggers>
<VisualState.Setters>
<Setter Target="grid.ColumnDefinitions[1].Width" Value="auto"/>
</VisualState.Setters>
</VisualState>
</VisualStateGroup>
</VisualStateManager.VisualStateGroups>
<Grid.ColumnDefinitions>
<ColumnDefinition/>
<ColumnDefinition Width="0"/>
</Grid.ColumnDefinitions>
<StackPanel>
<TextBlock Text="About us and this app" FontSize="28"/>
<TextBlock Text="FoxTube" FontSize="24"/>
<TextBlock Name="version" Text="[currentVersion]" FontSize="14" Foreground="Gray" Margin="0,-5,0,10"/>
<TextBlock TextWrapping="WrapWholeWords" Text="Developed by Michael Gordeev (also known as XFox)" Margin="0,0,0,10"/>
<TextBlock TextWrapping="WrapWholeWords" Visibility="Collapsed" Text="Special thanks to contributors for motivating me, testers and translators for making this app better everyday and you for using this app;)" Margin="0,0,0,10"/>
<TextBlock Text="Contacts" FontSize="22" FontWeight="SemiBold"/>
<TextBlock>Twitter: <Hyperlink NavigateUri="https://twitter.com/XFox_Mike" Foreground="Red">@XFox_Mike</Hyperlink></TextBlock>
<TextBlock>Vkontakte: <Hyperlink NavigateUri="https://vk.com/XFox.Mike" Foreground="Red">@XFox.Mike</Hyperlink></TextBlock>
<TextBlock>YouTube: <Hyperlink NavigateUri="https://youtube.com/c/FoxGameStudioChannel" Foreground="Red">@FoxGameStudioChannel</Hyperlink></TextBlock>
<TextBlock>E-mail: <Hyperlink NavigateUri="mailto:michael.xfox@outlook.com" Foreground="Red">michael.xfox@outlook.com</Hyperlink></TextBlock>
<TextBlock Margin="0,0,0,10">My blog (Russian language only): <Hyperlink NavigateUri="https://michael-xfox.com" Foreground="Red">https://michael-xfox.com</Hyperlink></TextBlock>
<TextBlock Text="Legal stuff" FontSize="22" FontWeight="SemiBold"/>
<HyperlinkButton Foreground="Red" Content="Our Privacy Policy" NavigateUri="https://michael-xfox.com/foxtubepp.txt" Padding="0,5,0,0"/>
<HyperlinkButton Foreground="Red" Content="YouTube Privacy Policy" NavigateUri="https://youtube.com/t/privacy" Padding="0"/>
<HyperlinkButton Foreground="Red" Content="YouTube Terms of use" NavigateUri="https://youtube.com/t/terms" Padding="0"/>
<HyperlinkButton Foreground="Red" Content="YouTube Community Guidelines" NavigateUri="https://youtube.com/t/community_guidelines" Padding="0,0,0,10"/>
<TextBlock Text="© 2018 Michael Gordeev"/>
<TextBlock Text="© 2018 YouTube, LLC"/>
</StackPanel>
<Image Grid.Column="1" Source="/Assets/LogoAvatar.png" VerticalAlignment="Top" Width="128"/>
</Grid>
</Page>
+33
View File
@@ -0,0 +1,33 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Runtime.InteropServices.WindowsRuntime;
using Windows.ApplicationModel;
using Windows.Foundation;
using Windows.Foundation.Collections;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
using Windows.UI.Xaml.Controls.Primitives;
using Windows.UI.Xaml.Data;
using Windows.UI.Xaml.Input;
using Windows.UI.Xaml.Media;
using Windows.UI.Xaml.Navigation;
// The Blank Page item template is documented at https://go.microsoft.com/fwlink/?LinkId=234238
namespace FoxTube.Pages.SettingsPages
{
/// <summary>
/// An empty page that can be used on its own or navigated to within a Frame.
/// </summary>
public sealed partial class About : Page
{
PackageVersion ver = Package.Current.Id.Version;
public About()
{
this.InitializeComponent();
version.Text = string.Format("{0}.{1}.{2}", ver.Major, ver.Minor, ver.Build);
}
}
}
+60
View File
@@ -0,0 +1,60 @@
<Page
x:Class="FoxTube.Pages.SettingsPages.Feedback"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:FoxTube"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d">
<Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" MaxWidth="1000"/>
</Grid.ColumnDefinitions>
<StackPanel Orientation="Vertical" Margin="10">
<TextBlock Text="Feedback Hub" FontSize="28"/>
<TextBlock Text="What kind of feedback is it?" FontSize="18" Margin="0,10,0,0"/>
<StackPanel Orientation="Horizontal">
<RadioButton Name="suggestionRadio" Content="Suggestion" IsChecked="True"/>
<RadioButton Name="promblemRadio" Content="Problem"/>
</StackPanel>
<TextBlock Text="Tell us about it" FontSize="18" Margin="0,10,0,0"/>
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="30"/>
</Grid.ColumnDefinitions>
<TextBox Name="subject" Grid.Column="0" HorizontalAlignment="Stretch" GotFocus="subject_GotFocus" Header="Summarize your issue (max 400 characters)" MaxLength="400"/>
<TextBlock Name="subjectMissed" Grid.Column="1" FontFamily="Segoe MDL2 Assets" Text="&#xE814;" Foreground="Red" FontSize="30" Visibility="Collapsed" VerticalAlignment="Bottom" Margin="1"/>
</Grid>
<TextBox Name="details" HorizontalAlignment="Stretch" Height="200" AcceptsReturn="True" ScrollViewer.VerticalScrollBarVisibility="Auto" MaxLength="1000" Margin="0,5,30,0" Header="Give us more detail (optional) (max 1000 characters)"/>
<CheckBox Content="I'd like to get response from developers" Name="emailToggle" Click="emailToggle_Click"/>
<TextBox Header="E-mail adress for response:" PlaceholderText="someone@example.com" IsEnabled="False" Name="email" Margin="0,5,30,0"/>
<StackPanel Orientation="Horizontal" BorderBrush="Green" BorderThickness="5" Margin="0,10,30,0" Name="debugAttached" Visibility="Collapsed">
<TextBlock FontFamily="Segoe MDL2 Assets" Text="&#xE16C;" FontSize="40" Foreground="Green" Margin="5"/>
<StackPanel>
<TextBlock Text="Logs attached!" Foreground="Green" FontWeight="Bold" FontSize="20"/>
<TextBlock Text="You don't have to attach error code or exception details to you feedback. We did it ourselves." Foreground="Green"/>
</StackPanel>
</StackPanel>
<StackPanel Orientation="Horizontal" BorderBrush="Green" BorderThickness="5" Margin="0,10,30,0" Visibility="Collapsed" Name="greenResult">
<TextBlock FontFamily="Segoe MDL2 Assets" Text="&#xE76E;" FontSize="40" Foreground="Green" Margin="5"/>
<StackPanel>
<TextBlock Text="Your feedback has been sent!" Foreground="Green" FontWeight="Bold" FontSize="20"/>
<TextBlock Text="Thank you! It's very imortant for us. Thank you for helping us making the app better" Foreground="Green"/>
</StackPanel>
</StackPanel>
<StackPanel Orientation="Horizontal" BorderBrush="OrangeRed" BorderThickness="5" Margin="0,10,30,0" Visibility="Collapsed" Name="cooldown">
<TextBlock FontFamily="Segoe MDL2 Assets" Text="&#xE7BA;" FontSize="40" Foreground="OrangeRed" Margin="5"/>
<StackPanel>
<TextBlock Text="You reached your daily feedback limit" Foreground="OrangeRed" FontWeight="Bold" FontSize="20"/>
<TextBlock Text="To prevent spaming our mailbox we allow our users to send 1 feedback per day. Come back later to leave additional feedback." Foreground="OrangeRed"/>
</StackPanel>
</StackPanel>
<StackPanel Orientation="Horizontal">
<Button Content="Submit feedback" Name="submit" Margin="0,10,10,10" Click="submit_Click" Background="Red" Foreground="White"/>
<ProgressRing VerticalAlignment="Center" Name="ring" Foreground="Red"/>
</StackPanel>
</StackPanel>
</Grid>
</Page>
@@ -0,0 +1,187 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Runtime.InteropServices.WindowsRuntime;
using Windows.Foundation;
using Windows.Foundation.Collections;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
using Windows.UI.Xaml.Controls.Primitives;
using Windows.UI.Xaml.Data;
using Windows.UI.Xaml.Input;
using Windows.UI.Xaml.Media;
using Windows.UI.Xaml.Navigation;
using Windows.Storage;
using System.Net.Mail;
using System.Net;
using Windows.UI.Popups;
using Windows.UI;
using System.Threading.Tasks;
using System.Diagnostics;
// The Blank Page item template is documented at https://go.microsoft.com/fwlink/?LinkId=234238
namespace FoxTube.Pages.SettingsPages
{
/// <summary>
/// An empty page that can be used on its own or navigated to within a Frame.
/// </summary>
public sealed partial class Feedback : Page
{
string debugData = "";
ApplicationDataContainer settings = ApplicationData.Current.LocalSettings;
public Feedback()
{
this.InitializeComponent();
if (settings.Values["feedbackRecord"] == null)
settings.Values.Add("feedbackRecord", DateTimeToString(DateTime.Now - new TimeSpan(2, 0, 0, 0)));
TimeSpan interval = new TimeSpan(1, 0, 0, 0);
if(DateTime.Now - StringDateTime(settings.Values["feedbackRecord"].ToString()) < interval)
{
subject.IsEnabled = false;
details.IsEnabled = false;
promblemRadio.IsEnabled = suggestionRadio.IsEnabled = false;
submit.IsEnabled = false;
cooldown.Visibility = Visibility.Visible;
}
}
string DateTimeToString(DateTime dateTime)
{
string value = string.Format("{0} {1} {2} {3} {4} {5}", dateTime.Year, dateTime.Month, dateTime.Day, dateTime.Hour, dateTime.Minute, dateTime.Second);
Debug.WriteLine("Debag " + value);
return value;
}
DateTime StringDateTime(string value)
{
string[] t = value.Split(' ');
List<int> i = new List<int>();
foreach (string s in t)
i.Add(Convert.ToInt32(s));
return new DateTime(i[0], i[1], i[2], i[3], i[4], i[5]);
}
private async void submit_Click(object sender, RoutedEventArgs e)
{
//subject.Text = "This is test feedback";
//details.Text = "This is test for FoxTube Feedback System (FTFS)\nAaBbCcDdEeFfGgHhIiJjKkLlMmNnOoPpQqRrSsTtUuVvWwXxYyZz 0123456789";
if (subject.Text == "")
{
subjectMissed.Visibility = Visibility.Visible;
subject.Background = new SolidColorBrush(Colors.Pink);
}
else
{
string Type()
{
if ((bool)suggestionRadio.IsChecked) return "Suggestion";
else return "Problem";
}
MailMessage msg = new MailMessage();
msg.To.Add("foxgameofficial+foxtube@gmail.com");
msg.From = new MailAddress("foxgameofficial+foxtube@gmail.com");
msg.Subject = "FoxTube feedback";
msg.Body = string.Format("Type: {0}\nTime: {1}\n\nTitle:\n{2}\n\nDetails:\n{3}\n\nResponse e-mail: {4}\n\nException details:\n{5}", Type(), DateTime.Now, subject.Text, details.Text, email.Text, debugData);
subject.IsEnabled = false;
details.IsEnabled = false;
promblemRadio.IsEnabled = suggestionRadio.IsEnabled = false;
submit.IsEnabled = false;
ring.IsActive = true;
await Task.Delay(1000);
Submit(msg);
}
}
async void Submit(MailMessage mes)
{
SmtpClient client = new SmtpClient("smtp.gmail.com", 587);
client.EnableSsl = true;
client.Credentials = SecretsVault.EmailCredential;
try
{
client.Send(mes);
greenResult.Visibility = Visibility.Visible;
settings.Values["feedbackRecord"] = DateTimeToString(DateTime.Now);
}
catch
{
MessageDialog message = new MessageDialog("We was unable to send your feedback due to connection problems or internal server error. Please, try again later.", "Failed to send your feedback");
await message.ShowAsync();
subject.IsEnabled = true;
details.IsEnabled = true;
promblemRadio.IsEnabled = suggestionRadio.IsEnabled = true;
submit.IsEnabled = true;
}
ring.IsActive = false;
}
private void subject_GotFocus(object sender, RoutedEventArgs e)
{
subjectMissed.Visibility = Visibility.Collapsed;
subject.Background = new SolidColorBrush();
}
private void emailToggle_Click(object sender, RoutedEventArgs e)
{
email.IsEnabled = (bool)emailToggle.IsChecked;
}
public void PreDefine(bool isProblem, string meta)
{
if (isProblem)
{
promblemRadio.IsChecked = true;
suggestionRadio.IsChecked = false;
}
else
{
promblemRadio.IsChecked = false;
suggestionRadio.IsChecked = true;
}
debugData = meta;
debugAttached.Visibility = Visibility.Visible;
}
/*
private void feedbackSubmit_Click(object sender, EventArgs e)
{
if (feedbackTitle.Text == "") MessageBox.Show("Please, fill the first field before submitting.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
else
{
string type()
{
if (feedbackSuggestion.Checked) return "Suggestion";
else return "Problem";
}
try
{
MailMessage msg = new MailMessage();
msg.To.Add("foxgameofficial@gmail.com");
msg.From = new MailAddress("sender@gmail.com");
msg.Subject = "Stream2String feedback";
msg.Body = "Type: " + type() + "\n\nTitle: " + feedbackTitle.Text + "\nDetails: " + feedbackDetails.Text + "\n\n" + feedbackMail.Text;
SmtpClient client = new SmtpClient("smtp.gmail.com", 587);
client.EnableSsl = true;
client.Credentials = new NetworkCredential("sender@gmail.com", "Thisisthepassword07734");
//Send the msg
client.Send(msg);
MessageBox.Show("Thank you for your feedback. You've just helped us to make our program better!", "Congratulations!", MessageBoxButtons.OK, MessageBoxIcon.Information);
proceedFeedback();
Properties.Settings.Default.feedback = true;
Properties.Settings.Default.Save();
}
catch { MessageBox.Show("Unfortunately, we can't send your feedback now. Please, try again later.", "Server connection error", MessageBoxButtons.OK, MessageBoxIcon.Error); }
}
}*/
}
}
+108
View File
@@ -0,0 +1,108 @@
<Page
x:Class="FoxTube.Pages.SettingsPages.Inbox"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:FoxTube.Pages"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:controls="using:Microsoft.Toolkit.Uwp.UI.Controls"
mc:Ignorable="d"
Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
<Grid Name="grid">
<VisualStateManager.VisualStateGroups>
<VisualStateGroup>
<VisualState>
<VisualState.StateTriggers>
<AdaptiveTrigger MinWindowWidth="1500"/>
</VisualState.StateTriggers>
<VisualState.Setters>
<Setter Target="grid.ColumnDefinitions[0].Width" Value="*"/>
<Setter Target="grid.ColumnDefinitions[1].Width" Value="3*"/>
<Setter Target="close.Visibility" Value="Collapsed"/>
</VisualState.Setters>
</VisualState>
<VisualState>
<VisualState.StateTriggers>
<AdaptiveTrigger MinWindowWidth="1000"/>
</VisualState.StateTriggers>
<VisualState.Setters>
<Setter Target="grid.ColumnDefinitions[0].Width" Value="*"/>
<Setter Target="grid.ColumnDefinitions[1].Width" Value="2*"/>
<Setter Target="close.Visibility" Value="Collapsed"/>
</VisualState.Setters>
</VisualState>
<VisualState>
<VisualState.StateTriggers>
<AdaptiveTrigger MinWindowWidth="800"/>
</VisualState.StateTriggers>
<VisualState.Setters>
<Setter Target="grid.ColumnDefinitions[0].Width" Value="*"/>
<Setter Target="grid.ColumnDefinitions[1].Width" Value="*"/>
<Setter Target="close.Visibility" Value="Collapsed"/>
</VisualState.Setters>
</VisualState>
</VisualStateGroup>
</VisualStateManager.VisualStateGroups>
<Grid.ColumnDefinitions>
<ColumnDefinition/>
<ColumnDefinition Width="0"/>
</Grid.ColumnDefinitions>
<ScrollViewer>
<StackPanel VerticalAlignment="Stretch" Background="#FFF2F2F2">
<ComboBox Header="Filter" Margin="10" HorizontalAlignment="Stretch" SelectedIndex="0" Name="filter" SelectionChanged="filter_SelectionChanged">
<ComboBoxItem Content="All"/>
<ComboBoxItem Content="Messages"/>
<ComboBoxItem Content="Patch notes"/>
</ComboBox>
<ListBox Name="list" SelectionChanged="list_SelectionChanged">
<ListBox.ItemContainerStyle>
<Style TargetType="ListBoxItem">
<Setter Property="Padding" Value="10"/>
<Setter Property="HorizontalContentAlignment" Value="Stretch"/>
</Style>
</ListBox.ItemContainerStyle>
<ListBox.ItemTemplate>
<DataTemplate>
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="auto"/>
<ColumnDefinition/>
<ColumnDefinition Width="auto"/>
</Grid.ColumnDefinitions>
<Grid Margin="0,0,10,0">
<Ellipse Fill="Red" Height="40" Width="40"/>
<TextBlock Foreground="White" FontFamily="Segoe MDL2 Assets" Text="{Binding Path=Icon}" VerticalAlignment="Center" HorizontalAlignment="Center" FontWeight="Light" FontSize="17"/>
</Grid>
<StackPanel Grid.Column="1">
<TextBlock FontWeight="Bold" Text="{Binding Path=Title}"/>
<TextBlock Foreground="Gray" Text="{Binding Path=Subtitle}"/>
</StackPanel>
<TextBlock Foreground="Gray" FontSize="13" Text="{Binding Path=TimeStamp}" Grid.Column="2"/>
</Grid>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
</StackPanel>
</ScrollViewer>
<ScrollViewer Grid.Column="1">
<StackPanel Margin="10">
<TextBlock FontWeight="Bold" Text="Hello, World!" FontSize="26" Name="title"/>
<controls:MarkdownTextBlock IsTextSelectionEnabled="True" Text="Content" Name="content"/>
</StackPanel>
</ScrollViewer>
<Button Grid.Column="1" VerticalAlignment="Top" HorizontalAlignment="Right" Background="Transparent" FontFamily="Segoe MDL2 Assets" Content="&#xE106;" Width="50" Height="50" Name="close" Click="close_Click"/>
<Grid Grid.Column="1" Background="{ThemeResource ApplicationPageBackgroundThemeBrush}" Name="block">
<StackPanel Orientation="Horizontal" VerticalAlignment="Center">
<TextBlock FontFamily="Segoe MDL2 Assets" Text="&#xE7EA;" FontSize="70" Foreground="Gray" Margin="10"/>
<TextBlock Text="Select item from list" FontSize="30" VerticalAlignment="Center" Foreground="Gray"/>
</StackPanel>
</Grid>
</Grid>
</Page>
+142
View File
@@ -0,0 +1,142 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Runtime.InteropServices.WindowsRuntime;
using Windows.Foundation;
using Windows.Foundation.Collections;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
using Windows.UI.Xaml.Controls.Primitives;
using Windows.UI.Xaml.Data;
using Windows.UI.Xaml.Input;
using Windows.UI.Xaml.Media;
using Windows.UI.Xaml.Navigation;
using FoxTube.Classes;
using System.Xml;
using Windows.Storage;
using System.Diagnostics;
// The Blank Page item template is documented at https://go.microsoft.com/fwlink/?LinkId=234238
namespace FoxTube.Pages.SettingsPages
{
/// <summary>
/// An empty page that can be used on its own or navigated to within a Frame.
/// </summary>
public sealed partial class Inbox : Page
{
public bool Loaded = false;
List<InboxItem> backup = new List<InboxItem>();
List<InboxItem> items = new List<InboxItem>();
public Inbox()
{
this.InitializeComponent();
}
public async void LoadItems()
{
XmlDocument doc = new XmlDocument();
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"),
e["content"].InnerText,
e.GetAttribute("time")
));
doc.Load("http://foxgame.hol.es/ftp.xml");
foreach (XmlElement e in doc["posts"].ChildNodes)
items.Add(new InboxItem(
e["header"].InnerText,
e["content"].InnerText,
DateTime.Parse(e.GetAttribute("time"))
));
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();
list.ItemsSource = null;
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;
if(list.SelectedItem != null)
{
OpenView(item.Title, item.Content);
if (grid.ColumnDefinitions[1].Width.Value == 0)
{
grid.ColumnDefinitions[0].Width = new GridLength(0);
grid.ColumnDefinitions[1].Width = new GridLength(1, GridUnitType.Star);
Debug.WriteLine("Opened");
}
}
}
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;
}
private void close_Click(object sender, RoutedEventArgs e)
{
CloseView();
if (grid.ColumnDefinitions[0].Width.Value == 0)
{
grid.ColumnDefinitions[0].Width = new GridLength(1, GridUnitType.Star);
grid.ColumnDefinitions[1].Width = new GridLength(0);
Debug.WriteLine("Closed");
}
}
}
}
@@ -0,0 +1,54 @@
<Page
x:Class="FoxTube.Pages.SettingsPages.Translate"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:FoxTube"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d">
<Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
<StackPanel Orientation="Vertical" Margin="10">
<TextBlock Text="Help us translate this app" FontSize="28"/>
<TextBlock TextWrapping="WrapWholeWords" Text="You can help us make this app even better by contributing to its development by translating this app. You can choose a brand new language to translate or edit mistakes in existing translations." Margin="0,0,0,10"/>
<StackPanel BorderThickness="2" BorderBrush="OrangeRed" MaxWidth="500" HorizontalAlignment="Left" Margin="0,0,0,10" Padding="0,0,0,3">
<TextBlock Foreground="OrangeRed" FontWeight="SemiBold" TextWrapping="WrapWholeWords" Text="Attention! This tool is used to help us to provide our app to more people from other countries. If you want to corect some mistakes in already existing language pack, please, report them via our Feedback Hub. Thanks in advance ;)" Margin="5"/>
</StackPanel>
<TextBlock Text="It's quite simple:" Margin="0,0,0,10"/>
<ComboBox Header="1. Choose language you want to translate" PlaceholderText="Choose language..." Name="LangList" Margin="0,0,0,10" MinWidth="350" SelectionChanged="LangList_SelectionChanged"/>
<TextBlock Text="2. Import language pack file to your PC" Margin="0,0,0,10"/>
<Button Content="Export to PC (.xml)" Margin="0,0,0,10" Name="export" Click="export_Click" IsEnabled="False"/>
<TextBlock TextWrapping="WrapWholeWords" Text="3. Open file with any text editor you want (Notepad, Wordpad, Notepad++, VS Code, etc.)" Margin="0,0,0,10"/>
<TextBlock TextWrapping="WrapWholeWords" Text="4. Edit file by translating nececcary words and sentences" Margin="0,0,0,10"/>
<TextBlock Text="5. Upload final package to our servers" Margin="0,0,0,10"/>
<StackPanel Name="submitNotification" Visibility="Collapsed" BorderThickness="2" BorderBrush="OrangeRed" Width="350" HorizontalAlignment="Left" Margin="0,0,0,10" Padding="0,0,0,3">
<TextBlock Foreground="OrangeRed" FontWeight="SemiBold" Text="Attention! Once you submitted this language pack you won't be able to contribute to the language anymore. Think twice before continuing" TextWrapping="WrapWholeWords" Margin="5"/>
</StackPanel>
<Button Content="Choose file to upload" Margin="-1,0,0,10" HorizontalAlignment="Left" VerticalAlignment="Top" Name="upload" IsEnabled="False" Click="upload_Click"/>
<ProgressBar Width="250" HorizontalAlignment="Left" IsIndeterminate="True" Name="uploadingProgress" Visibility="Collapsed"/>
<TextBlock TextWrapping="WrapWholeWords" Text="It takes about 2-3 weeks to process new language pack and include it to the next update" Margin="0,0,0,10"/>
<TextBlock Text="Thank you for your help &#x1F61A;"/>
<TextBlock Text="Best wishes,"/>
<TextBlock Text=" XFox"/>
<StackPanel Orientation="Horizontal" BorderBrush="Green" BorderThickness="5" Margin="0,10,30,0" Visibility="Collapsed" Name="greenResult">
<TextBlock FontFamily="Segoe MDL2 Assets" Text="&#xE76E;" FontSize="40" Foreground="Green" Margin="5"/>
<StackPanel>
<TextBlock Text="Your language pack has been sent!" Foreground="Green" FontWeight="Bold" FontSize="20"/>
<TextBlock Text="Thank you! It's very imortant for us. Thank you for helping us making the app better" Foreground="Green"/>
</StackPanel>
</StackPanel>
<StackPanel Orientation="Horizontal" BorderBrush="OrangeRed" BorderThickness="5" Margin="0,10,30,0" Visibility="Collapsed" Name="denied">
<TextBlock FontFamily="Segoe MDL2 Assets" Text="&#xE7BA;" FontSize="40" Foreground="OrangeRed" Margin="5"/>
<StackPanel>
<TextBlock Text="You have already contributed to this language" Foreground="OrangeRed" FontWeight="Bold" FontSize="20"/>
<TextBlock Text="To prevent spaming our mailbox we allow our users to contribute to each language only 1 time" Foreground="OrangeRed"/>
</StackPanel>
</StackPanel>
</StackPanel>
</Grid>
</Page>
@@ -0,0 +1,125 @@
using System;
using System.Collections.Generic;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Runtime.InteropServices.WindowsRuntime;
using Windows.Foundation;
using Windows.Foundation.Collections;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
using Windows.UI.Xaml.Controls.Primitives;
using Windows.UI.Xaml.Data;
using Windows.UI.Xaml.Input;
using Windows.UI.Xaml.Media;
using Windows.UI.Xaml.Navigation;
using Windows.Storage.Pickers;
using Windows.Storage;
using System.Net.Mail;
using System.Net;
using Windows.UI.Popups;
// The Blank Page item template is documented at https://go.microsoft.com/fwlink/?LinkId=234238
namespace FoxTube.Pages.SettingsPages
{
/// <summary>
/// An empty page that can be used on its own or navigated to within a Frame.
/// </summary>
public sealed partial class Translate : Page
{
ApplicationDataContainer settings = ApplicationData.Current.LocalSettings;
int selectedLanguage;
public Translate()
{
this.InitializeComponent();
foreach (CultureInfo culture in CultureInfo.GetCultures(CultureTypes.AllCultures))
LangList.Items.Add(culture.DisplayName);
}
private async void export_Click(object sender, RoutedEventArgs e)
{
FileSavePicker picker = new FileSavePicker();
picker.CommitButtonText = "Export";
picker.DefaultFileExtension = ".xml";
picker.SuggestedFileName = "foxtube_langpack_" + CultureInfo.GetCultures(CultureTypes.AllCultures)[selectedLanguage];
picker.SuggestedStartLocation = PickerLocationId.Desktop;
picker.FileTypeChoices.Add("Language pack scheme", new List<string>() { ".xml" });
StorageFile file = await picker.PickSaveFileAsync();
if(file != null)
await FileIO.WriteTextAsync(file, GetPackage(selectedLanguage));
}
private void LangList_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
selectedLanguage = LangList.SelectedIndex;
greenResult.Visibility = Visibility.Collapsed;
denied.Visibility = Visibility.Collapsed;
if (settings.Values[CultureInfo.GetCultures(CultureTypes.AllCultures)[selectedLanguage] + "_sent"] == null)
{
export.IsEnabled = true;
upload.IsEnabled = true;
submitNotification.Visibility = Visibility.Visible;
}
else
{
export.IsEnabled = false;
upload.IsEnabled = false;
denied.Visibility = Visibility.Visible;
}
}
private async void upload_Click(object sender, RoutedEventArgs e)
{
FileOpenPicker picker = new FileOpenPicker()
{
CommitButtonText = "Upload",
SuggestedStartLocation = PickerLocationId.Desktop
};
picker.FileTypeFilter.Clear();
picker.FileTypeFilter.Add(".xml");
StorageFile file = await picker.PickSingleFileAsync();
if (file != null)
{
MailMessage msg = new MailMessage();
msg.To.Add("foxgameofficial+foxtube@gmail.com");
msg.From = new MailAddress("foxgameofficial+foxtube@gmail.com");
msg.Subject = "FoxTube language pack contribution";
msg.Body = string.Format("Language: {0}\nLanguage code: {1}", CultureInfo.GetCultures(CultureTypes.AllCultures)[selectedLanguage].EnglishName, CultureInfo.GetCultures(CultureTypes.AllCultures)[selectedLanguage]);
msg.Attachments.Add(new Attachment(file.Path));
SmtpClient client = new SmtpClient("smtp.gmail.com", 587);
client.EnableSsl = true;
client.Credentials = SecretsVault.EmailCredential;
upload.IsEnabled = false;
export.IsEnabled = false;
uploadingProgress.Visibility = Visibility.Visible;
try
{
client.Send(msg);
greenResult.Visibility = Visibility.Visible;
submitNotification.Visibility = Visibility.Collapsed;
settings.Values.Add(CultureInfo.GetCultures(CultureTypes.AllCultures)[selectedLanguage] + "_sent", true);
}
catch
{
MessageDialog message = new MessageDialog("We were unable to send your feedback due to connection problems or internal server error. Please, try again later.", "Failed to send your feedback");
await message.ShowAsync();
export.IsEnabled = true;
upload.IsEnabled = true;
}
uploadingProgress.Visibility = Visibility.Collapsed;
}
}
public string GetPackage(int cultureIndex)
{
return "langpack";
}
}
}