Ejemplo n.º 1
0
        /// <summary>
        /// This is used to initialize the User control and set the binding and its properties dynamically so that we can set the
        /// Password box secure string property in view model.
        /// </summary>
        public LoginView()
        {
            InitializeComponent();
            Binding passwordBinding = new Binding(SecurePasswordProperty.Name);

            passwordBinding.ValidatesOnDataErrors = true;
            passwordBinding.UpdateSourceTrigger   = UpdateSourceTrigger.PropertyChanged;
            MyPassword.SetBinding(SecurePasswordProperty, passwordBinding);
        }
Ejemplo n.º 2
0
        private async Task InitNetAccess()
        {
            Pass = new MyPassword();
            while (!Pass.GetLoginInfoFromRegistry())
            {
                var result = await Task.Run(() =>
                                            MessageBox.Show("ユーザー情報を入力してください。", "Password not found", MessageBoxButton.OKCancel));

                if (result == MessageBoxResult.Cancel)
                {
                    // Quit the program
                    Application.Current.Shutdown();
                    return;
                }
                await RunProcessNoWindow("powershell.exe", @"-ExecutionPolicy Bypass -File .\SavePassword.ps1");
            }

            Net = new NetAccess();

            while (!IsLoggedIn)
            {
                Net.SupplyLoginInfo(Pass.CompanyCode, Pass.UserId, Pass.Password);

                if ((IsLoggedIn = await Net.Login()) == true)
                {
                    break;
                }

                var result = await Task.Run(() =>
                                            MessageBox.Show("ユーザー情報が間違っているようです。入れ直しますか?", "Unable to login", MessageBoxButton.OKCancel));

                if (result == MessageBoxResult.Cancel)
                {
                    // Quit the program
                    Application.Current.Shutdown();
                    return;
                }
                await RunProcessNoWindow("powershell.exe", @"-ExecutionPolicy Bypass -File .\ClearPassword.ps1");
                await RunProcessNoWindow("powershell.exe", @"-ExecutionPolicy Bypass -File .\SavePassword.ps1");

                Pass.GetLoginInfoFromRegistry();
            }
        }
Ejemplo n.º 3
0
 private void ShowPasswordCharsCheckBox_Checked(object sender, RoutedEventArgs e)
 {
     MyPassword.Visibility = System.Windows.Visibility.Visible;
     MyPassword.Focus();
 }