File tree Expand file tree Collapse file tree 3 files changed +19
-20
lines changed
Expand file tree Collapse file tree 3 files changed +19
-20
lines changed Original file line number Diff line number Diff line change @@ -15,17 +15,18 @@ public SftpFormView()
1515
1616 Loaded += ( sender , args ) =>
1717 {
18- if ( DataContext is SFTP vm )
18+ if ( DataContext is SftpFormViewModel { New : var vm } )
1919 {
20- CbUsePrivateKey . IsChecked = false ;
20+ bool ? privateKey = false ;
2121 if ( vm . PrivateKey == vm . ServerEditorDifferentOptions )
2222 {
23- CbUsePrivateKey . IsChecked = null ;
23+ privateKey = null ;
2424 }
2525 if ( ! string . IsNullOrEmpty ( vm . PrivateKey ) )
2626 {
27- CbUsePrivateKey . IsChecked = true ;
27+ privateKey = true ;
2828 }
29+ CbUsePrivateKey . IsChecked = privateKey ;
2930 }
3031 } ;
3132 }
Original file line number Diff line number Diff line change @@ -22,18 +22,14 @@ public SshFormView() : base()
2222 bool ? privateKey = false ;
2323 if ( ssh . PrivateKey == ssh . ServerEditorDifferentOptions )
2424 {
25- CbUsePrivateKey . IsChecked = null ;
2625 privateKey = null ;
2726
2827 }
29-
3028 if ( ! string . IsNullOrEmpty ( ssh . PrivateKey ) )
3129 {
32- CbUsePrivateKey . IsChecked = true ;
3330 privateKey = true ;
3431
3532 }
36-
3733 CbUsePrivateKey . IsChecked = privateKey ;
3834 }
3935 } ;
Original file line number Diff line number Diff line change @@ -534,24 +534,26 @@ private void UpdateServerWhenProtocolChanged(Type newProtocolType)
534534
535535
536536 #region change port and username if the old velue is the default port and username
537- if ( server is ProtocolBaseWithAddressPort newPort && Server is ProtocolBaseWithAddressPort )
537+ if ( server is ProtocolBaseWithAddressPort newPort )
538538 {
539- var oldPortDefault = ( ProtocolBaseWithAddressPort ) protocolServerBaseAssembly . CreateInstance ( Server . GetType ( ) . FullName ! ) ! ;
540- if ( newPort . Port == oldPortDefault . Port )
539+ bool isDefaultPort = false ;
540+ if ( Server is ProtocolBaseWithAddressPort )
541541 {
542- var newDefault = ( ProtocolBaseWithAddressPort ) protocolServerBaseAssembly . CreateInstance ( newProtocolType . FullName ) ! ;
543- newPort . Port = newDefault . Port ;
542+ var oldPortDefault = ( ProtocolBaseWithAddressPort ) protocolServerBaseAssembly . CreateInstance ( Server . GetType ( ) . FullName ! ) ! ;
543+ isDefaultPort = newPort . Port == oldPortDefault . Port ;
544544 }
545- }
546- if ( server is ProtocolBaseWithAddressPortUserPwd newUserName && Server is ProtocolBaseWithAddressPortUserPwd )
547- {
548- var oldDefault = ( ProtocolBaseWithAddressPortUserPwd ) protocolServerBaseAssembly . CreateInstance ( Server . GetType ( ) . FullName ! ) ! ;
549- if ( newUserName . UserName == oldDefault . UserName )
545+ else if ( string . IsNullOrEmpty ( newPort . Port ) || newPort . Port == "3389" )
546+ {
547+ isDefaultPort = true ;
548+ }
549+ if ( isDefaultPort )
550550 {
551- var newDefault = ( ProtocolBaseWithAddressPortUserPwd ) protocolServerBaseAssembly . CreateInstance ( newProtocolType . FullName ) ! ;
552- newUserName . UserName = newDefault . UserName ;
551+ var newDefault = ( ProtocolBaseWithAddressPort ) protocolServerBaseAssembly . CreateInstance ( newProtocolType . FullName ) ! ;
552+ newPort . Port = newDefault . Port ;
553553 }
554554 }
555+
556+
555557 #endregion
556558
557559 Server = server ;
You can’t perform that action at this time.
0 commit comments