@@ -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}
0 commit comments