Skip to content

Commit 72dd70d

Browse files
committed
Remote Desktop - Check if credentials are deleted
1 parent fdc0dbc commit 72dd70d

4 files changed

Lines changed: 65 additions & 50 deletions

File tree

Source/NETworkManager/Resources/Localization/Resources.de-DE.xaml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,8 @@
9494
<system:String x:Key="String_Header_DeleteCredential">Anmeldeinformation löschen</system:String>
9595
<system:String x:Key="String_Header_ConfigureNetworkInterface">Konfiguriere Netzwerkinterface</system:String>
9696
<system:String x:Key="String_Header_Authentication">Authentifizierung</system:String>
97-
97+
<system:String x:Key="String_Header_CredentialNotFound">Anmeldeinformation nicht gefunden!</system:String>
98+
9899
<!-- Normal strings -->
99100
<system:String x:Key="String_ProductName">NETworkManager</system:String>
100101
<system:String x:Key="String_Slogan">Ein leistungsstarkes Tool zum Verwalten von Netzwerken und zur Behebung von Netzwerkproblemen!</system:String>
@@ -321,7 +322,8 @@
321322
<system:String x:Key="String_AuthenticationLevel">Authentifizierungsebene</system:String>
322323
<system:String x:Key="String_RemainingTime">Verbleibende Zeit</system:String>
323324
<system:String x:Key="String_UserInterfaceLocked">Benutzeroberfläche gesperrt!</system:String>
324-
325+
<system:String x:Key="String_CredentialNotFoundMessage">Die Anmeldeinformation wurde gelöscht. Bearbeiten Sie die Sitzung und wählen Sie eine andere Anmeldeinformation oder löschen die vorhandene.</system:String>
326+
325327
<!-- Help message -->
326328
<system:String x:Key="String_HelpMessage_ParameterHelp">Zeigt diesen Dialog an.</system:String>
327329
<system:String x:Key="String_HelpMessage_ParameterResetSettings">Setzt alle Einstellungen zurück.</system:String>

Source/NETworkManager/Resources/Localization/Resources.en-US.xaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,7 @@
9494
<system:String x:Key="String_Header_DeleteCredential">Delete credential</system:String>
9595
<system:String x:Key="String_Header_ConfigureNetworkInterface">Configure Network Interface</system:String>
9696
<system:String x:Key="String_Header_Authentication">Authentication</system:String>
97+
<system:String x:Key="String_Header_CredentialNotFound">Credential not found!</system:String>
9798

9899
<!-- Normal strings -->
99100
<system:String x:Key="String_ProductName">NETworkManager</system:String>
@@ -321,6 +322,7 @@
321322
<system:String x:Key="String_AuthenticationLevel">Authentication level</system:String>
322323
<system:String x:Key="String_RemainingTime">Remaining time</system:String>
323324
<system:String x:Key="String_UserInterfaceLocked">User interface locked!</system:String>
325+
<system:String x:Key="String_CredentialNotFoundMessage">Edit the session and select a different credential or delete the existing one</system:String>
324326

325327
<!-- Help message -->
326328
<system:String x:Key="String_HelpMessage_ParameterHelp">Displays this dialog.</system:String>

Source/NETworkManager/ViewModels/Applications/RemoteDesktopViewModel.cs

Lines changed: 54 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -143,46 +143,7 @@ private void LoadSettings()
143143
{
144144
ExpandSessionView = SettingsManager.Current.RemoteDesktop_ExpandSessionView;
145145
}
146-
#endregion
147-
148-
#region Methods
149-
private void ConnectSession(Models.RemoteDesktop.RemoteDesktopSessionInfo sessionInfo, string Header = null)
150-
{
151-
// Add global settings...
152-
sessionInfo.AdjustScreenAutomatically = SettingsManager.Current.RemoteDesktop_AdjustScreenAutomatically;
153-
sessionInfo.DesktopWidth = SettingsManager.Current.RemoteDesktop_DesktopWidth;
154-
sessionInfo.DesktopHeight = SettingsManager.Current.RemoteDesktop_DesktopHeight;
155-
sessionInfo.ColorDepth = SettingsManager.Current.RemoteDesktop_ColorDepth;
156-
sessionInfo.EnableCredSspSupport = SettingsManager.Current.RemoteDesktop_EnableCredSspSupport;
157-
sessionInfo.AuthenticationLevel = SettingsManager.Current.RemoteDesktop_AuthenticationLevel;
158-
sessionInfo.RedirectClipboard = SettingsManager.Current.RemoteDesktop_RedirectClipboard;
159-
sessionInfo.RedirectDevices = SettingsManager.Current.RemoteDesktop_RedirectDevices;
160-
sessionInfo.RedirectDrives = SettingsManager.Current.RemoteDesktop_RedirectDrives;
161-
sessionInfo.RedirectPorts = SettingsManager.Current.RemoteDesktop_RedirectPorts;
162-
sessionInfo.RedirectSmartCards = SettingsManager.Current.RemoteDesktop_RedirectSmartCards;
163-
164-
TabItems.Add(new DragablzRemoteDesktopTabItem(Header ?? sessionInfo.Hostname, new RemoteDesktopControl(sessionInfo)));
165-
SelectedTabIndex = TabItems.Count - 1;
166-
}
167-
168-
private void RemoteDesktopSession_Search(object sender, FilterEventArgs e)
169-
{
170-
if (string.IsNullOrEmpty(Search))
171-
{
172-
e.Accepted = true;
173-
return;
174-
}
175-
176-
RemoteDesktopSessionInfo info = e.Item as RemoteDesktopSessionInfo;
177-
178-
string search = Search.Trim();
179-
180-
if (info.Hostname.IndexOf(search, StringComparison.OrdinalIgnoreCase) >= 0)
181-
e.Accepted = true;
182-
else
183-
e.Accepted = false;
184-
}
185-
#endregion
146+
#endregion
186147

187148
#region ICommand & Actions
188149
public ICommand ConnectNewSessionCommand
@@ -294,6 +255,13 @@ private async void ConnectSessionAction()
294255
{
295256
CredentialInfo credentialInfo = CredentialManager.GetCredentialByID((int)SelectedSession.CredentialID);
296257

258+
if (credentialInfo == null)
259+
{
260+
await dialogCoordinator.ShowMessageAsync(this, Application.Current.Resources["String_Header_CredentialNotFound"] as string, Application.Current.Resources["String_CredentialNotFoundMessage"] as string, MessageDialogStyle.Affirmative, AppearanceManager.MetroDialog);
261+
262+
return;
263+
}
264+
297265
sessionInfo.CustomCredentials = true;
298266
sessionInfo.Username = credentialInfo.Username;
299267
sessionInfo.Password = credentialInfo.Password;
@@ -320,6 +288,13 @@ private async void ConnectSessionAction()
320288
{
321289
CredentialInfo credentialInfo = CredentialManager.GetCredentialByID((int)SelectedSession.CredentialID);
322290

291+
if(credentialInfo == null)
292+
{
293+
await dialogCoordinator.ShowMessageAsync(this, Application.Current.Resources["String_Header_CredentialNotFound"] as string, Application.Current.Resources["String_CredentialNotFoundMessage"] as string, MessageDialogStyle.Affirmative, AppearanceManager.MetroDialog);
294+
295+
return;
296+
}
297+
323298
sessionInfo.CustomCredentials = true;
324299
sessionInfo.Username = credentialInfo.Username;
325300
sessionInfo.Password = credentialInfo.Password;
@@ -451,5 +426,44 @@ private async void DeleteSessionAction()
451426
await dialogCoordinator.ShowMetroDialogAsync(this, customDialog);
452427
}
453428
#endregion
429+
430+
#region Methods
431+
private void ConnectSession(Models.RemoteDesktop.RemoteDesktopSessionInfo sessionInfo, string Header = null)
432+
{
433+
// Add global settings...
434+
sessionInfo.AdjustScreenAutomatically = SettingsManager.Current.RemoteDesktop_AdjustScreenAutomatically;
435+
sessionInfo.DesktopWidth = SettingsManager.Current.RemoteDesktop_DesktopWidth;
436+
sessionInfo.DesktopHeight = SettingsManager.Current.RemoteDesktop_DesktopHeight;
437+
sessionInfo.ColorDepth = SettingsManager.Current.RemoteDesktop_ColorDepth;
438+
sessionInfo.EnableCredSspSupport = SettingsManager.Current.RemoteDesktop_EnableCredSspSupport;
439+
sessionInfo.AuthenticationLevel = SettingsManager.Current.RemoteDesktop_AuthenticationLevel;
440+
sessionInfo.RedirectClipboard = SettingsManager.Current.RemoteDesktop_RedirectClipboard;
441+
sessionInfo.RedirectDevices = SettingsManager.Current.RemoteDesktop_RedirectDevices;
442+
sessionInfo.RedirectDrives = SettingsManager.Current.RemoteDesktop_RedirectDrives;
443+
sessionInfo.RedirectPorts = SettingsManager.Current.RemoteDesktop_RedirectPorts;
444+
sessionInfo.RedirectSmartCards = SettingsManager.Current.RemoteDesktop_RedirectSmartCards;
445+
446+
TabItems.Add(new DragablzRemoteDesktopTabItem(Header ?? sessionInfo.Hostname, new RemoteDesktopControl(sessionInfo)));
447+
SelectedTabIndex = TabItems.Count - 1;
448+
}
449+
450+
private void RemoteDesktopSession_Search(object sender, FilterEventArgs e)
451+
{
452+
if (string.IsNullOrEmpty(Search))
453+
{
454+
e.Accepted = true;
455+
return;
456+
}
457+
458+
RemoteDesktopSessionInfo info = e.Item as RemoteDesktopSessionInfo;
459+
460+
string search = Search.Trim();
461+
462+
if (info.Hostname.IndexOf(search, StringComparison.OrdinalIgnoreCase) >= 0)
463+
e.Accepted = true;
464+
else
465+
e.Accepted = false;
466+
}
467+
#endregion
454468
}
455469
}

Source/NETworkManager/ViewModels/Dialogs/RemoteDesktopSessionViewModel.cs

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -173,16 +173,13 @@ public RemoteDesktopSessionViewModel(Action<RemoteDesktopSessionViewModel> saveC
173173
Tags = _sessionInfo.Tags;
174174

175175
if (CredentialManager.Loaded)
176-
{
177176
_credentials = CollectionViewSource.GetDefaultView(CredentialManager.CredentialInfoList);
178-
}
179-
else // Fake the entry for the user
180-
{
181-
if (CredentialID != null)
182-
_credentials = CollectionViewSource.GetDefaultView(new List<CredentialInfo>() { new CredentialInfo((int)CredentialID) });
183-
177+
else
184178
ShowUnlockCredentialsHint = true;
185-
}
179+
180+
// Fake the entry for the user (if credentials are not loaded or credential was deleted) --> example [12]
181+
if (CredentialID != null && (!CredentialManager.Loaded || CredentialManager.GetCredentialByID((int)CredentialID) == null))
182+
_credentials = CollectionViewSource.GetDefaultView(new List<CredentialInfo>() { new CredentialInfo((int)CredentialID) });
186183

187184
_groups = CollectionViewSource.GetDefaultView(groups);
188185
_groups.SortDescriptions.Add(new SortDescription());

0 commit comments

Comments
 (0)