Three explicit buttons: Connect / Go Live / End Stream, shown per state

This commit is contained in:
2026-08-04 10:37:38 -07:00
parent 639e1bb323
commit 4caf7eec8d
2 changed files with 23 additions and 26 deletions
+10 -3
View File
@@ -91,10 +91,17 @@
Width="400" HorizontalAlignment="Left" Width="400" HorizontalAlignment="Left"
VerticalAlignment="Center"/> VerticalAlignment="Center"/>
<!-- Primary action: single button, adapts to state --> <!-- Primary actions: one relevant button per state -->
<StackPanel Grid.Column="2" Orientation="Horizontal" VerticalAlignment="Center"> <StackPanel Grid.Column="2" Orientation="Horizontal" VerticalAlignment="Center">
<Button Content="{Binding PrimaryButtonText}" Style="{StaticResource YtButton}" <Button Content="Connect" Style="{StaticResource YtButton}"
Command="{Binding PrimaryCommand}"/> Command="{Binding ConnectCommand}"
Visibility="{Binding ShowConnect, Converter={StaticResource BoolToVis}}"/>
<Button Content="Go Live" Style="{StaticResource YtButton}"
Command="{Binding GoLiveCommand}"
Visibility="{Binding ShowGoLive, Converter={StaticResource BoolToVis}}"/>
<Button Content="End Stream" Style="{StaticResource YtButton}"
Background="#333" Command="{Binding EndStreamCommand}"
Visibility="{Binding IsLive, Converter={StaticResource BoolToVis}}"/>
</StackPanel> </StackPanel>
</Grid> </Grid>
</Border> </Border>
+13 -23
View File
@@ -37,7 +37,7 @@ public class MainViewModel : ViewModelBase
{ {
OnPropertyChanged(nameof(IsOffline)); OnPropertyChanged(nameof(IsOffline));
OnPropertyChanged(nameof(IsLive)); OnPropertyChanged(nameof(IsLive));
OnPropertyChanged(nameof(PrimaryButtonText)); OnPropertyChanged(nameof(ShowGoLive));
} }
} }
} }
@@ -69,24 +69,22 @@ public class MainViewModel : ViewModelBase
set set
{ {
if (SetProperty(ref _isYouTubeConnected, value)) if (SetProperty(ref _isYouTubeConnected, value))
OnPropertyChanged(nameof(PrimaryButtonText)); {
OnPropertyChanged(nameof(ShowConnect));
OnPropertyChanged(nameof(ShowGoLive));
}
} }
} }
/// <summary> public bool ShowConnect => !IsYouTubeConnected;
/// Single, context-aware primary button. Follows the user's journey: public bool ShowGoLive => IsYouTubeConnected && IsOffline;
/// not connected → connect, connected+idle → go live, live → stop.
/// </summary>
public string PrimaryButtonText => !IsYouTubeConnected
? "Connect to YouTube"
: IsLive
? "Stop Stream"
: "Go Live";
// Commands // Commands
public ICommand AddSceneCommand { get; } public ICommand AddSceneCommand { get; }
public ICommand RemoveSceneCommand { get; } public ICommand RemoveSceneCommand { get; }
public ICommand PrimaryCommand { get; } public ICommand ConnectCommand { get; }
public ICommand GoLiveCommand { get; }
public ICommand EndStreamCommand { get; }
public MainViewModel() public MainViewModel()
{ {
@@ -98,7 +96,9 @@ public class MainViewModel : ViewModelBase
AddSceneCommand = new RelayCommand(_ => AddScene()); AddSceneCommand = new RelayCommand(_ => AddScene());
RemoveSceneCommand = new RelayCommand(scene => RemoveScene(scene as Scene)); RemoveSceneCommand = new RelayCommand(scene => RemoveScene(scene as Scene));
PrimaryCommand = new RelayCommand(_ => PrimaryAction()); ConnectCommand = new RelayCommand(_ => ConnectYouTube());
GoLiveCommand = new RelayCommand(_ => StartStream(), _ => IsYouTubeConnected && IsOffline);
EndStreamCommand = new RelayCommand(_ => StopStream(), _ => IsLive);
// Start with a default scene // Start with a default scene
AddScene("Scene 1"); AddScene("Scene 1");
@@ -150,14 +150,4 @@ public class MainViewModel : ViewModelBase
// For now, this is a stub // For now, this is a stub
IsYouTubeConnected = false; IsYouTubeConnected = false;
} }
private void PrimaryAction()
{
if (!IsYouTubeConnected)
ConnectYouTube();
else if (IsLive)
StopStream();
else
StartStream();
}
} }