2222using ProtocolHostStatus = _1RM . View . Host . ProtocolHosts . ProtocolHostStatus ;
2323using _1RM . Service . DataSource ;
2424using System . Collections . Generic ;
25+ using Shawn . Utils . WpfResources . Theme . Styles ;
2526
2627namespace _1RM . Service
2728{
@@ -122,13 +123,16 @@ private bool ActivateOrReConnIfServerSessionIsOpened(in ProtocolBase server)
122123 if ( server . IsOnlyOneInstance ( ) && _connectionId2Hosts . ContainsKey ( serverId ) )
123124 {
124125 SimpleLogHelper . Debug ( $ "_connectionId2Hosts ContainsKey { serverId } ") ;
125- if ( _connectionId2Hosts [ serverId ] . ParentWindow is TabWindowBase t )
126+ if ( _connectionId2Hosts [ serverId ] . ParentWindow is { } win )
126127 {
127- var s = t . GetViewModel ( ) . Items . FirstOrDefault ( x => x . Content ? . ProtocolServer ? . Id == serverId ) ;
128- if ( s != null )
129- t . GetViewModel ( ) . SelectedItem = s ;
128+ if ( win is TabWindowBase tab )
129+ {
130+ var s = tab . GetViewModel ( ) . Items . FirstOrDefault ( x => x . Content ? . ProtocolServer ? . Id == serverId ) ;
131+ if ( s != null )
132+ tab . GetViewModel ( ) . SelectedItem = s ;
133+ }
130134
131- if ( t . IsClosed )
135+ if ( win . IsClosed )
132136 {
133137 MarkProtocolHostToClose ( new string [ ] { serverId . ToString ( ) } ) ;
134138 CleanupProtocolsAndWindows ( ) ;
@@ -139,9 +143,16 @@ private bool ActivateOrReConnIfServerSessionIsOpened(in ProtocolBase server)
139143 {
140144 Execute . OnUIThreadSync ( ( ) =>
141145 {
142- t . Show ( ) ;
143- t . Activate ( ) ;
146+ if ( win . IsClosing == false )
147+ {
148+ win . WindowState = win . WindowState == WindowState . Minimized ? WindowState . Normal : win . WindowState ;
149+ win . Show ( ) ;
150+ win . Activate ( ) ;
151+ }
144152 } ) ;
153+
154+ var vmServer = _appData . GetItemById ( server . DataSourceName , server . Id ) ;
155+ vmServer ? . UpdateConnectTime ( ) ;
145156 }
146157 catch ( Exception e )
147158 {
@@ -150,6 +161,7 @@ private bool ActivateOrReConnIfServerSessionIsOpened(in ProtocolBase server)
150161 CleanupProtocolsAndWindows ( ) ;
151162 }
152163 }
164+
153165 if ( _connectionId2Hosts [ serverId ] . ParentWindow != null )
154166 {
155167 if ( _connectionId2Hosts [ serverId ] . Status != ProtocolHostStatus . Connected )
0 commit comments