mirror of
https://github.com/ckaczor/FloatingStatusWindow.git
synced 2026-03-10 12:01:38 -04:00
- Update to .NET 10 - Set actual window title to window name - Add new way to identify other windows
76 lines
1.9 KiB
C#
76 lines
1.9 KiB
C#
using ChrisKaczor.Wpf.Windows.FloatingStatusWindow;
|
|
using System;
|
|
using System.Globalization;
|
|
using System.Reflection;
|
|
using System.Timers;
|
|
using System.Windows.Threading;
|
|
|
|
namespace TestWindow;
|
|
|
|
internal class WindowSource3 : IWindowSource, IDisposable
|
|
{
|
|
private readonly FloatingStatusWindow _floatingStatusWindow;
|
|
private readonly Timer _timer;
|
|
private readonly Dispatcher _dispatcher;
|
|
|
|
internal WindowSource3()
|
|
{
|
|
_floatingStatusWindow = new FloatingStatusWindow(this);
|
|
_floatingStatusWindow.SetText("Loading...");
|
|
|
|
_dispatcher = Dispatcher.CurrentDispatcher;
|
|
|
|
_timer = new Timer(1000);
|
|
_timer.Elapsed += HandleTimerElapsed;
|
|
_timer.Enabled = true;
|
|
}
|
|
|
|
private void HandleTimerElapsed(object sender, ElapsedEventArgs e)
|
|
{
|
|
_dispatcher.InvokeAsync(() => _floatingStatusWindow.SetText(DateTime.Now.ToString(CultureInfo.InvariantCulture)));
|
|
}
|
|
|
|
public void Dispose()
|
|
{
|
|
_timer.Enabled = false;
|
|
_timer.Dispose();
|
|
|
|
_floatingStatusWindow.Save();
|
|
_floatingStatusWindow.Dispose();
|
|
}
|
|
|
|
public Guid Id => Guid.Parse("CF7466DF-8980-452B-B2FA-290B26204BF2");
|
|
|
|
public string Name => "Test Window 3";
|
|
|
|
public System.Drawing.Icon Icon => Properties.Resources.ApplicationIcon;
|
|
|
|
public bool HasSettingsMenu => true;
|
|
|
|
public bool HasAboutMenu => true;
|
|
|
|
public void ShowAbout()
|
|
{
|
|
_floatingStatusWindow.SetText(Assembly.GetEntryAssembly()?.GetName().Version?.ToString());
|
|
}
|
|
|
|
public void ShowSettings()
|
|
{
|
|
}
|
|
|
|
public bool HasRefreshMenu => true;
|
|
|
|
public void Refresh()
|
|
{
|
|
}
|
|
|
|
public string WindowSettings
|
|
{
|
|
get => Properties.Settings.Default.WindowSettings3;
|
|
set
|
|
{
|
|
Properties.Settings.Default.WindowSettings3 = value;
|
|
Properties.Settings.Default.Save();
|
|
}
|
|
}
|
|
} |