Example #1
0
        /// <summary>
        /// Creates a LoginDialog outside of the current window.
        /// </summary>
        /// <param name="window">The window that is the parent of the dialog.</param>
        /// <param name="title">The title of the LoginDialog.</param>
        /// <param name="message">The message contained within the LoginDialog.</param>
        /// <param name="settings">Optional settings that override the global metro dialog settings.</param>
        /// <returns>The text that was entered or null (Nothing in Visual Basic) if the user cancelled the operation.</returns>
        public static LoginDialogData ShowModalLoginExternal(this MetroWindow window, string title, string message, LoginDialogSettings settings = null)
        {
            var win = CreateModalExternalWindow(window);

            settings = settings ?? new LoginDialogSettings();

            //create the dialog control
            LoginDialog dialog = new LoginDialog(win, settings)
            {
                Title   = title,
                Message = message
            };

            SetDialogFontSizes(settings, dialog);

            win.Content = dialog;

            LoginDialogData result = null;

            dialog.WaitForButtonPressAsync().ContinueWith(task =>
            {
                result = task.Result;
                win.Invoke(win.Close);
            });

            HandleOverlayOnShow(settings, window);
            win.ShowDialog();
            HandleOverlayOnHide(settings, window);
            return(result);
        }
Example #2
0
 /// <summary>
 /// При зауске программы отображаем окно ввода логина/пароля
 /// </summary>
 private async void LogIn()
 {
     loginResult = await this.ShowLoginAsync("Hello, new user", "Please, enter your login / password",
         new LoginDialogSettings { ColorScheme = this.MetroDialogOptions.ColorScheme });
 }
 private bool PerformLogin(LoginData credentials) {
     if (!failedLogin.Contains(credentials.User)) {
         if (credentials.IsManual) {
             GameModel model = ProfileManager.CurrentProfile.GameModel;
             if (ConfigurationManager.GetConfiguration(model).IsManualLoginSupported) {
                 Login(credentials.User, PassEncrypt.ConvertToUnsecureString(credentials.SecurePassword), true);
                 return true;
             }
         }
         if (credentials.IsCorrect) {
             LoginDialogData loginData = new LoginDialogData() {
                 Username = credentials.User,
                 Password = PassEncrypt.ConvertToUnsecureString(credentials.SecurePassword)
             };
             ShowLoggingInDialog(loginData);
             return true;
         }
     }
     return false;
 }
 private async void ShowLoggingInDialog(LoginDialogData loginData) {
     MainWindow MainWindow = App.Kernel.Get<MainWindow>();
     MetroDialogSettings settings = new MetroDialogSettings() {
         ColorScheme = MetroDialogColorScheme.Accented,
         NegativeButtonText = LanguageManager.Model.CancelButton
     };
     controller = await MainWindow.ShowProgressAsync(LanguageManager.Model.LoginLogIn, String.Empty, true, settings);
     Login(loginData.Username, loginData.Password, false);
 }
 private async void metroWindow_Loaded(object sender, RoutedEventArgs e)
 {
     LoginDialogData x=new LoginDialogData();
         x=await this.ShowLoginAsync("Login","Please Login to Use the Application",null);
         //MessageBox.Show("UserName: "******" Password: " + x.Password);
 }
 private void HandleLoginClose(LoginDialogData rslt)
 {
     // if they hit cancel, then rslt == null, else it contains user name and password
 }