Working on multiple instance and multiple application layout of taskbar.

This commit is contained in:
Damian Büchel 2017-07-17 08:28:18 +02:00
parent e623101f8c
commit 2104f401ec
7 changed files with 98 additions and 34 deletions

View file

@ -171,16 +171,35 @@ namespace SafeExamBrowser.Core.Behaviour
private void InitializeBrowser()
{
var browserButton = uiFactory.CreateApplicationButton(browserInfo);
logger.Info("Initializing browser.");
splashScreen.UpdateText(Key.SplashScreen_InitializeBrowser);
var browserButton = uiFactory.CreateApplicationButton(browserInfo);
browserController.RegisterApplicationButton(browserButton);
// TODO
taskbar.AddButton(browserButton);
taskbar.AddButton(uiFactory.CreateApplicationButton(browserInfo));
taskbar.AddButton(uiFactory.CreateApplicationButton(browserInfo));
taskbar.AddButton(uiFactory.CreateApplicationButton(browserInfo));
taskbar.AddButton(uiFactory.CreateApplicationButton(browserInfo));
taskbar.AddButton(uiFactory.CreateApplicationButton(browserInfo));
taskbar.AddButton(uiFactory.CreateApplicationButton(browserInfo));
taskbar.AddButton(uiFactory.CreateApplicationButton(browserInfo));
taskbar.AddButton(uiFactory.CreateApplicationButton(browserInfo));
taskbar.AddButton(uiFactory.CreateApplicationButton(browserInfo));
taskbar.AddButton(uiFactory.CreateApplicationButton(browserInfo));
taskbar.AddButton(uiFactory.CreateApplicationButton(browserInfo));
taskbar.AddButton(uiFactory.CreateApplicationButton(browserInfo));
taskbar.AddButton(uiFactory.CreateApplicationButton(browserInfo));
taskbar.AddButton(uiFactory.CreateApplicationButton(browserInfo));
taskbar.AddButton(uiFactory.CreateApplicationButton(browserInfo));
taskbar.AddButton(uiFactory.CreateApplicationButton(browserInfo));
taskbar.AddButton(uiFactory.CreateApplicationButton(browserInfo));
taskbar.AddButton(uiFactory.CreateApplicationButton(browserInfo));
taskbar.SetPosition(500, 500);
}
private void FinishInitialization()

View file

@ -4,15 +4,20 @@
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:SafeExamBrowser.UserInterface.Controls"
xmlns:s="clr-namespace:System;assembly=mscorlib"
mc:Ignorable="d"
d:DesignHeight="40" d:DesignWidth="50">
<Grid>
<Popup x:Name="InstancePopup" IsOpen="False" Placement="Top" PlacementTarget="{Binding ElementName=Button}" AllowsTransparency="True">
<StackPanel x:Name="InstanceStackPanel">
<StackPanel.Background>
<ScrollViewer x:Name="InstanceScrollViewer" VerticalScrollBarVisibility="Auto">
<ScrollViewer.Background>
<SolidColorBrush Color="Black" Opacity="0.8"/>
</StackPanel.Background>
</StackPanel>
</ScrollViewer.Background>
<ScrollViewer.Resources>
<s:Double x:Key="{x:Static SystemParameters.VerticalScrollBarWidthKey}">5</s:Double>
</ScrollViewer.Resources>
<StackPanel x:Name="InstanceStackPanel" />
</ScrollViewer>
</Popup>
<Button x:Name="Button" BorderThickness="0" Click="Button_Click" Width="50">
<Button.Template>

View file

@ -8,6 +8,7 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Windows;
using System.Windows.Controls;
using SafeExamBrowser.Contracts.Configuration;
@ -38,11 +39,6 @@ namespace SafeExamBrowser.UserInterface.Controls
instances.Add(instance);
instanceButton.Click += (id) => OnClick?.Invoke(id);
InstanceStackPanel.Children.Add(instanceButton);
if (instances.Count > 1)
{
InstancePopup.IsOpen = true;
}
}
public void UnregisterInstance(Guid id)
@ -57,13 +53,20 @@ namespace SafeExamBrowser.UserInterface.Controls
Button.Content = ApplicationIconResourceLoader.Load(info.IconResource);
InstancePopup.MouseLeave += (o, args) => InstancePopup.IsOpen = false;
InstanceStackPanel.SizeChanged += (o, args) =>
{
if (instances.Count > 9)
{
InstanceScrollViewer.MaxHeight = InstanceScrollViewer.ActualHeight;
}
};
}
private void Button_Click(object sender, RoutedEventArgs e)
{
if (instances.Count <= 1)
{
OnClick?.Invoke();
OnClick?.Invoke(instances.FirstOrDefault()?.Id);
}
else
{

View file

@ -39,7 +39,7 @@ namespace SafeExamBrowser.UserInterface.Controls
panel.Children.Add(ApplicationIconResourceLoader.Load(info.IconResource));
panel.Children.Add(new TextBlock { Text = instance.Name, Foreground = Brushes.White, Padding = new Thickness(5, 0, 5, 0) });
Button.ToolTip = info.Tooltip;
Button.ToolTip = $"{instance.Name} - {info.Tooltip}";
Button.Content = panel;
}

View file

@ -4,6 +4,7 @@
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:SafeExamBrowser.UserInterface.Controls"
xmlns:s="clr-namespace:System;assembly=mscorlib"
mc:Ignorable="d"
Title="Taskbar" Height="40" Width="750" WindowStyle="None" AllowsTransparency="True" Topmost="True" Icon="./Images/Icon.ico">
<Window.Background>
@ -16,7 +17,12 @@
<ColumnDefinition Width="75" />
<ColumnDefinition Width="40" />
</Grid.ColumnDefinitions>
<StackPanel x:Name="ApplicationAreaStackPanel" Orientation="Horizontal" />
<ScrollViewer Grid.Column="0" x:Name="ApplicationScrollViewer" VerticalScrollBarVisibility="Disabled" HorizontalScrollBarVisibility="Auto" PreviewMouseWheel="ApplicationScrollViewer_PreviewMouseWheel">
<ScrollViewer.Resources>
<s:Double x:Key="{x:Static SystemParameters.HorizontalScrollBarHeightKey}">5</s:Double>
</ScrollViewer.Resources>
<StackPanel x:Name="ApplicationStackPanel" Orientation="Horizontal" />
</ScrollViewer>
<local:DateTimeControl Grid.Column="2" />
</Grid>
</Window>

View file

@ -22,7 +22,7 @@ namespace SafeExamBrowser.UserInterface
{
if (button is UIElement)
{
ApplicationAreaStackPanel.Children.Add(button as UIElement);
ApplicationStackPanel.Children.Add(button as UIElement);
}
}
@ -37,5 +37,36 @@ namespace SafeExamBrowser.UserInterface
Width = width;
Height = height;
}
private void ApplicationScrollViewer_PreviewMouseWheel(object sender, System.Windows.Input.MouseWheelEventArgs e)
{
var scrollAmount = 20;
if (ApplicationScrollViewer.IsMouseOver)
{
if (e.Delta < 0)
{
if (ApplicationScrollViewer.HorizontalOffset + scrollAmount > 0)
{
ApplicationScrollViewer.ScrollToHorizontalOffset(ApplicationScrollViewer.HorizontalOffset + scrollAmount);
}
else
{
ApplicationScrollViewer.ScrollToLeftEnd();
}
}
else
{
if (ApplicationScrollViewer.ExtentWidth > ApplicationScrollViewer.HorizontalOffset - scrollAmount)
{
ApplicationScrollViewer.ScrollToHorizontalOffset(ApplicationScrollViewer.HorizontalOffset - scrollAmount);
}
else
{
ApplicationScrollViewer.ScrollToRightEnd();
}
}
}
}
}
}

View file

@ -62,25 +62,6 @@ namespace SafeExamBrowser
base.OnExit(e);
}
private void InitializeApplication()
{
instances.BuildObjectGraph();
var success = instances.StartupController.TryInitializeApplication();
if (success)
{
MainWindow = instances.Taskbar;
MainWindow.Show();
}
else
{
Shutdown();
}
instances.SplashScreen?.Dispatcher.InvokeAsync(instances.SplashScreen.Close);
}
private void ShowSplashScreen()
{
instances.BuildModulesRequiredBySplashScreen();
@ -104,5 +85,24 @@ namespace SafeExamBrowser
splashReadyEvent.WaitOne();
}
private void InitializeApplication()
{
instances.BuildObjectGraph();
var success = instances.StartupController.TryInitializeApplication();
if (success)
{
MainWindow = instances.Taskbar;
MainWindow.Show();
}
else
{
Shutdown();
}
instances.SplashScreen?.Dispatcher.InvokeAsync(instances.SplashScreen.Close);
}
}
}