public void ShowMainWindow() { if (!IsLoggedIn) { new MainWindow().Show(); return; } if (MainWindow == null && !IsLoggedIn) { return; } else if (MainWindow == null && IsLoggedIn) { MainWindow = new ContactListWindow(); } if (MainWindow.Title == "Log In") { MainWindow = new ContactListWindow(); } if (MainWindow.IsVisible) { if (MainWindow.WindowState == WindowState.Minimized) { MainWindow.WindowState = WindowState.Normal; } MainWindow.Activate(); } else { MainWindow.Show(); } }
private async void Next_Clicked(object sender, RoutedEventArgs e) { if (!Utils.HasText(txt_ID) || !Utils.HasText(txt_Secret) || !Utils.HasText(txt_Username) || !Utils.HasText(txt_Extension)) { MessageBox.Show("Alle velden dienen ingevuld te worden."); return; } ToggleAllFields(false); var User = new User { Username = txt_Username.Text, Password = txt_Password.Password, ClientID = txt_ID.Password, ClientSecret = txt_Secret.Password, Extension = txt_Extension.Text }; var response = await NetworkManager.CheckLogin(User); ToggleAllFields(true); if (response == null || response.access_token == null) { MessageBox.Show("Onjuiste waarden! Probeer het opnieuw."); return; } var UserSettings = App.UserSettings; if (UserSettings == null) { UserSettings = new User(); } UserSettings.Username = txt_Username.Text; UserSettings.Password = txt_Password.Password; UserSettings.ClientID = txt_ID.Password; UserSettings.ClientSecret = txt_Secret.Password; UserSettings.Extension = txt_Extension.Text; UserSettings.AccessToken = response.access_token; UserSettings.RefreshToken = response.refresh_token; App.DatabaseManager.SaveUser(UserSettings); var page = new ContactListWindow(); page.Show(); App.IsLoggedIn = true; ((App)Application.Current).CreateContextMenu(); this.Close(); ((App)Application.Current).MainWindow = page; }
private async void Application_Startup(object sender, StartupEventArgs e) { AppCenter.Start("83c694cd-7de0-4536-a606-e58251e96c26", typeof(Analytics), typeof(Crashes)); StartTimer(); _notifyIcon = new System.Windows.Forms.NotifyIcon(); DatabaseManager = new DatabaseManager(); var Settings = DatabaseManager.GetUser(); UserSettings = Settings; if (App.UserSettings == null) { MainWindow = new MainWindow(); MainWindow.Show(); } else { var User = new User { Username = Settings.Username, Password = Settings.Password, ClientID = Settings.ClientID, ClientSecret = Settings.ClientSecret, Extension = Settings.Extension }; var response = await NetworkManager.CheckLogin(User); if (response == null || response.access_token == null) { MainWindow = new MainWindow(); MainWindow.Show(); return; } App.UserSettings.AccessToken = response.access_token; App.UserSettings.RefreshToken = response.refresh_token; App.DatabaseManager.SaveUser(UserSettings); MainWindow = new ContactListWindow(); IsLoggedIn = true; } UserSettings = DatabaseManager.GetUser(); MainWindow.Closing += MainWindow_Closing; using (var mgr = UpdateManager.GitHubUpdateManager("https://github.com/TGlev/C2D")) { var result = await mgr.Result.UpdateApp(); if (result?.Version.ToString() != null) { MessageBox.Show("Er is een update geïnstalleerd! Start de applicatie opnieuw op om deze te activeren."); } } }
public ContactEditWindow(Contact c, ContactListWindow window) { InitializeComponent(); this.ToEdit = c; this.Window = window; btn_Delete.IsEnabled = false; if (ToEdit != null) { FillFields(); } MadeChanges = false; btn_Save.IsEnabled = MadeChanges; }