Example #1
0
        private void ApplicationStart(object sender, StartupEventArgs e)
        {
            EventManager.RegisterClassHandler(typeof(TextBox), TextBox.KeyDownEvent, new KeyEventHandler(TextBox_KeyDown));
            EventManager.RegisterClassHandler(typeof(CheckBox), CheckBox.KeyDownEvent, new KeyEventHandler(CheckBox_KeyDown));
            //Disable shutdown when the dialog closes
            Current.ShutdownMode = ShutdownMode.OnExplicitShutdown;

            var dialog = new LoginWindow();

            if (dialog.ShowDialog() == true)
            {
                var mainWindow = new MainWindow(dialog.currentUser);
                //Re-enable normal shutdown mode.
                Current.ShutdownMode = ShutdownMode.OnMainWindowClose;
                Current.MainWindow   = mainWindow;
                mainWindow.Show();
            }
            else
            {
                MessageBox.Show("Отказан достъп.", "Грешка", MessageBoxButton.OK);
                Current.Shutdown(-1);
            }
        }
Example #2
0
		private void ApplicationStart(object sender, StartupEventArgs e)
		{
			EventManager.RegisterClassHandler(typeof(TextBox), TextBox.KeyDownEvent, new KeyEventHandler(TextBox_KeyDown));
			EventManager.RegisterClassHandler(typeof(CheckBox), CheckBox.KeyDownEvent, new KeyEventHandler(CheckBox_KeyDown));
			//Disable shutdown when the dialog closes
			Current.ShutdownMode = ShutdownMode.OnExplicitShutdown;

			var dialog = new LoginWindow();

			if (dialog.ShowDialog() == true)
			{
				var mainWindow = new MainWindow(dialog.currentUser);
				//Re-enable normal shutdown mode.
				Current.ShutdownMode = ShutdownMode.OnMainWindowClose;
				Current.MainWindow = mainWindow;
				mainWindow.Show();
			}
			else
			{
				MessageBox.Show("Отказан достъп.", "Грешка", MessageBoxButton.OK);
				Current.Shutdown(-1);
			}
		}