Three explicit buttons: Connect / Go Live / End Stream, shown per state
This commit is contained in:
+10
-3
@@ -91,10 +91,17 @@
|
||||
Width="400" HorizontalAlignment="Left"
|
||||
VerticalAlignment="Center"/>
|
||||
|
||||
<!-- Primary action: single button, adapts to state -->
|
||||
<!-- Primary actions: one relevant button per state -->
|
||||
<StackPanel Grid.Column="2" Orientation="Horizontal" VerticalAlignment="Center">
|
||||
<Button Content="{Binding PrimaryButtonText}" Style="{StaticResource YtButton}"
|
||||
Command="{Binding PrimaryCommand}"/>
|
||||
<Button Content="Connect" Style="{StaticResource YtButton}"
|
||||
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>
|
||||
</Grid>
|
||||
</Border>
|
||||
|
||||
+13
-23
@@ -37,7 +37,7 @@ public class MainViewModel : ViewModelBase
|
||||
{
|
||||
OnPropertyChanged(nameof(IsOffline));
|
||||
OnPropertyChanged(nameof(IsLive));
|
||||
OnPropertyChanged(nameof(PrimaryButtonText));
|
||||
OnPropertyChanged(nameof(ShowGoLive));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -69,24 +69,22 @@ public class MainViewModel : ViewModelBase
|
||||
set
|
||||
{
|
||||
if (SetProperty(ref _isYouTubeConnected, value))
|
||||
OnPropertyChanged(nameof(PrimaryButtonText));
|
||||
{
|
||||
OnPropertyChanged(nameof(ShowConnect));
|
||||
OnPropertyChanged(nameof(ShowGoLive));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Single, context-aware primary button. Follows the user's journey:
|
||||
/// not connected → connect, connected+idle → go live, live → stop.
|
||||
/// </summary>
|
||||
public string PrimaryButtonText => !IsYouTubeConnected
|
||||
? "Connect to YouTube"
|
||||
: IsLive
|
||||
? "Stop Stream"
|
||||
: "Go Live";
|
||||
public bool ShowConnect => !IsYouTubeConnected;
|
||||
public bool ShowGoLive => IsYouTubeConnected && IsOffline;
|
||||
|
||||
// Commands
|
||||
public ICommand AddSceneCommand { get; }
|
||||
public ICommand RemoveSceneCommand { get; }
|
||||
public ICommand PrimaryCommand { get; }
|
||||
public ICommand ConnectCommand { get; }
|
||||
public ICommand GoLiveCommand { get; }
|
||||
public ICommand EndStreamCommand { get; }
|
||||
|
||||
public MainViewModel()
|
||||
{
|
||||
@@ -98,7 +96,9 @@ public class MainViewModel : ViewModelBase
|
||||
|
||||
AddSceneCommand = new RelayCommand(_ => AddScene());
|
||||
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
|
||||
AddScene("Scene 1");
|
||||
@@ -150,14 +150,4 @@ public class MainViewModel : ViewModelBase
|
||||
// For now, this is a stub
|
||||
IsYouTubeConnected = false;
|
||||
}
|
||||
|
||||
private void PrimaryAction()
|
||||
{
|
||||
if (!IsYouTubeConnected)
|
||||
ConnectYouTube();
|
||||
else if (IsLive)
|
||||
StopStream();
|
||||
else
|
||||
StartStream();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user