Add DashboardWindow, controlls to close the login than open the dashboard
This commit is contained in:
@@ -3,6 +3,6 @@ using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace Server_Dashboard {
|
||||
class MainViewModel : BaseViewModel {
|
||||
class DashboardViewModel : BaseViewModel {
|
||||
}
|
||||
}
|
||||
9
Server Dashboard/ViewModels/Interfaces/IWindowHelper.cs
Normal file
9
Server Dashboard/ViewModels/Interfaces/IWindowHelper.cs
Normal file
@@ -0,0 +1,9 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace Server_Dashboard {
|
||||
interface IWindowHelper {
|
||||
Action Close { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -1,11 +1,12 @@
|
||||
using System;
|
||||
using Server_Dashboard.Views;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Security;
|
||||
using System.Text;
|
||||
using System.Windows.Input;
|
||||
|
||||
namespace Server_Dashboard {
|
||||
class LoginViewModel : BaseViewModel {
|
||||
class LoginViewModel : BaseViewModel, IWindowHelper {
|
||||
|
||||
private string username;
|
||||
|
||||
@@ -28,7 +29,7 @@ namespace Server_Dashboard {
|
||||
OnPropertyChanged(nameof(errorText));
|
||||
}
|
||||
}
|
||||
|
||||
public Action Close { get ; set; }
|
||||
|
||||
public LoginViewModel() {
|
||||
LoginCommand = new RelayCommand(Login);
|
||||
@@ -39,7 +40,10 @@ namespace Server_Dashboard {
|
||||
private void Login(object parameter) {
|
||||
if (!String.IsNullOrWhiteSpace(Username) && !String.IsNullOrWhiteSpace((parameter as IHavePassword).SecurePassword.Unsecure())) {
|
||||
if (DatabaseHandler.CheckLogin(Username, (parameter as IHavePassword).SecurePassword.Unsecure())) {
|
||||
Console.WriteLine();
|
||||
DashboardWindow window = new DashboardWindow();
|
||||
window.DataContext = new DashboardViewModel();
|
||||
window.Show();
|
||||
Close?.Invoke();
|
||||
} else {
|
||||
ErrorText = "Username or password is wrong.";
|
||||
return;
|
||||
|
||||
Reference in New Issue
Block a user