58 lines
2.2 KiB
C#
58 lines
2.2 KiB
C#
using System;
|
|
using System.Drawing;
|
|
using System.Drawing.Drawing2D;
|
|
using System.Threading;
|
|
|
|
namespace QuickClaude
|
|
{
|
|
public static class Program
|
|
{
|
|
[STAThread]
|
|
public static int Main(string[] args)
|
|
{
|
|
// Run as Claude Code's shell-command confirm hook (separate short-lived process)
|
|
if (Array.IndexOf(args, "--confirm") >= 0) return ConfirmHook.Run();
|
|
|
|
using var mutex = new Mutex(true, "QuickClaude.SingleInstance", out bool first);
|
|
if (!first) return 0;
|
|
|
|
var app = new System.Windows.Application { ShutdownMode = System.Windows.ShutdownMode.OnExplicitShutdown };
|
|
var win = new MainWindow();
|
|
win.Show();
|
|
app.Run();
|
|
return 0;
|
|
}
|
|
}
|
|
|
|
public static class TrayIcon
|
|
{
|
|
[System.Runtime.InteropServices.DllImport("user32.dll")] static extern bool DestroyIcon(IntPtr h);
|
|
|
|
public static Icon Make()
|
|
{
|
|
using var bmp = new Bitmap(32, 32);
|
|
using (var g = Graphics.FromImage(bmp))
|
|
{
|
|
g.SmoothingMode = SmoothingMode.AntiAlias;
|
|
g.Clear(Color.Transparent);
|
|
using var fill = new SolidBrush(Color.FromArgb(0x1E, 0x3A, 0x8A)); // dark blue, matches app.ico
|
|
using var path = new GraphicsPath();
|
|
int r = 8;
|
|
path.AddArc(1, 1, r * 2, r * 2, 180, 90);
|
|
path.AddArc(31 - r * 2, 1, r * 2, r * 2, 270, 90);
|
|
path.AddArc(31 - r * 2, 31 - r * 2, r * 2, r * 2, 0, 90);
|
|
path.AddArc(1, 31 - r * 2, r * 2, r * 2, 90, 90);
|
|
path.CloseFigure();
|
|
g.FillPath(fill, path);
|
|
using var font = new Font("Segoe UI", 17, FontStyle.Bold, GraphicsUnit.Pixel);
|
|
var sf = new StringFormat { Alignment = StringAlignment.Center, LineAlignment = StringAlignment.Center };
|
|
g.DrawString("C", font, Brushes.White, new RectangleF(0, 1, 32, 32), sf);
|
|
}
|
|
var h = bmp.GetHicon();
|
|
var icon = (Icon)Icon.FromHandle(h).Clone();
|
|
DestroyIcon(h);
|
|
return icon;
|
|
}
|
|
}
|
|
}
|