chore: initial commit of TaskTracker project
Existing ASP.NET API with vanilla JS SPA, WindowWatcher, Chrome extension, and MCP server. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
58
WindowWatcher/TrayApplicationContext.cs
Normal file
58
WindowWatcher/TrayApplicationContext.cs
Normal file
@@ -0,0 +1,58 @@
|
||||
namespace WindowWatcher;
|
||||
|
||||
public class TrayApplicationContext : ApplicationContext
|
||||
{
|
||||
private readonly NotifyIcon _trayIcon;
|
||||
private readonly CancellationTokenSource _hostCts;
|
||||
private bool _trackingPaused;
|
||||
|
||||
public TrayApplicationContext(CancellationTokenSource hostCts)
|
||||
{
|
||||
_hostCts = hostCts;
|
||||
|
||||
_trayIcon = new NotifyIcon
|
||||
{
|
||||
Icon = SystemIcons.Application,
|
||||
Text = "Work Context Tracker",
|
||||
Visible = true,
|
||||
ContextMenuStrip = CreateMenu()
|
||||
};
|
||||
}
|
||||
|
||||
private ContextMenuStrip CreateMenu()
|
||||
{
|
||||
var menu = new ContextMenuStrip();
|
||||
|
||||
var pauseItem = new ToolStripMenuItem("Pause Tracking");
|
||||
pauseItem.Click += (_, _) =>
|
||||
{
|
||||
_trackingPaused = !_trackingPaused;
|
||||
pauseItem.Text = _trackingPaused ? "Resume Tracking" : "Pause Tracking";
|
||||
_trayIcon.Text = _trackingPaused ? "Work Context Tracker (Paused)" : "Work Context Tracker";
|
||||
};
|
||||
|
||||
var exitItem = new ToolStripMenuItem("Exit");
|
||||
exitItem.Click += (_, _) =>
|
||||
{
|
||||
_trayIcon.Visible = false;
|
||||
_hostCts.Cancel();
|
||||
Application.Exit();
|
||||
};
|
||||
|
||||
menu.Items.Add(pauseItem);
|
||||
menu.Items.Add(new ToolStripSeparator());
|
||||
menu.Items.Add(exitItem);
|
||||
|
||||
return menu;
|
||||
}
|
||||
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing)
|
||||
{
|
||||
_trayIcon.Visible = false;
|
||||
_trayIcon.Dispose();
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user