private async void DecryptAndLoadAction()
        {
            CustomDialog customDialog = new CustomDialog()
            {
                Title = LocalizationManager.GetStringByKey("String_Header_MasterPassword")
            };

            CredentialsMasterPasswordViewModel credentialsMasterPasswordViewModel = new CredentialsMasterPasswordViewModel(async instance =>
            {
                await dialogCoordinator.HideMetroDialogAsync(this, customDialog);

                if (!CredentialManager.Load(instance.Password))
                {
                    await dialogCoordinator.ShowMessageAsync(this, LocalizationManager.GetStringByKey("String_Header_WrongPassword"), LocalizationManager.GetStringByKey("String_WrongPasswordDecryptionFailed"), MessageDialogStyle.Affirmative, AppearanceManager.MetroDialog);
                }

                CheckCredentialsLoaded();

                TimerLockUIStart();
            }, instance =>
            {
                dialogCoordinator.HideMetroDialogAsync(this, customDialog);
            });

            customDialog.Content = new CredentialsMasterPasswordDialog
            {
                DataContext = credentialsMasterPasswordViewModel
            };

            await dialogCoordinator.ShowMetroDialogAsync(this, customDialog);
        }
        private async void LockUnlockAction()
        {
            if (Locked)
            {
                CustomDialog customDialogMasterPassword = new CustomDialog()
                {
                    Title = LocalizationManager.GetStringByKey("String_Header_MasterPassword")
                };

                CredentialsMasterPasswordViewModel credentialsMasterPasswordViewModel = new CredentialsMasterPasswordViewModel(async instance =>
                {
                    await dialogCoordinator.HideMetroDialogAsync(this, customDialogMasterPassword);

                    if (CredentialManager.VerifyMasterPasword(instance.Password))
                    {
                        TimerLockUIStart();
                    }
                    else
                    {
                        await dialogCoordinator.ShowMessageAsync(this, LocalizationManager.GetStringByKey("String_Header_WrongPassword"), LocalizationManager.GetStringByKey("String_WrongPassword"), MessageDialogStyle.Affirmative, AppearanceManager.MetroDialog);
                    }
                }, instance =>
                {
                    dialogCoordinator.HideMetroDialogAsync(this, customDialogMasterPassword);
                });

                customDialogMasterPassword.Content = new CredentialsMasterPasswordDialog
                {
                    DataContext = credentialsMasterPasswordViewModel
                };

                await dialogCoordinator.ShowMetroDialogAsync(this, customDialogMasterPassword);
            }
            else
            {
                TimerLockUIStop();
            }
        }
        private async void ConnectSessionAction()
        {
            Models.RemoteDesktop.RemoteDesktopSessionInfo sessionInfo = new Models.RemoteDesktop.RemoteDesktopSessionInfo
            {
                Hostname = SelectedSession.Host
            };

            if (SelectedSession.CredentialID != null) // Credentials need to be unlocked first
            {
                if (!CredentialManager.Loaded)
                {
                    CustomDialog customDialog = new CustomDialog()
                    {
                        Title = Application.Current.Resources["String_Header_MasterPassword"] as string
                    };

                    CredentialsMasterPasswordViewModel credentialsMasterPasswordViewModel = new CredentialsMasterPasswordViewModel(async instance =>
                    {
                        await dialogCoordinator.HideMetroDialogAsync(this, customDialog);

                        if (CredentialManager.Load(instance.Password))
                        {
                            CredentialInfo credentialInfo = CredentialManager.GetCredentialByID((int)SelectedSession.CredentialID);

                            if (credentialInfo == null)
                            {
                                await dialogCoordinator.ShowMessageAsync(this, Application.Current.Resources["String_Header_CredentialNotFound"] as string, Application.Current.Resources["String_CredentialNotFoundMessage"] as string, MessageDialogStyle.Affirmative, AppearanceManager.MetroDialog);

                                return;
                            }

                            sessionInfo.CustomCredentials = true;
                            sessionInfo.Username          = credentialInfo.Username;
                            sessionInfo.Password          = credentialInfo.Password;

                            ConnectSession(sessionInfo, SelectedSession.Name);
                        }
                        else
                        {
                            await dialogCoordinator.ShowMessageAsync(this, Application.Current.Resources["String_Header_WrongPassword"] as string, Application.Current.Resources["String_WrongPasswordDecryptionFailed"] as string, MessageDialogStyle.Affirmative, AppearanceManager.MetroDialog);
                        }
                    }, instance =>
                    {
                        dialogCoordinator.HideMetroDialogAsync(this, customDialog);
                    });

                    customDialog.Content = new CredentialsMasterPasswordDialog
                    {
                        DataContext = credentialsMasterPasswordViewModel
                    };

                    await dialogCoordinator.ShowMetroDialogAsync(this, customDialog);
                }
                else // Connect already unlocked
                {
                    CredentialInfo credentialInfo = CredentialManager.GetCredentialByID((int)SelectedSession.CredentialID);

                    if (credentialInfo == null)
                    {
                        await dialogCoordinator.ShowMessageAsync(this, Application.Current.Resources["String_Header_CredentialNotFound"] as string, Application.Current.Resources["String_CredentialNotFoundMessage"] as string, MessageDialogStyle.Affirmative, AppearanceManager.MetroDialog);

                        return;
                    }

                    sessionInfo.CustomCredentials = true;
                    sessionInfo.Username          = credentialInfo.Username;
                    sessionInfo.Password          = credentialInfo.Password;

                    ConnectSession(sessionInfo, SelectedSession.Name);
                }
            }
            else // Connect without credentials
            {
                ConnectSession(sessionInfo, SelectedSession.Name);
            }
        }
        private async void ConnectProfile()
        {
            Models.RemoteDesktop.RemoteDesktopSessionInfo session = new Models.RemoteDesktop.RemoteDesktopSessionInfo
            {
                Hostname = SelectedProfile.RemoteDesktop_Host
            };

            if (SelectedProfile.CredentialID > -1) // Credentials need to be unlocked first
            {
                if (!CredentialManager.Loaded)
                {
                    CustomDialog customDialog = new CustomDialog()
                    {
                        Title = LocalizationManager.GetStringByKey("String_Header_MasterPassword")
                    };

                    CredentialsMasterPasswordViewModel credentialsMasterPasswordViewModel = new CredentialsMasterPasswordViewModel(async instance =>
                    {
                        await dialogCoordinator.HideMetroDialogAsync(this, customDialog);
                        ConfigurationManager.Current.IsDialogOpen = false;

                        if (CredentialManager.Load(instance.Password))
                        {
                            CredentialInfo credentialInfo = CredentialManager.GetCredentialByID(SelectedProfile.CredentialID);

                            if (credentialInfo == null)
                            {
                                ConfigurationManager.Current.IsDialogOpen = true;
                                await dialogCoordinator.ShowMessageAsync(this, LocalizationManager.GetStringByKey("String_Header_CredentialNotFound"), LocalizationManager.GetStringByKey("String_CredentialNotFoundMessage"), MessageDialogStyle.Affirmative, AppearanceManager.MetroDialog);
                                ConfigurationManager.Current.IsDialogOpen = false;

                                return;
                            }

                            session.CustomCredentials = true;
                            session.Username          = credentialInfo.Username;
                            session.Password          = credentialInfo.Password;

                            Connect(session, SelectedProfile.Name);
                        }
                        else
                        {
                            ConfigurationManager.Current.IsDialogOpen = true;
                            await dialogCoordinator.ShowMessageAsync(this, LocalizationManager.GetStringByKey("String_Header_WrongPassword"), LocalizationManager.GetStringByKey("String_WrongPasswordDecryptionFailed"), MessageDialogStyle.Affirmative, AppearanceManager.MetroDialog);
                            ConfigurationManager.Current.IsDialogOpen = false;
                        }
                    }, instance =>
                    {
                        dialogCoordinator.HideMetroDialogAsync(this, customDialog);
                        ConfigurationManager.Current.IsDialogOpen = false;
                    });

                    customDialog.Content = new CredentialsMasterPasswordDialog
                    {
                        DataContext = credentialsMasterPasswordViewModel
                    };

                    ConfigurationManager.Current.IsDialogOpen = true;
                    await dialogCoordinator.ShowMetroDialogAsync(this, customDialog);
                }
                else // Connect already unlocked
                {
                    CredentialInfo credentialInfo = CredentialManager.GetCredentialByID(SelectedProfile.CredentialID);

                    if (credentialInfo == null)
                    {
                        ConfigurationManager.Current.IsDialogOpen = true;
                        await dialogCoordinator.ShowMessageAsync(this, LocalizationManager.GetStringByKey("String_Header_CredentialNotFound"), LocalizationManager.GetStringByKey("String_CredentialNotFoundMessage"), MessageDialogStyle.Affirmative, AppearanceManager.MetroDialog);

                        ConfigurationManager.Current.IsDialogOpen = false;

                        return;
                    }

                    session.CustomCredentials = true;
                    session.Username          = credentialInfo.Username;
                    session.Password          = credentialInfo.Password;

                    Connect(session, SelectedProfile.Name);
                }
            }
            else // Connect without credentials
            {
                Connect(session, SelectedProfile.Name);
            }
        }