Vastgelopen
This commit is contained in:
10
DoctorApp/ViewModels/ClientInfoViewModel.cs
Normal file
10
DoctorApp/ViewModels/ClientInfoViewModel.cs
Normal file
@@ -0,0 +1,10 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace DoctorApp.ViewModels
|
||||
{
|
||||
class ClientInfoViewModel
|
||||
{
|
||||
}
|
||||
}
|
||||
44
DoctorApp/ViewModels/LoginViewModel.cs
Normal file
44
DoctorApp/ViewModels/LoginViewModel.cs
Normal file
@@ -0,0 +1,44 @@
|
||||
|
||||
using DoctorApp.Utils;
|
||||
using GalaSoft.MvvmLight.Command;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Input;
|
||||
|
||||
namespace DoctorApp.ViewModels
|
||||
{
|
||||
class LoginViewModel : ObservableObject
|
||||
{
|
||||
public string Username { get; set; }
|
||||
public ICommand LoginCommand { get; set; }
|
||||
|
||||
public bool LoginStatus { get; set; }
|
||||
|
||||
public bool InvertedLoginStatus { get; set; }
|
||||
|
||||
private MainWindowViewModel mainWindowViewModel;
|
||||
public LoginViewModel(MainWindowViewModel mainWindowViewModel)
|
||||
{
|
||||
this.mainWindowViewModel = mainWindowViewModel;
|
||||
LoginCommand = new RelayCommand<object>((parameter) =>
|
||||
{
|
||||
//TODO send username and password to server
|
||||
this.mainWindowViewModel.client.tryLogin(Username, ((PasswordBox)parameter).Password);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
|
||||
internal void setLoginStatus(bool status)
|
||||
{
|
||||
this.mainWindowViewModel.InfoModel.ConnectedToServer = status;
|
||||
this.InvertedLoginStatus = !status;
|
||||
if (status)
|
||||
{
|
||||
this.mainWindowViewModel.SelectedViewModel = new MainViewModel(mainWindowViewModel);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
17
DoctorApp/ViewModels/MainViewModel.cs
Normal file
17
DoctorApp/ViewModels/MainViewModel.cs
Normal file
@@ -0,0 +1,17 @@
|
||||
using DoctorApp.Utils;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace DoctorApp.ViewModels
|
||||
{
|
||||
class MainViewModel : ObservableObject
|
||||
{
|
||||
public MainWindowViewModel MainWindowViewModel { get; set; }
|
||||
|
||||
public MainViewModel(MainWindowViewModel mainWindowViewModel)
|
||||
{
|
||||
MainWindowViewModel = mainWindowViewModel;
|
||||
}
|
||||
}
|
||||
}
|
||||
25
DoctorApp/ViewModels/MainWindowViewModel.cs
Normal file
25
DoctorApp/ViewModels/MainWindowViewModel.cs
Normal file
@@ -0,0 +1,25 @@
|
||||
using DoctorApp.Models;
|
||||
using DoctorApp.Utils;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace DoctorApp.ViewModels
|
||||
{
|
||||
class MainWindowViewModel
|
||||
{
|
||||
public Info InfoModel { get; set; }
|
||||
|
||||
public ObservableObject SelectedViewModel { get; set; }
|
||||
public Client client { get; }
|
||||
|
||||
public MainWindowViewModel(Client client)
|
||||
{
|
||||
this.InfoModel = new Info();
|
||||
this.client = client;
|
||||
LoginViewModel loginViewModel = new LoginViewModel(this);
|
||||
SelectedViewModel = loginViewModel;
|
||||
this.client.SetLoginViewModel(loginViewModel);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user