From e4508f0d495d8340c9c4b5ba22f31deb632bb6aa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Damian=20B=C3=BCchel?= Date: Mon, 17 Jul 2017 11:16:49 +0200 Subject: [PATCH] Finished first draft of multi-instance and multi-application layout / behaviour of taskbar. --- .../Behaviour/StartupController.cs | 19 ------------------- .../Controls/ApplicationButton.xaml | 9 ++++++--- .../Controls/ApplicationButton.xaml.cs | 14 ++++++++++++-- .../Controls/ApplicationInstanceButton.xaml | 4 ++++ .../ApplicationInstanceButton.xaml.cs | 9 ++------- 5 files changed, 24 insertions(+), 31 deletions(-) diff --git a/SafeExamBrowser.Core/Behaviour/StartupController.cs b/SafeExamBrowser.Core/Behaviour/StartupController.cs index 86d40035..1efbf712 100644 --- a/SafeExamBrowser.Core/Behaviour/StartupController.cs +++ b/SafeExamBrowser.Core/Behaviour/StartupController.cs @@ -181,25 +181,6 @@ namespace SafeExamBrowser.Core.Behaviour // 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() diff --git a/SafeExamBrowser.UserInterface/Controls/ApplicationButton.xaml b/SafeExamBrowser.UserInterface/Controls/ApplicationButton.xaml index f028afc1..277fccb0 100644 --- a/SafeExamBrowser.UserInterface/Controls/ApplicationButton.xaml +++ b/SafeExamBrowser.UserInterface/Controls/ApplicationButton.xaml @@ -11,7 +11,7 @@ - + 5 @@ -19,10 +19,10 @@ - + + + diff --git a/SafeExamBrowser.UserInterface/Controls/ApplicationButton.xaml.cs b/SafeExamBrowser.UserInterface/Controls/ApplicationButton.xaml.cs index cfbf832c..95aab8e5 100644 --- a/SafeExamBrowser.UserInterface/Controls/ApplicationButton.xaml.cs +++ b/SafeExamBrowser.UserInterface/Controls/ApplicationButton.xaml.cs @@ -14,6 +14,7 @@ using System.Windows.Controls; using SafeExamBrowser.Contracts.Configuration; using SafeExamBrowser.Contracts.UserInterface; using SafeExamBrowser.UserInterface.Utilities; +using System.Windows.Media; namespace SafeExamBrowser.UserInterface.Controls { @@ -39,20 +40,28 @@ namespace SafeExamBrowser.UserInterface.Controls instances.Add(instance); instanceButton.Click += (id) => OnClick?.Invoke(id); InstanceStackPanel.Children.Add(instanceButton); + + ActiveBar.Visibility = Visibility.Visible; } 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() { Button.ToolTip = info.Tooltip; - Button.MouseLeave += (o, args) => InstancePopup.IsOpen = InstancePopup.IsMouseOver; Button.Content = ApplicationIconResourceLoader.Load(info.IconResource); + Button.MouseLeave += (o, args) => InstancePopup.IsOpen = InstancePopup.IsMouseOver; InstancePopup.MouseLeave += (o, args) => InstancePopup.IsOpen = false; + InstancePopup.Closed += (o, args) => ActiveBar.Width = 40; InstanceStackPanel.SizeChanged += (o, args) => { if (instances.Count > 9) @@ -71,6 +80,7 @@ namespace SafeExamBrowser.UserInterface.Controls else { InstancePopup.IsOpen = true; + ActiveBar.Width = Double.NaN; } } } diff --git a/SafeExamBrowser.UserInterface/Controls/ApplicationInstanceButton.xaml b/SafeExamBrowser.UserInterface/Controls/ApplicationInstanceButton.xaml index fe5bcc08..223aadbf 100644 --- a/SafeExamBrowser.UserInterface/Controls/ApplicationInstanceButton.xaml +++ b/SafeExamBrowser.UserInterface/Controls/ApplicationInstanceButton.xaml @@ -22,6 +22,10 @@ + + + + diff --git a/SafeExamBrowser.UserInterface/Controls/ApplicationInstanceButton.xaml.cs b/SafeExamBrowser.UserInterface/Controls/ApplicationInstanceButton.xaml.cs index 4fead73a..3a82cfd5 100644 --- a/SafeExamBrowser.UserInterface/Controls/ApplicationInstanceButton.xaml.cs +++ b/SafeExamBrowser.UserInterface/Controls/ApplicationInstanceButton.xaml.cs @@ -9,7 +9,6 @@ using System; using System.Windows; using System.Windows.Controls; -using System.Windows.Media; using SafeExamBrowser.Contracts.Configuration; using SafeExamBrowser.UserInterface.Utilities; @@ -34,13 +33,9 @@ namespace SafeExamBrowser.UserInterface.Controls private void InitializeApplicationInstanceButton() { - var panel = new StackPanel { Orientation = Orientation.Horizontal }; - - 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) }); - + Icon.Content = ApplicationIconResourceLoader.Load(info.IconResource); + Text.Text = instance.Name; Button.ToolTip = $"{instance.Name} - {info.Tooltip}"; - Button.Content = panel; } private void Button_Click(object sender, RoutedEventArgs e)