@@ -92,12 +92,12 @@ public ICommand ActivePlayerButtonCommand
92
92
93
93
public ICommand OpenLicensesFolder { get ; private set ; }
94
94
95
- private IPackageSource _packageSource ;
95
+ private IPackageSource ? _packageSource ;
96
96
97
97
/// <summary>
98
- /// Путь к отыгрываемому документу
98
+ /// Package source.
99
99
/// </summary>
100
- public IPackageSource PackageSource
100
+ public IPackageSource ? PackageSource
101
101
{
102
102
get => _packageSource ;
103
103
set
@@ -231,7 +231,7 @@ public MainViewModel(AppSettings settings)
231
231
232
232
OpenLicensesFolder = new SimpleCommand ( OpenLicensesFolder_Executed ) ;
233
233
234
- ActivePlayerButtonCommand = _addPlayerButton ;
234
+ _activePlayerButtonCommand = _addPlayerButton ;
235
235
236
236
UpdateStartCommand ( ) ;
237
237
UpdateCanAddPlayerButton ( ) ;
@@ -378,6 +378,11 @@ private void Settings_PropertyChanged(object? sender, PropertyChangedEventArgs e
378
378
379
379
private async Task < SIDocument > PreparePackageAsync ( CancellationToken cancellationToken = default )
380
380
{
381
+ if ( _packageSource == null )
382
+ {
383
+ throw new InvalidOperationException ( "_packageSource == null" ) ;
384
+ }
385
+
381
386
var ( filePath , isTemporary ) = await _packageSource . GetPackageFileAsync ( cancellationToken ) ;
382
387
383
388
var tempDir = Path . Combine ( Path . GetTempPath ( ) , AppSettings . AppName , Guid . NewGuid ( ) . ToString ( ) ) ;
@@ -455,6 +460,11 @@ private async Task Start_Executed(object? _)
455
460
{
456
461
try
457
462
{
463
+ if ( _packageSource == null )
464
+ {
465
+ throw new InvalidOperationException ( "_packageSource == null" ) ;
466
+ }
467
+
458
468
var screenIndex = SettingsViewModel . Model . ScreenNumber ;
459
469
460
470
if ( screenIndex < 0 || screenIndex >= Screens . Length )
@@ -615,12 +625,8 @@ private async Task EndGameAsync()
615
625
616
626
private async void SelectPackage_Executed ( object ? arg )
617
627
{
618
- if ( arg == null )
619
- {
620
- throw new ArgumentNullException ( nameof ( arg ) ) ;
621
- }
622
-
623
- var packageSource = await PlatformManager . Instance . AskSelectPackageAsync ( arg ) ;
628
+ var stringArg = ( arg ? . ToString ( ) ) ?? throw new ArgumentNullException ( nameof ( arg ) ) ;
629
+ var packageSource = await PlatformManager . Instance . AskSelectPackageAsync ( stringArg ) ;
624
630
625
631
if ( packageSource != null )
626
632
{
@@ -772,7 +778,10 @@ public async Task OnButtonsLeftAsync()
772
778
773
779
private void RemovePlayerButton_Executed ( object ? arg )
774
780
{
775
- var key = ( GameKey ) arg ;
781
+ if ( arg is not GameKey key )
782
+ {
783
+ return ;
784
+ }
776
785
777
786
if ( Settings . PlayerKeys2 . Contains ( key ) )
778
787
{
@@ -815,6 +824,11 @@ private void OnModeChanged()
815
824
816
825
private void UpdatePlayersView ( )
817
826
{
827
+ if ( _game == null )
828
+ {
829
+ return ;
830
+ }
831
+
818
832
if ( Settings . PlayersView == PlayersViewMode . Separate && _mode == GameMode . Moderator )
819
833
{
820
834
PlatformManager . Instance . CreatePlayersView ( _game ) ;
0 commit comments