-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathClaudeCodeToolWindow.cs
More file actions
100 lines (83 loc) · 2.92 KB
/
ClaudeCodeToolWindow.cs
File metadata and controls
100 lines (83 loc) · 2.92 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
/* *******************************************************************************************************************
* Application: ClaudeCodeExtension
*
* Autor: Daniel Carvalho Liedke
*
* Copyright © Daniel Carvalho Liedke 2026
* Usage and reproduction in any manner whatsoever without the written permission of Daniel Carvalho Liedke is strictly forbidden.
*
* Purpose: Tool window class for the Claude Code extension for VS.NET
*
* *******************************************************************************************************************/
using Microsoft.VisualStudio;
using Microsoft.VisualStudio.Imaging;
using Microsoft.VisualStudio.Shell;
using Microsoft.VisualStudio.Shell.Interop;
using System;
using System.Runtime.InteropServices;
namespace ClaudeCodeVS
{
[Guid("87654321-4321-4321-4321-987654321cba")]
public class ClaudeCodeToolWindow : ToolWindowPane, IVsWindowFrameNotify
{
private ClaudeCodeControl claudeCodeControl;
private uint _notifyCookie;
/// <summary>
/// Fired when the tool window's show state changes (tab activated, shown, hidden, etc.)
/// The int parameter is the raw __FRAMESHOW value.
/// </summary>
public event EventHandler<int> FrameShow;
public ClaudeCodeToolWindow() : base(null)
{
this.Caption = "Claude Code";
this.BitmapImageMoniker = KnownMonikers.Console;
claudeCodeControl = new ClaudeCodeControl();
this.Content = claudeCodeControl;
// Set up the reference so the control can update the title
claudeCodeControl.SetToolWindow(this);
}
public override void OnToolWindowCreated()
{
base.OnToolWindowCreated();
ThreadHelper.ThrowIfNotOnUIThread();
if (Frame is IVsWindowFrame2 windowFrame2)
{
windowFrame2.Advise(this, out _notifyCookie);
}
}
protected override void OnClose()
{
ThreadHelper.ThrowIfNotOnUIThread();
if (_notifyCookie != 0 && Frame is IVsWindowFrame2 windowFrame2)
{
windowFrame2.Unadvise(_notifyCookie);
_notifyCookie = 0;
}
base.OnClose();
}
public void UpdateTitle(string providerName)
{
ThreadHelper.ThrowIfNotOnUIThread();
this.Caption = $"{providerName}";
}
#region IVsWindowFrameNotify Implementation
public int OnShow(int fShow)
{
FrameShow?.Invoke(this, fShow);
return VSConstants.S_OK;
}
public int OnMove()
{
return VSConstants.S_OK;
}
public int OnSize()
{
return VSConstants.S_OK;
}
public int OnDockableChange(int fDockable)
{
return VSConstants.S_OK;
}
#endregion
}
}