Skip to content

Commit

Permalink
Click car position button to change focus
Browse files Browse the repository at this point in the history
  • Loading branch information
ColonelChocomel committed Apr 15, 2022
1 parent 2d5f30e commit f244e57
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 7 deletions.
4 changes: 2 additions & 2 deletions ACCBroadcaster/Views/Broadcasting/CarListView.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,12 @@
<MenuFlyoutSubItem x:Name="DrivableContextFlyout" Text="Drivable"/>
</MenuFlyout>
<ControlTemplate x:Name="CarPositionTemplate" TargetType="Button">
<Button Grid.Row="0" Grid.Column="0" CornerRadius="20" VerticalAlignment="Top" Width="55" Background="DarkGray" Foreground="Black">
<Button Grid.Row="0" Grid.Column="0" CornerRadius="20" VerticalAlignment="Top" Width="55" Background="DarkGray" Foreground="Black" Click="CarPostionButtonClicked" CommandParameter="{TemplateBinding CommandParameter}">
<ContentPresenter Content="{TemplateBinding Content}"/>
</Button>
</ControlTemplate>
<ControlTemplate x:Name="FocusedCarPositionTemplate" TargetType="Button">
<Button Grid.Row="0" Grid.Column="0" CornerRadius="20" VerticalAlignment="Top" Width="55" Background="DodgerBlue" Foreground="Black">
<Button Grid.Row="0" Grid.Column="0" CornerRadius="20" VerticalAlignment="Top" Width="55" Background="DodgerBlue" Foreground="Black" Click="CarPostionButtonClicked" CommandParameter="{TemplateBinding CommandParameter}">
<ContentPresenter Content="{TemplateBinding Content}"/>
</Button>
</ControlTemplate>
Expand Down
17 changes: 12 additions & 5 deletions ACCBroadcaster/Views/Broadcasting/CarListView.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ private void OnRealtimeUpdate(string sender, RealtimeUpdate update)
}
} else
{
focusedCar.SetAsFocusedCar(true);
SetAsFocusedCar(focusedCar, true);
}
}
SessionType = update.SessionType;
Expand Down Expand Up @@ -249,28 +249,28 @@ private void CreateCarContextFlyout()

private void OnCarContextClicked(object sender, RoutedEventArgs e)
{
MenuFlyoutItem item = (MenuFlyoutItem)e.OriginalSource;
MenuFlyoutItem item = (MenuFlyoutItem)sender;
Car car = (Car)item.DataContext;
ACCService.Client.MessageHandler.SetFocus((UInt16)car.Index, item.Name, "default");
}

private void OnCarContextOnboardClicked(object sender, RoutedEventArgs e)
{
MenuFlyoutItem item = (MenuFlyoutItem)e.OriginalSource;
MenuFlyoutItem item = (MenuFlyoutItem)sender;
Car car = (Car)item.DataContext;
ACCService.Client.MessageHandler.SetFocus((UInt16)car.Index, "Onboard", item.Name);
}

private void OnCarContextDrivableClicked(object sender, RoutedEventArgs e)
{
MenuFlyoutItem item = (MenuFlyoutItem)e.OriginalSource;
MenuFlyoutItem item = (MenuFlyoutItem)sender;
Car car = (Car)item.DataContext;
ACCService.Client.MessageHandler.SetFocus((UInt16)car.Index, "Drivable", item.Name);
}

private void OnCarContextReplayClicked(object sender, RoutedEventArgs e)
{
MenuFlyoutItem item = (MenuFlyoutItem)e.OriginalSource;
MenuFlyoutItem item = (MenuFlyoutItem)sender;
Car car = (Car)item.DataContext;
float length;
if (item.Name == "Custom")
Expand Down Expand Up @@ -308,5 +308,12 @@ private void SetAsFocusedCar (Car car, bool isFocused)
button.Template = CarPositionTemplate;
}
}

private void CarPostionButtonClicked(object sender, RoutedEventArgs e)
{
Button button = (Button)sender;
int carIndex = (int)button.CommandParameter;
ACCService.Client.MessageHandler.SetFocus((UInt16)carIndex);
}
}
}

0 comments on commit f244e57

Please sign in to comment.