@@ -13,6 +13,7 @@ public class ConnectingViewModel : ViewModelBase
13
13
private readonly Connector _connector ;
14
14
private readonly Updater _updater ;
15
15
private readonly MainWindowViewModel _windowVm ;
16
+ private readonly ConnectionType _connectionType ;
16
17
17
18
private readonly CancellationTokenSource _cancelSource = new CancellationTokenSource ( ) ;
18
19
@@ -25,16 +26,18 @@ public class ConnectingViewModel : ViewModelBase
25
26
26
27
public bool IsErrored => _connectorStatus == Connector . ConnectionStatus . ConnectionFailed ||
27
28
_connectorStatus == Connector . ConnectionStatus . UpdateError ||
29
+ _connectorStatus == Connector . ConnectionStatus . NotAContentBundle ||
28
30
_connectorStatus == Connector . ConnectionStatus . ClientExited &&
29
31
_connector . ClientExitedBadly ;
30
32
31
33
public static event Action ? StartedConnecting ;
32
34
33
- public ConnectingViewModel ( Connector connector , MainWindowViewModel windowVm , string ? givenReason )
35
+ public ConnectingViewModel ( Connector connector , MainWindowViewModel windowVm , string ? givenReason , ConnectionType connectionType )
34
36
{
35
37
_updater = Locator . Current . GetRequiredService < Updater > ( ) ;
36
38
_connector = connector ;
37
39
_windowVm = windowVm ;
40
+ _connectionType = connectionType ;
38
41
_reasonSuffix = ( givenReason != null ) ? ( "\n " + givenReason ) : "" ;
39
42
40
43
this . WhenAnyValue ( x => x . _updater . Progress )
@@ -134,7 +137,8 @@ public string ProgressText
134
137
public bool ProgressBarVisible => _connectorStatus != Connector . ConnectionStatus . ClientExited &&
135
138
_connectorStatus != Connector . ConnectionStatus . ClientRunning &&
136
139
_connectorStatus != Connector . ConnectionStatus . ConnectionFailed &&
137
- _connectorStatus != Connector . ConnectionStatus . UpdateError ;
140
+ _connectorStatus != Connector . ConnectionStatus . UpdateError &&
141
+ _connectorStatus != Connector . ConnectionStatus . NotAContentBundle ;
138
142
139
143
public bool SpeedIndeterminate => _connectorStatus != Connector . ConnectionStatus . Updating || _updaterSpeed == null ;
140
144
@@ -182,10 +186,17 @@ public string SpeedText
182
186
_ => ""
183
187
} ;
184
188
189
+ public string TitleText => _connectionType switch
190
+ {
191
+ ConnectionType . Server => "Connecting..." ,
192
+ ConnectionType . ContentBundle => "Loading..." ,
193
+ _ => ""
194
+ } ;
195
+
185
196
public static void StartConnect ( MainWindowViewModel windowVm , string address , string ? givenReason = null )
186
197
{
187
198
var connector = new Connector ( ) ;
188
- var vm = new ConnectingViewModel ( connector , windowVm , givenReason ) ;
199
+ var vm = new ConnectingViewModel ( connector , windowVm , givenReason , ConnectionType . Server ) ;
189
200
windowVm . ConnectingVM = vm ;
190
201
vm . Start ( address ) ;
191
202
StartedConnecting ? . Invoke ( ) ;
@@ -194,7 +205,7 @@ public static void StartConnect(MainWindowViewModel windowVm, string address, st
194
205
public static void StartContentBundle ( MainWindowViewModel windowVm , string fileName )
195
206
{
196
207
var connector = new Connector ( ) ;
197
- var vm = new ConnectingViewModel ( connector , windowVm , null ) ;
208
+ var vm = new ConnectingViewModel ( connector , windowVm , null , ConnectionType . ContentBundle ) ;
198
209
windowVm . ConnectingVM = vm ;
199
210
vm . StartContentBundle ( fileName ) ;
200
211
StartedConnecting ? . Invoke ( ) ;
@@ -224,4 +235,10 @@ public void Cancel()
224
235
{
225
236
_cancelSource . Cancel ( ) ;
226
237
}
238
+
239
+ public enum ConnectionType
240
+ {
241
+ Server ,
242
+ ContentBundle
243
+ }
227
244
}
0 commit comments