file360

Log | Files | Refs

SecurityPage.xaml.cs (3200B)


      1 using System;
      2 using System.Collections.Generic;
      3 using System.Linq;
      4 using System.Net;
      5 using System.Windows;
      6 using System.Windows.Controls;
      7 using System.Windows.Navigation;
      8 using Microsoft.Phone.Controls;
      9 using Microsoft.Phone.Shell;
     10 using Microsoft.Devices.Sensors;
     11 using File360.Resources;
     12 using System.IO.IsolatedStorage;
     13 using System.Windows.Media;
     14 using System.Windows.Input;
     15 
     16 namespace File360
     17 {
     18     public partial class SecurityPage : PhoneApplicationPage
     19     {
     20         IsolatedStorageSettings appSettings = IsolatedStorageSettings.ApplicationSettings;
     21         public SecurityPage()
     22         {
     23             InitializeComponent();
     24             if (!Accelerometer.IsSupported)
     25             {
     26                 shake.IsEnabled = false;
     27             }
     28             Shaker_Checker();
     29             pb.Background = (SolidColorBrush)Resources["PhoneBackgroundBrush"];
     30             pb.Foreground = (SolidColorBrush)Resources["PhoneForegroundBrush"];
     31             pb.BorderBrush = (SolidColorBrush)Resources["PhoneBackgroundBrush"];
     32             pb.InputScope = new InputScope { Names = { new InputScopeName { NameValue = InputScopeNameValue.Number } } };
     33         }
     34 
     35         void pb_GotFocus(object sender, RoutedEventArgs e)
     36         {
     37             pb.Background = (SolidColorBrush)Resources["PhoneBackgroundBrush"];
     38             pb.Foreground = (SolidColorBrush)Resources["PhoneForegroundBrush"];
     39             pb.MaxLength = 5;
     40             pb.BorderBrush = (SolidColorBrush)Resources["PhoneBackgroundBrush"];
     41             pb.TextAlignment = TextAlignment.Center;
     42         }
     43 
     44         #region ToggleSwitcher
     45 
     46         private void shake_Checked(object sender, RoutedEventArgs e)
     47         {
     48             appSettings["Shaker"] = "On";
     49             appSettings.Save();
     50         }
     51 
     52         private void shake_Unchecked(object sender, RoutedEventArgs e)
     53         {
     54             appSettings["Shaker"] = "Off";
     55             appSettings.Save();
     56         }
     57 
     58         private void passw_Checked(object sender, RoutedEventArgs e)
     59         {
     60             appSettings["Passer"] = "On";
     61         }
     62 
     63         private void passw_Unchecked(object sender, RoutedEventArgs e)
     64         {
     65             appSettings["Passer"] = "Off";
     66         }
     67 
     68 
     69         private void PSetter(object sender, TextChangedEventArgs e)
     70         {
     71 
     72             appSettings["PasswordValue"] = pb.Text;
     73         }
     74 
     75         #endregion
     76 
     77         #region SettingsUpdater
     78 
     79         public void Shaker_Checker()
     80         {
     81                 if ((string)appSettings["Shaker"] == "On")
     82                 {
     83                     shake.IsChecked = true;
     84                 }
     85 
     86                 if ((string)appSettings["Shaker"] == "Off")
     87                 {
     88                     shake.IsChecked = false;
     89                 }
     90 
     91                 if ((string)appSettings["Passer"] == "On")
     92                 {
     93                     passw.IsChecked = true;
     94                 }
     95 
     96                 if ((string)appSettings["Passer"] == "Off")
     97                 {
     98                     passw.IsChecked = false;
     99                 }
    100         }
    101         #endregion
    102 
    103 
    104 
    105         private void Video_Tap(object sender, EventArgs e)
    106         {
    107             NavigationService.Navigate(new Uri("/VideoPlayer.xaml", UriKind.Relative));
    108         }
    109     }
    110 }