2017-07-14 10:28:59 +02:00
|
|
|
|
/*
|
2018-01-16 08:24:00 +01:00
|
|
|
|
* Copyright (c) 2018 ETH Zürich, Educational Development and Technology (LET)
|
2017-07-14 10:28:59 +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;
|
|
|
|
|
using System.Windows;
|
|
|
|
|
using System.Windows.Controls;
|
|
|
|
|
using SafeExamBrowser.Contracts.Configuration;
|
2017-08-22 08:39:49 +02:00
|
|
|
|
using SafeExamBrowser.UserInterface.Windows10.Utilities;
|
2017-07-14 10:28:59 +02:00
|
|
|
|
|
2017-08-22 08:39:49 +02:00
|
|
|
|
namespace SafeExamBrowser.UserInterface.Windows10.Controls
|
2017-07-14 10:28:59 +02:00
|
|
|
|
{
|
2017-08-02 08:31:12 +02:00
|
|
|
|
internal delegate void InstanceButtonClickedEventHandler(Guid instanceId);
|
|
|
|
|
|
2017-07-14 10:28:59 +02:00
|
|
|
|
public partial class ApplicationInstanceButton : UserControl
|
|
|
|
|
{
|
|
|
|
|
private IApplicationInfo info;
|
|
|
|
|
private IApplicationInstance instance;
|
|
|
|
|
|
2017-08-02 08:31:12 +02:00
|
|
|
|
internal event InstanceButtonClickedEventHandler Clicked;
|
2017-07-14 10:28:59 +02:00
|
|
|
|
|
|
|
|
|
public ApplicationInstanceButton(IApplicationInstance instance, IApplicationInfo info)
|
|
|
|
|
{
|
|
|
|
|
this.info = info;
|
|
|
|
|
this.instance = instance;
|
|
|
|
|
|
|
|
|
|
InitializeComponent();
|
|
|
|
|
InitializeApplicationInstanceButton();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void InitializeApplicationInstanceButton()
|
|
|
|
|
{
|
2017-07-17 16:59:50 +02:00
|
|
|
|
Icon.Content = IconResourceLoader.Load(info.IconResource);
|
2017-07-17 11:16:49 +02:00
|
|
|
|
Text.Text = instance.Name;
|
2017-07-31 20:22:53 +02:00
|
|
|
|
Button.ToolTip = instance.Name;
|
|
|
|
|
|
|
|
|
|
instance.NameChanged += (name) =>
|
|
|
|
|
{
|
|
|
|
|
Dispatcher.Invoke(() =>
|
|
|
|
|
{
|
|
|
|
|
Text.Text = name;
|
|
|
|
|
Button.ToolTip = name;
|
|
|
|
|
});
|
|
|
|
|
};
|
2017-07-14 10:28:59 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void Button_Click(object sender, RoutedEventArgs e)
|
|
|
|
|
{
|
2017-08-02 08:31:12 +02:00
|
|
|
|
Clicked?.Invoke(instance.Id);
|
2017-07-14 10:28:59 +02:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|