Finished first draft of multi-instance and multi-application layout / behaviour of taskbar.

This commit is contained in:
Damian Büchel 2017-07-17 11:16:49 +02:00
parent 2104f401ec
commit e4508f0d49
5 changed files with 24 additions and 31 deletions

View file

@ -181,25 +181,6 @@ namespace SafeExamBrowser.Core.Behaviour
// TODO // TODO
taskbar.AddButton(browserButton); 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() private void FinishInitialization()

View file

@ -11,7 +11,7 @@
<Popup x:Name="InstancePopup" IsOpen="False" Placement="Top" PlacementTarget="{Binding ElementName=Button}" AllowsTransparency="True"> <Popup x:Name="InstancePopup" IsOpen="False" Placement="Top" PlacementTarget="{Binding ElementName=Button}" AllowsTransparency="True">
<ScrollViewer x:Name="InstanceScrollViewer" VerticalScrollBarVisibility="Auto"> <ScrollViewer x:Name="InstanceScrollViewer" VerticalScrollBarVisibility="Auto">
<ScrollViewer.Background> <ScrollViewer.Background>
<SolidColorBrush Color="Black" Opacity="0.8"/> <SolidColorBrush Color="Black" Opacity="0.8" />
</ScrollViewer.Background> </ScrollViewer.Background>
<ScrollViewer.Resources> <ScrollViewer.Resources>
<s:Double x:Key="{x:Static SystemParameters.VerticalScrollBarWidthKey}">5</s:Double> <s:Double x:Key="{x:Static SystemParameters.VerticalScrollBarWidthKey}">5</s:Double>
@ -19,10 +19,10 @@
<StackPanel x:Name="InstanceStackPanel" /> <StackPanel x:Name="InstanceStackPanel" />
</ScrollViewer> </ScrollViewer>
</Popup> </Popup>
<Button x:Name="Button" BorderThickness="0" Click="Button_Click" Width="50"> <Button x:Name="Button" Background="#00000000" BorderThickness="0" Click="Button_Click" Width="50">
<Button.Template> <Button.Template>
<ControlTemplate TargetType="Button"> <ControlTemplate TargetType="Button">
<Border x:Name="ButtonContent" Background="#00000000" Padding="5"> <Border x:Name="ButtonContent" Background="{TemplateBinding Background}" Padding="5">
<ContentPresenter VerticalAlignment="Center" HorizontalAlignment="Center" ContentSource="Content" /> <ContentPresenter VerticalAlignment="Center" HorizontalAlignment="Center" ContentSource="Content" />
</Border> </Border>
<ControlTemplate.Triggers> <ControlTemplate.Triggers>
@ -36,5 +36,8 @@
</ControlTemplate> </ControlTemplate>
</Button.Template> </Button.Template>
</Button> </Button>
<Grid Panel.ZIndex="10">
<Rectangle x:Name="ActiveBar" Height="3" Width="40" VerticalAlignment="Bottom" Fill="LightSteelBlue" Visibility="Collapsed" />
</Grid>
</Grid> </Grid>
</UserControl> </UserControl>

View file

@ -14,6 +14,7 @@ using System.Windows.Controls;
using SafeExamBrowser.Contracts.Configuration; using SafeExamBrowser.Contracts.Configuration;
using SafeExamBrowser.Contracts.UserInterface; using SafeExamBrowser.Contracts.UserInterface;
using SafeExamBrowser.UserInterface.Utilities; using SafeExamBrowser.UserInterface.Utilities;
using System.Windows.Media;
namespace SafeExamBrowser.UserInterface.Controls namespace SafeExamBrowser.UserInterface.Controls
{ {
@ -39,20 +40,28 @@ namespace SafeExamBrowser.UserInterface.Controls
instances.Add(instance); instances.Add(instance);
instanceButton.Click += (id) => OnClick?.Invoke(id); instanceButton.Click += (id) => OnClick?.Invoke(id);
InstanceStackPanel.Children.Add(instanceButton); InstanceStackPanel.Children.Add(instanceButton);
ActiveBar.Visibility = Visibility.Visible;
} }
public void UnregisterInstance(Guid id) public void UnregisterInstance(Guid id)
{ {
throw new NotImplementedException(); instances.Remove(instances.FirstOrDefault(i => i.Id == id));
if (!instances.Any())
{
ActiveBar.Visibility = Visibility.Collapsed;
}
} }
private void InitializeApplicationButton() private void InitializeApplicationButton()
{ {
Button.ToolTip = info.Tooltip; Button.ToolTip = info.Tooltip;
Button.MouseLeave += (o, args) => InstancePopup.IsOpen = InstancePopup.IsMouseOver;
Button.Content = ApplicationIconResourceLoader.Load(info.IconResource); Button.Content = ApplicationIconResourceLoader.Load(info.IconResource);
Button.MouseLeave += (o, args) => InstancePopup.IsOpen = InstancePopup.IsMouseOver;
InstancePopup.MouseLeave += (o, args) => InstancePopup.IsOpen = false; InstancePopup.MouseLeave += (o, args) => InstancePopup.IsOpen = false;
InstancePopup.Closed += (o, args) => ActiveBar.Width = 40;
InstanceStackPanel.SizeChanged += (o, args) => InstanceStackPanel.SizeChanged += (o, args) =>
{ {
if (instances.Count > 9) if (instances.Count > 9)
@ -71,6 +80,7 @@ namespace SafeExamBrowser.UserInterface.Controls
else else
{ {
InstancePopup.IsOpen = true; InstancePopup.IsOpen = true;
ActiveBar.Width = Double.NaN;
} }
} }
} }

View file

@ -22,6 +22,10 @@
</ControlTemplate.Triggers> </ControlTemplate.Triggers>
</ControlTemplate> </ControlTemplate>
</Button.Template> </Button.Template>
<StackPanel Orientation="Horizontal">
<ContentControl x:Name="Icon" />
<TextBlock x:Name="Text" Foreground="White" Padding="5,0,5,0" />
</StackPanel>
</Button> </Button>
</Grid> </Grid>
</UserControl> </UserControl>

View file

@ -9,7 +9,6 @@
using System; using System;
using System.Windows; using System.Windows;
using System.Windows.Controls; using System.Windows.Controls;
using System.Windows.Media;
using SafeExamBrowser.Contracts.Configuration; using SafeExamBrowser.Contracts.Configuration;
using SafeExamBrowser.UserInterface.Utilities; using SafeExamBrowser.UserInterface.Utilities;
@ -34,13 +33,9 @@ namespace SafeExamBrowser.UserInterface.Controls
private void InitializeApplicationInstanceButton() private void InitializeApplicationInstanceButton()
{ {
var panel = new StackPanel { Orientation = Orientation.Horizontal }; Icon.Content = ApplicationIconResourceLoader.Load(info.IconResource);
Text.Text = instance.Name;
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 = $"{instance.Name} - {info.Tooltip}"; Button.ToolTip = $"{instance.Name} - {info.Tooltip}";
Button.Content = panel;
} }
private void Button_Click(object sender, RoutedEventArgs e) private void Button_Click(object sender, RoutedEventArgs e)