Archived
1
0
This repository has been archived on 2026-04-22. You can view files and clone it. You cannot open issues or pull requests or push a commit.
Files
FoxTube/FoxTube/Settings.xaml.cs
T
Michael Gordeev f97cebb958 Trending is coming
2018-06-07 12:58:48 +03:00

142 lines
5.4 KiB
C#

using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Runtime.InteropServices.WindowsRuntime;
using Windows.ApplicationModel;
using System.Globalization;
using Windows.Foundation;
using Windows.Foundation.Collections;
using Windows.Storage;
using Windows.UI.Text;
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
{
/// <summary>
/// An empty page that can be used on its own or navigated to within a Frame.
/// </summary>
public sealed partial class Settings : Page
{
ApplicationDataContainer settings = ApplicationData.Current.LocalSettings;
PackageVersion ver = Package.Current.Id.Version;
public Pivot pivot;
public Feedback fb;
public Settings()
{
this.InitializeComponent();
version.Text = string.Format("{0}.{1}.{2}", ver.Major, ver.Minor, ver.Build);
pivot = content;
fb = feedbackHub.Content as Feedback;
language.SelectedIndex = (int)settings.Values["language"];
quality.SelectedIndex = (int)settings.Values["quality"];
newVideo.IsChecked = (bool)settings.Values["newVideoNotification"];
newComment.IsChecked = (bool)settings.Values["newCommentNotification"];
newPost.IsChecked = (bool)settings.Values["newPostNotification"];
messages.IsChecked = (bool)settings.Values["newmessagesNotification"];
mobileWarning.IsOn = (bool)settings.Values["moblieWarning"];
autoplay.IsOn = (bool)settings.Values["videoAutoplay"];
foreach (CultureInfo culture in CultureInfo.GetCultures(CultureTypes.AllCultures))
region.Items.Add(culture.DisplayName);
}
private void language_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
if ((int)settings.Values["language"] != language.SelectedIndex)
{
settings.Values["language"] = language.SelectedIndex;
restartNote.Visibility = Visibility.Visible;
}
}
private void quality_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
if ((int)settings.Values["quality"] != quality.SelectedIndex)
settings.Values["quality"] = quality.SelectedIndex;
}
private void notification_IsEnabledChanged(object sender, RoutedEventArgs e)
{
if ((bool)settings.Values["newVideoNotification"] != newVideo.IsChecked)
settings.Values["newVideoNotification"] = newVideo.IsChecked;
if ((bool)settings.Values["newPostNotification"] != newPost.IsChecked)
settings.Values["newPostNotification"] = newPost.IsChecked;
if ((bool)settings.Values["newCommentNotification"] != newComment.IsChecked)
settings.Values["newCommentNotification"] = newComment.IsChecked;
if ((bool)settings.Values["newmessagesNotification"] != messages.IsChecked)
settings.Values["newmessagesNotification"] = messages.IsChecked;
if ((bool)settings.Values["moblieWarning"] != mobileWarning.IsOn)
settings.Values["moblieWarning"] = mobileWarning.IsOn;
if ((bool)settings.Values["videoAutoplay"] != autoplay.IsOn)
settings.Values["videoAutoplay"] = autoplay.IsOn;
}
private void toGeneral_Click(object sender, RoutedEventArgs e)
{
content.SelectedIndex = 0;
}
private void toFeedback_Click(object sender, RoutedEventArgs e)
{
content.SelectedIndex = 2;
}
private void toTranslate_Click(object sender, RoutedEventArgs e)
{
content.SelectedIndex = 4;
}
private void content_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
toGeneral.FontWeight = FontWeights.Normal;
toAccount.FontWeight = FontWeights.Normal;
toFeedback.FontWeight = FontWeights.Normal;
toAbout.FontWeight = FontWeights.Normal;
toTranslate.FontWeight = FontWeights.Normal;
if (content.SelectedIndex == 0)
toGeneral.FontWeight = FontWeights.Bold;
else if (content.SelectedIndex == 1)
toAccount.FontWeight = FontWeights.Bold;
else if (content.SelectedIndex == 2)
toFeedback.FontWeight = FontWeights.Bold;
else if (content.SelectedIndex == 3)
toAbout.FontWeight = FontWeights.Bold;
else if (content.SelectedIndex == 4)
toTranslate.FontWeight = FontWeights.Bold;
}
private void toAccount_Click(object sender, RoutedEventArgs e)
{
content.SelectedIndex = 1;
}
private void toAbout_Click(object sender, RoutedEventArgs e)
{
content.SelectedIndex = 3;
}
private void region_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
settings.Values["region"] = CultureInfo.GetCultures(CultureTypes.AllCultures)[region.SelectedIndex];
}
}
}