Elias: smal fixes to arrow nav.remote now semi trigers right events/playlist nav still needs making

This commit is contained in:
unknown
2025-07-07 11:18:25 +02:00
parent d3cd0f1bdd
commit 6a63193082
146 changed files with 1226 additions and 361 deletions

View File

@@ -109,18 +109,18 @@
</Grid>
<!-- SETTINGS BUTTON -->
<Button Grid.Column="0" Grid.Row="2" Content="Settings" Margin="10" HorizontalAlignment="Left"
TabIndex="8" Focusable="True" Click="PlayListButton_Click"/>
<Button Focusable="False" Grid.Column="0" Grid.Row="2" Content="Settings" Margin="10" HorizontalAlignment="Left"
TabIndex="8" Click="PlayListButton_Click"/>
<!-- PLAYER PROGRESS -->
<Slider Name="itemProgress" TabIndex="9" Focusable="True" PreviewMouseDown="ItemProgress_OnPreviewMouseDown"
<Slider Focusable="False" Name="itemProgress" TabIndex="9" PreviewMouseDown="ItemProgress_OnPreviewMouseDown"
Panel.ZIndex="2" VerticalAlignment="Top" ValueChanged="ItemProgress_OnValueChanged"
Grid.Row="2" Grid.Column="1" Padding="10"/>
<ProgressBar Name="itemProgressVisual" Panel.ZIndex="1" Height="20" VerticalAlignment="Top"
Grid.Row="2" Grid.Column="1" Padding="10"/>
<!-- PLAYER CONTROLS -->
<StackPanel Grid.Column="1" Grid.Row="2" Orientation="Horizontal" HorizontalAlignment="Center"
<StackPanel Focusable="False" Grid.Column="1" Grid.Row="2" Orientation="Horizontal" HorizontalAlignment="Center"
VerticalAlignment="Bottom" Background="#222" KeyboardNavigation.DirectionalNavigation="None">
<TextBlock Name="title" Text="Titel" Foreground="White" FontSize="16" Margin="10"/>
<Button Name="prior" Content="⏮" Width="40" Margin="10" TabIndex="10" Focusable="True" Click="OnItemPriorButtonClick"/>

View File

@@ -123,7 +123,7 @@ public partial class MainWindow : Window
#endregion
#region BlutuethLogic
//InitBluetoothServer();
InitBluetoothServer();
#endregion
#region only exdend. no remuving of code
@@ -1036,9 +1036,9 @@ public partial class MainWindow : Window
Server1.MessageReceived += (msg) =>
{
Dispatcher.Invoke(() =>
Dispatcher.BeginInvoke(new Action(()=>
{
MessageBox.Show($"📨 Message: {msg.Trim()}");
//MessageBox.Show($"📨 Message: {msg.Trim()}");
switch (msg.Trim())
{
// Arrow Up
@@ -1047,12 +1047,13 @@ public partial class MainWindow : Window
Keyboard.PrimaryDevice,
PresentationSource.FromVisual(this),
0,
Key.Up) // simulate pressing the "A" key
Key.Up)
{
RoutedEvent = Keyboard.PreviewKeyDownEvent
};
this.RaiseEvent(keyEventArgs);
break;
// Arrow Down
@@ -1061,7 +1062,7 @@ public partial class MainWindow : Window
Keyboard.PrimaryDevice,
PresentationSource.FromVisual(this),
0,
Key.Down) // simulate pressing the "A" key
Key.Down)
{
RoutedEvent = Keyboard.PreviewKeyDownEvent
};
@@ -1075,7 +1076,7 @@ public partial class MainWindow : Window
Keyboard.PrimaryDevice,
PresentationSource.FromVisual(this),
0,
Key.Left) // simulate pressing the "A" key
Key.Left)
{
RoutedEvent = Keyboard.PreviewKeyDownEvent
};
@@ -1089,7 +1090,7 @@ public partial class MainWindow : Window
Keyboard.PrimaryDevice,
PresentationSource.FromVisual(this),
0,
Key.Right) // simulate pressing the "A" key
Key.Right)
{
RoutedEvent = Keyboard.PreviewKeyDownEvent
};
@@ -1109,36 +1110,24 @@ public partial class MainWindow : Window
next.RaiseEvent(clickEventArgs2);
break;
// Center button (Dot)
case "●": // \u25CF
if (_mediaPlayer.IsPlaying)
case "●":
Dispatcher.BeginInvoke(new Action(() =>
{
var keyEventArgs5 = new KeyEventArgs(
Keyboard.PrimaryDevice,
PresentationSource.FromVisual(this),
0,
Key.Space) // simulate pressing the "A" key
{
RoutedEvent = Keyboard.PreviewKeyDownEvent
};
this.RaiseEvent(keyEventArgs5);
}
else
{
var keyEventArgs5 = new KeyEventArgs(
Keyboard.PrimaryDevice,
PresentationSource.FromVisual(this),
0,
Key.Enter) // simulate pressing the "A" key
{
RoutedEvent = Keyboard.PreviewKeyDownEvent
};
this.RaiseEvent(keyEventArgs5);
}
if (_mediaPlayer.IsPlaying)
{
// Simulate pause
OnItemPauseBtn_Click(null, null);
}
else
{
// Simulate item selection
var focused = Keyboard.FocusedElement as Button;
focused?.RaiseEvent(new RoutedEventArgs(Button.ClickEvent));
}
}));
break;
case "Vol -":
if(_mediaPlayer.Volume>10)
_mediaPlayer.Volume = _mediaPlayer.Volume - 10;
@@ -1168,8 +1157,9 @@ public partial class MainWindow : Window
MessageBox.Show($"Unrecognized input: '{msg}'");
break;
}
Console.WriteLine(msg+":recived");
});
}));
// Optional: echo back the message
@@ -1702,7 +1692,6 @@ private void MainWindow_PreviewKeyDown(object sender, KeyEventArgs e)
var wrapPanel = FindAncestor<WrapPanel>(focusedElement);
var stackPanel = FindAncestor<StackPanel>(focusedElement);
if (wrapPanel != null && wrapPanel.Children.Count > 0)
{
int focusedIndex = FindFocusedIndexInWrapPanel(wrapPanel, focusedElement);
@@ -1795,6 +1784,42 @@ private void MainWindow_PreviewKeyDown(object sender, KeyEventArgs e)
else if (ScrollContentPlaylist.Visibility == Visibility.Visible) ScrollContentPlaylist.Focus();
}
}
else if (catPan.IsAncestorOf(Keyboard.FocusedElement as DependencyObject) && e.Key == Key.Down)
{
e.Handled = true;
var buttons = catPan.Children.OfType<Button>().ToList();
var focused = Keyboard.FocusedElement as Button;
int index = buttons.IndexOf(focused);
if (index != -1 && index < buttons.Count - 1)
{
Dispatcher.BeginInvoke(new Action(() =>
{
buttons[index + 1].Focus();
}));
}
}
else if (catPan.IsAncestorOf(Keyboard.FocusedElement as DependencyObject) && e.Key == Key.Up)
{
e.Handled = true;
var buttons = catPan.Children.OfType<Button>().ToList();
var focused = Keyboard.FocusedElement as Button;
int index = buttons.IndexOf(focused);
if (index > 0)
{
Dispatcher.BeginInvoke(new Action(() =>
{
buttons[index - 1].Focus();
}));
}
}
}
private Control FindFirstFocusableInVisibleWrapPanel()