Implemented visual indication for active applications in taskbar.

This commit is contained in:
Damian Büchel 2022-10-27 13:06:49 +02:00
parent cd053e760e
commit 89401df6f6
4 changed files with 18 additions and 4 deletions

View file

@ -24,5 +24,8 @@
</Border>
</Popup>
<Button x:Name="Button" Background="{StaticResource BackgroundBrush}" Padding="4" Template="{StaticResource TaskbarButton}" Width="50" />
<Grid>
<Rectangle x:Name="ActiveBar" Cursor="Hand" Height="2.5" Width="40" VerticalAlignment="Bottom" Fill="DodgerBlue" Visibility="Collapsed" />
</Grid>
</Grid>
</UserControl>

View file

@ -21,7 +21,7 @@ namespace SafeExamBrowser.UserInterface.Desktop.Controls.Taskbar
{
internal partial class ApplicationControl : UserControl, IApplicationControl
{
private IApplication application;
private readonly IApplication application;
private IApplicationWindow single;
internal ApplicationControl(IApplication application)
@ -38,22 +38,25 @@ namespace SafeExamBrowser.UserInterface.Desktop.Controls.Taskbar
application.WindowsChanged += Application_WindowsChanged;
ActiveBar.MouseLeave += (o, args) => WindowPopup.IsOpen &= WindowPopup.IsMouseOver || Button.IsMouseOver;
Button.Click += Button_Click;
Button.Content = IconResourceLoader.Load(application.Icon);
Button.MouseEnter += (o, args) => WindowPopup.IsOpen = WindowStackPanel.Children.Count > 0;
Button.MouseLeave += (o, args) => Task.Delay(250).ContinueWith(_ => Dispatcher.Invoke(() => WindowPopup.IsOpen = WindowPopup.IsMouseOver));
Button.MouseLeave += (o, args) => Task.Delay(250).ContinueWith(_ => Dispatcher.Invoke(() => WindowPopup.IsOpen = WindowPopup.IsMouseOver || ActiveBar.IsMouseOver));
Button.ToolTip = application.Tooltip;
WindowPopup.CustomPopupPlacementCallback = new CustomPopupPlacementCallback(WindowPopup_PlacementCallback);
WindowPopup.MouseLeave += (o, args) => Task.Delay(250).ContinueWith(_ => Dispatcher.Invoke(() => WindowPopup.IsOpen = IsMouseOver));
WindowPopup.Opened += (o, args) =>
{
ActiveBar.Width = double.NaN;
Background = Brushes.LightGray;
Button.Background = Brushes.LightGray;
};
WindowPopup.Closed += (o, args) =>
{
ActiveBar.Width = 40;
Background = originalBrush;
Button.Background = originalBrush;
};
@ -88,6 +91,7 @@ namespace SafeExamBrowser.UserInterface.Desktop.Controls.Taskbar
{
var windows = application.GetWindows();
ActiveBar.Visibility = windows.Any() ? Visibility.Visible : Visibility.Collapsed;
WindowStackPanel.Children.Clear();
foreach (var window in windows)

View file

@ -24,5 +24,8 @@
</Border>
</Popup>
<Button x:Name="Button" Background="{StaticResource BackgroundBrush}" Padding="4" Template="{StaticResource TaskbarButton}" Width="60" />
<Grid>
<Rectangle x:Name="ActiveBar" Cursor="Hand" Height="2.5" Width="40" VerticalAlignment="Bottom" Fill="DodgerBlue" Visibility="Collapsed" />
</Grid>
</Grid>
</UserControl>

View file

@ -21,7 +21,7 @@ namespace SafeExamBrowser.UserInterface.Mobile.Controls.Taskbar
{
internal partial class ApplicationControl : UserControl, IApplicationControl
{
private IApplication application;
private readonly IApplication application;
private IApplicationWindow single;
internal ApplicationControl(IApplication application)
@ -38,22 +38,25 @@ namespace SafeExamBrowser.UserInterface.Mobile.Controls.Taskbar
application.WindowsChanged += Application_WindowsChanged;
ActiveBar.MouseLeave += (o, args) => WindowPopup.IsOpen &= WindowPopup.IsMouseOver || Button.IsMouseOver;
Button.Click += Button_Click;
Button.Content = IconResourceLoader.Load(application.Icon);
Button.MouseEnter += (o, args) => WindowPopup.IsOpen = WindowStackPanel.Children.Count > 0;
Button.MouseLeave += (o, args) => Task.Delay(250).ContinueWith(_ => Dispatcher.Invoke(() => WindowPopup.IsOpen = WindowPopup.IsMouseOver));
Button.MouseLeave += (o, args) => Task.Delay(250).ContinueWith(_ => Dispatcher.Invoke(() => WindowPopup.IsOpen = WindowPopup.IsMouseOver || ActiveBar.IsMouseOver));
Button.ToolTip = application.Tooltip;
WindowPopup.CustomPopupPlacementCallback = new CustomPopupPlacementCallback(WindowPopup_PlacementCallback);
WindowPopup.MouseLeave += (o, args) => Task.Delay(250).ContinueWith(_ => Dispatcher.Invoke(() => WindowPopup.IsOpen = IsMouseOver));
WindowPopup.Opened += (o, args) =>
{
ActiveBar.Width = double.NaN;
Background = Brushes.LightGray;
Button.Background = Brushes.LightGray;
};
WindowPopup.Closed += (o, args) =>
{
ActiveBar.Width = 40;
Background = originalBrush;
Button.Background = originalBrush;
};
@ -88,6 +91,7 @@ namespace SafeExamBrowser.UserInterface.Mobile.Controls.Taskbar
{
var windows = application.GetWindows();
ActiveBar.Visibility = windows.Any() ? Visibility.Visible : Visibility.Collapsed;
WindowStackPanel.Children.Clear();
foreach (var window in windows)