Пример #1
0
        private async Task NewUserLogin(RoutedEventArgs e)
        {
            if (userId != null)
            {
                MessageBox.Show("Already logged in", "Error", MessageBoxButton.OK, MessageBoxImage.Information);
                return;
            }

            LoginDialog loginWindow  = new LoginDialog();
            bool?       dialogResult = loginWindow.ShowDialog();

            if (dialogResult.HasValue)
            {
                if (dialogResult.Value)
                {
                    var loginName = loginWindow.LoginName;
                    await StartChatting(loginName, e);
                }
                else
                {
                    await AppendLineToChatBox("Login aborted.");
                }
            }
            else
            {
                await AppendLineToChatBox("Something went wrong (example i forgot the window close event)");
            }
        }
Пример #2
0
        static void Main()
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            Thread splashThread = new Thread(new ThreadStart(
                                                 delegate
            {
                splashScreen = new SplashScreen();
                Application.Run(splashScreen);
            }
                                                 ));

            splashThread.SetApartmentState(ApartmentState.STA);
            splashThread.Start();

            using (LoginDialog loginForm = new LoginDialog())
            {
                loginForm.Load += new EventHandler(loginForm_Load);


                if (loginForm.ShowDialog() == DialogResult.OK)
                {
                    Application.Run(new Client(loginForm.LoginInfoName));
                }
                else
                {
                    Application.Exit();
                }
            }
        }
 private void MainWindow_OnLoaded(object sender, RoutedEventArgs e)
 {
     var loginWindow = new LoginDialog();
     loginWindow.Owner = this;
     loginWindow.WindowStartupLocation = WindowStartupLocation.CenterOwner;
     loginWindow.ShowDialog();
     if (loginWindow.LoggedIn)
     {
         ButtonSend.IsEnabled = true;
         client.DataMessageArrived += ClientOnDataMessageArrived;
         SessionId = loginWindow.SessionId;
     }
 }