• IsolatedStorage实现软件登陆时的密码验证


    Login.xaml:

    public partial class Login : PhoneApplicationPage
    {
    private const string pwd = "pwd";

    public Login()
    {
    InitializeComponent();
    this.Loaded += new RoutedEventHandler(Login_Loaded);
    }

    void Login_Loaded(object sender, RoutedEventArgs e)
    {
    if (!IsolatedStorageSettings.ApplicationSettings.Contains(pwd))
    {
    textBlock.Text = "请设定密码:";
    }
    }

    private void buttonReset_Click(object sender, RoutedEventArgs e)
    {
    textBox.Text = "";
    }

    private void buttonOK_Click(object sender, RoutedEventArgs e)
    {
    if (!IsolatedStorageSettings.ApplicationSettings.Contains(pwd))
    {
    IsolatedStorageSettings.ApplicationSettings[pwd] = textBox.Text;
    IsolatedStorageSettings.ApplicationSettings.Save();
    NavigationService.Navigate(new Uri("/MainPage.xaml", UriKind.Relative));
    }
    else
    {
    if (textBox.Text.Equals(IsolatedStorageSettings.ApplicationSettings[pwd] as string))
    {
    NavigationService.Navigate(new Uri("/MainPage.xaml", UriKind.Relative));
    }
    else
    {
    textBlock.Text = "请重新输入:";
    textBox.Text = "";
    }
    }
    }
    }

    MainPage.xaml:

    public partial class MainPage : PhoneApplicationPage
    {
    private const string pwd = "pwd";

    // 构造函数
    public MainPage()
    {
    InitializeComponent();
    this.Loaded += new RoutedEventHandler(MainPage_Loaded);
    this.BackKeyPress += new EventHandler<System.ComponentModel.CancelEventArgs>(MainPage_BackKeyPress);
    }

    void MainPage_BackKeyPress(object sender, System.ComponentModel.CancelEventArgs e)
    {
    MessageBoxResult msgRst = MessageBox.Show("要退出到登陆界面吗?", "提示", MessageBoxButton.OKCancel);
    if (msgRst == MessageBoxResult.Cancel)
    {
    e.Cancel = true;
    }
    }

    void MainPage_Loaded(object sender, RoutedEventArgs e)
    {
    textBlock.Text = IsolatedStorageSettings.ApplicationSettings[pwd] as string;

    }

    }
  • 相关阅读:
    增加正则项Regularization to Prevent Overfitting
    feature_column、fc.input_layer以及各种类型的column如何转化
    input_fn如何读取数据
    matplotlib.pyplot如何绘制多张子图
    机器学习之杂乱笔记
    Adobe Flash Player
    LSTM/GRU-讲得非常细致
    anaconda python36 tensorflow virtualenv
    畅通工程-HZNU寒假集训
    食物链-HZUN寒假集训
  • 原文地址:https://www.cnblogs.com/liubaicai/p/2306705.html
Copyright © 2020-2023  润新知