2017-08-22 10:29:00 +02:00
|
|
|
|
/*
|
2024-03-05 18:37:42 +01:00
|
|
|
|
* Copyright (c) 2024 ETH Zürich, IT Services
|
2017-08-22 10:29:00 +02:00
|
|
|
|
*
|
|
|
|
|
* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
using System.Windows;
|
|
|
|
|
using System.Windows.Controls;
|
2019-08-30 09:55:26 +02:00
|
|
|
|
using SafeExamBrowser.Applications.Contracts;
|
2021-03-18 23:12:07 +01:00
|
|
|
|
using SafeExamBrowser.Core.Contracts.Resources.Icons;
|
2019-05-08 09:56:34 +02:00
|
|
|
|
using SafeExamBrowser.UserInterface.Shared.Utilities;
|
2017-08-22 10:29:00 +02:00
|
|
|
|
|
2020-03-16 18:29:06 +01:00
|
|
|
|
namespace SafeExamBrowser.UserInterface.Desktop.Controls.Taskbar
|
2017-08-22 10:29:00 +02:00
|
|
|
|
{
|
2020-03-16 18:29:06 +01:00
|
|
|
|
internal partial class ApplicationWindowButton : UserControl
|
2017-08-22 10:29:00 +02:00
|
|
|
|
{
|
2019-11-28 17:22:04 +01:00
|
|
|
|
private IApplicationWindow window;
|
2017-08-22 10:29:00 +02:00
|
|
|
|
|
2020-03-16 18:29:06 +01:00
|
|
|
|
internal ApplicationWindowButton(IApplicationWindow window)
|
2017-08-22 10:29:00 +02:00
|
|
|
|
{
|
2019-11-28 17:22:04 +01:00
|
|
|
|
this.window = window;
|
2017-08-22 10:29:00 +02:00
|
|
|
|
|
|
|
|
|
InitializeComponent();
|
|
|
|
|
InitializeApplicationInstanceButton();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void InitializeApplicationInstanceButton()
|
|
|
|
|
{
|
2019-08-30 12:30:00 +02:00
|
|
|
|
Button.Click += Button_Click;
|
2019-11-28 17:22:04 +01:00
|
|
|
|
Button.ToolTip = window.Title;
|
|
|
|
|
Icon.Content = IconResourceLoader.Load(window.Icon);
|
|
|
|
|
window.IconChanged += Instance_IconChanged;
|
|
|
|
|
window.TitleChanged += Window_TitleChanged;
|
|
|
|
|
Text.Text = window.Title;
|
2019-08-30 12:30:00 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void Button_Click(object sender, RoutedEventArgs e)
|
|
|
|
|
{
|
2019-11-28 17:22:04 +01:00
|
|
|
|
window.Activate();
|
2019-01-17 16:15:10 +01:00
|
|
|
|
}
|
|
|
|
|
|
2019-11-06 08:45:37 +01:00
|
|
|
|
private void Instance_IconChanged(IconResource icon)
|
2019-01-17 16:15:10 +01:00
|
|
|
|
{
|
2019-01-23 14:18:44 +01:00
|
|
|
|
Dispatcher.InvokeAsync(() => Icon.Content = IconResourceLoader.Load(icon));
|
2019-01-17 16:15:10 +01:00
|
|
|
|
}
|
|
|
|
|
|
2019-11-28 17:22:04 +01:00
|
|
|
|
private void Window_TitleChanged(string title)
|
2019-01-17 16:15:10 +01:00
|
|
|
|
{
|
2019-11-28 17:22:04 +01:00
|
|
|
|
Dispatcher.InvokeAsync(() =>
|
2017-08-22 10:29:00 +02:00
|
|
|
|
{
|
2019-11-28 17:22:04 +01:00
|
|
|
|
Text.Text = title;
|
|
|
|
|
Button.ToolTip = title;
|
2019-01-17 16:15:10 +01:00
|
|
|
|
});
|
2017-08-22 10:29:00 +02:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|