2022-10-23 11:02:31 +13:00
|
|
|
|
// <copyright file="TaskbarLogo.xaml.cs" company="PlaceholderCompany">
|
|
|
|
|
// Copyright (c) PlaceholderCompany. All rights reserved.
|
|
|
|
|
// </copyright>
|
2022-11-13 09:07:15 +13:00
|
|
|
|
//
|
2023-08-12 12:33:11 +12:00
|
|
|
|
// Copyright (c) 2022-2023 Peter Kirmeier
|
2022-10-23 11:02:31 +13:00
|
|
|
|
|
|
|
|
|
namespace SystemTrayMenu.UserInterface
|
|
|
|
|
{
|
|
|
|
|
using System;
|
|
|
|
|
using System.Reflection;
|
|
|
|
|
using System.Windows;
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Logic of Taskbar window.
|
|
|
|
|
/// </summary>
|
|
|
|
|
public partial class TaskbarLogo : Window
|
|
|
|
|
{
|
|
|
|
|
public TaskbarLogo()
|
|
|
|
|
{
|
|
|
|
|
InitializeComponent();
|
|
|
|
|
|
|
|
|
|
Assembly myassembly = Assembly.GetExecutingAssembly();
|
|
|
|
|
string myname = myassembly.GetName().Name ?? string.Empty;
|
|
|
|
|
Title = myname;
|
|
|
|
|
|
|
|
|
|
Closed += (_, _) => Application.Current.Shutdown();
|
2023-09-23 06:39:43 +12:00
|
|
|
|
|
|
|
|
|
// Do final initialization after rendering has been finished for the first time.
|
|
|
|
|
// This ensures all icons and images are properly loaded and renderd (e.g. thumbnail image of alt tab menu).
|
|
|
|
|
ContentRendered += LateInitialize;
|
2022-12-04 13:24:30 +13:00
|
|
|
|
}
|
|
|
|
|
|
2023-09-23 06:39:43 +12:00
|
|
|
|
private void LateInitialize(object? sender, EventArgs e)
|
2022-12-04 13:24:30 +13:00
|
|
|
|
{
|
|
|
|
|
// Do this only once
|
2023-09-23 06:39:43 +12:00
|
|
|
|
ContentRendered -= LateInitialize;
|
|
|
|
|
|
|
|
|
|
// Move the window out of screen, just for safety
|
2022-12-04 13:24:30 +13:00
|
|
|
|
Top += SystemParameters.VirtualScreenHeight;
|
2023-09-23 06:39:43 +12:00
|
|
|
|
|
|
|
|
|
// There is nothing to see, so no need to show this window.
|
|
|
|
|
// Therefore it shall always be in minimized state.
|
|
|
|
|
// Further, we then can rely on every activating event.
|
|
|
|
|
WindowState = WindowState.Minimized;
|
|
|
|
|
StateChanged += (_, _) => WindowState = WindowState.Minimized;
|
2022-10-23 11:02:31 +13:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|