Skip to content

Instantly share code, notes, and snippets.

@BrianJVarley
Created December 15, 2015 12:38
Show Gist options
  • Save BrianJVarley/178b93c9acca301f6f4d to your computer and use it in GitHub Desktop.
Save BrianJVarley/178b93c9acca301f6f4d to your computer and use it in GitHub Desktop.
using MongoDBApp.Services;
using MongoDBApp.Utility;
using MongoDBApp.ViewModels;
using MongoDBApp.Views;
using System;
using System.Collections.Generic;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Threading.Tasks;
using System.Windows;
namespace MongoDBApp
{
/// <summary>
/// Interaction logic for App.xaml
/// </summary>
public partial class App : Application
{
private static IDialogService dialogService = new DialogService();
private static IAuthenticationService authoService = new AuthenticationService();
private LoginView login;
private ApplicationView app;
public App()
{
Messenger.Default.Register<string>(this, OnLoggedInMessageReceived);
Messenger.Default.Register<bool>(this, OnLoggedOutMessageReceived);
}
private void OnLoggedInMessageReceived(string username)
{
app = new ApplicationView();
var appVM = new ApplicationViewModel();
app.DataContext = appVM;
app.Show();
login.Hide();
}
private void OnLoggedOutMessageReceived(bool isLoggedIn)
{
login = new LoginView();
var loginVM = new LoginViewModel(dialogService, authoService);
login.DataContext = loginVM;
login.Show();
app.Close();
}
protected override void OnStartup(StartupEventArgs e)
{
base.OnStartup(e);
login = new LoginView();
var loginVM = new LoginViewModel(dialogService,authoService);
login.DataContext = loginVM;
login.Show();
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment