efb07fda10
227: Additional fixes (final) Introduced new settings storing system Related Work Items: #222, #227
127 lines
4.5 KiB
C#
127 lines
4.5 KiB
C#
using System.Globalization;
|
|
using System.Linq;
|
|
using Windows.ApplicationModel.Core;
|
|
using Windows.UI;
|
|
using Windows.UI.Xaml;
|
|
using Windows.UI.Xaml.Controls;
|
|
|
|
namespace FoxTube.Pages.SettingsPages
|
|
{
|
|
/// <summary>
|
|
/// Settings page with general preferences
|
|
/// </summary>
|
|
public sealed partial class General : Page
|
|
{
|
|
public General()
|
|
{
|
|
InitializeComponent();
|
|
|
|
language.SelectedItem = language.Items.Find(i => ((ComboBoxItem)i).Tag.ToString() == SettingsStorage.Language);
|
|
CultureInfo.GetCultures(CultureTypes.AllCultures).FindAll(i => !i.IsNeutralCulture).ForEach(i =>
|
|
{
|
|
region.Items.Add(new ComboBoxItem
|
|
{
|
|
Content = i.DisplayName,
|
|
Tag = i.IetfLanguageTag
|
|
});
|
|
if (i.IetfLanguageTag == SettingsStorage.Region)
|
|
region.SelectedItem = region.Items.Last();
|
|
});
|
|
safeSearch.SelectedIndex = SettingsStorage.SafeSearch;
|
|
|
|
quality.SelectedItem = quality.Items.ToList().Find(i => ((ComboBoxItem)i).Tag.ToString() == SettingsStorage.VideoQuality);
|
|
mobileWarning.IsOn = SettingsStorage.CheckConnection;
|
|
autoplay.IsOn = SettingsStorage.Autoplay;
|
|
|
|
newVideo.IsOn = SettingsStorage.VideoNotifications;
|
|
devNews.IsOn = SettingsStorage.DevNotifications;
|
|
|
|
switch(SettingsStorage.Theme)
|
|
{
|
|
case 0:
|
|
light.IsChecked = true;
|
|
break;
|
|
case 1:
|
|
dark.IsChecked = true;
|
|
break;
|
|
case 2:
|
|
system.IsChecked = true;
|
|
break;
|
|
}
|
|
}
|
|
|
|
private void language_SelectionChanged(object sender, SelectionChangedEventArgs e)
|
|
{
|
|
if (SettingsStorage.Language == (language.SelectedItem as ComboBoxItem).Tag.ToString())
|
|
return;
|
|
|
|
SettingsStorage.Language = (language.SelectedItem as ComboBoxItem).Tag.ToString();
|
|
restartNote.Visibility = Visibility.Visible;
|
|
}
|
|
|
|
private void quality_SelectionChanged(object sender, SelectionChangedEventArgs e)
|
|
{
|
|
SettingsStorage.VideoQuality = (quality.SelectedItem as ComboBoxItem).Tag as string;
|
|
}
|
|
|
|
private void mobileWarning_Toggled(object sender, RoutedEventArgs e)
|
|
{
|
|
SettingsStorage.CheckConnection = mobileWarning.IsOn;
|
|
}
|
|
|
|
private void autoplay_Toggled(object sender, RoutedEventArgs e)
|
|
{
|
|
SettingsStorage.Autoplay = autoplay.IsOn;
|
|
}
|
|
|
|
private void notification_IsEnabledChanged(object sender, RoutedEventArgs e)
|
|
{
|
|
SettingsStorage.VideoNotifications = newVideo.IsOn;
|
|
}
|
|
|
|
private void region_SelectionChanged(object sender, SelectionChangedEventArgs e)
|
|
{
|
|
SettingsStorage.Region = CultureInfo.GetCultures(CultureTypes.AllCultures)[region.SelectedIndex].Name;
|
|
}
|
|
|
|
private void safeSearch_SelectionChanged(object sender, SelectionChangedEventArgs e)
|
|
{
|
|
SettingsStorage.SafeSearch = safeSearch.SelectedIndex;
|
|
}
|
|
|
|
private void RadioButton_Checked(object sender, RoutedEventArgs e)
|
|
{
|
|
if (sender == light && SettingsStorage.Theme != 0)
|
|
{
|
|
SettingsStorage.Theme = 0;
|
|
Methods.MainPage.RequestedTheme = ElementTheme.Light;
|
|
}
|
|
else if (sender == dark && SettingsStorage.Theme != 1)
|
|
{
|
|
SettingsStorage.Theme = 1;
|
|
Methods.MainPage.RequestedTheme = ElementTheme.Dark;
|
|
}
|
|
else if (sender == system && SettingsStorage.Theme != 2)
|
|
{
|
|
SettingsStorage.Theme = 2;
|
|
Color uiTheme = new Windows.UI.ViewManagement.UISettings().GetColorValue(Windows.UI.ViewManagement.UIColorType.Background);
|
|
if (uiTheme == Colors.Black)
|
|
Methods.MainPage.RequestedTheme = ElementTheme.Dark;
|
|
else
|
|
Methods.MainPage.RequestedTheme = ElementTheme.Light;
|
|
}
|
|
Methods.MainPage.SetTitleBar();
|
|
}
|
|
|
|
private void Button_Click(object sender, RoutedEventArgs e)
|
|
{
|
|
CoreApplication.Exit();
|
|
}
|
|
|
|
private void devNews_Toggled(object sender, RoutedEventArgs e)
|
|
{
|
|
SettingsStorage.DevNotifications = devNews.IsOn;
|
|
}
|
|
}
|
|
}
|