2017-08-22 10:29:00 +02:00
|
|
|
|
/*
|
2019-01-09 11:25:21 +01:00
|
|
|
|
* Copyright (c) 2019 ETH Zürich, Educational Development and Technology (LET)
|
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/.
|
|
|
|
|
*/
|
|
|
|
|
|
2019-08-30 12:30:00 +02:00
|
|
|
|
using System;
|
2017-08-22 10:29:00 +02:00
|
|
|
|
using System.Windows.Controls;
|
2019-08-30 09:55:26 +02:00
|
|
|
|
using SafeExamBrowser.Applications.Contracts;
|
|
|
|
|
using SafeExamBrowser.Core.Contracts;
|
2019-05-08 09:56:34 +02:00
|
|
|
|
using SafeExamBrowser.UserInterface.Shared.Utilities;
|
2017-08-22 10:29:00 +02:00
|
|
|
|
|
2019-01-11 15:32:47 +01:00
|
|
|
|
namespace SafeExamBrowser.UserInterface.Desktop.Controls
|
2017-08-22 10:29:00 +02:00
|
|
|
|
{
|
2019-03-08 11:43:52 +01:00
|
|
|
|
public partial class ActionCenterApplicationButton : UserControl
|
2017-08-22 10:29:00 +02:00
|
|
|
|
{
|
2019-12-02 15:48:06 +01:00
|
|
|
|
private IApplication application;
|
2019-11-28 17:22:04 +01:00
|
|
|
|
private IApplicationWindow window;
|
2017-08-22 10:29:00 +02:00
|
|
|
|
|
2019-08-30 12:30:00 +02:00
|
|
|
|
internal event EventHandler Clicked;
|
2017-08-22 10:29:00 +02:00
|
|
|
|
|
2019-12-02 15:48:06 +01:00
|
|
|
|
public ActionCenterApplicationButton(IApplication application, IApplicationWindow window = null)
|
2017-08-22 10:29:00 +02:00
|
|
|
|
{
|
2019-12-02 15:48:06 +01:00
|
|
|
|
this.application = application;
|
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-12-02 15:48:06 +01:00
|
|
|
|
Icon.Content = IconResourceLoader.Load(application.Icon);
|
|
|
|
|
Text.Text = window?.Title ?? application.Name;
|
2019-08-30 12:30:00 +02:00
|
|
|
|
Button.Click += (o, args) => Clicked?.Invoke(this, EventArgs.Empty);
|
2019-12-02 15:48:06 +01:00
|
|
|
|
Button.ToolTip = window?.Title ?? application.Tooltip;
|
2017-08-22 10:29:00 +02:00
|
|
|
|
|
2019-11-28 17:22:04 +01:00
|
|
|
|
if (window != null)
|
2019-03-08 11:43:52 +01:00
|
|
|
|
{
|
2019-11-28 17:22:04 +01:00
|
|
|
|
window.IconChanged += Window_IconChanged;
|
|
|
|
|
window.TitleChanged += Window_TitleChanged;
|
2019-03-08 11:43:52 +01:00
|
|
|
|
}
|
2019-01-17 16:15:10 +01:00
|
|
|
|
}
|
|
|
|
|
|
2019-11-28 17:22:04 +01:00
|
|
|
|
private void Window_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-08-30 12:30:00 +02: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
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|