Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions .claude/settings.local.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"permissions": {
"allow": [
"Bash(msbuild:*)",
"Bash(\"/c/Program Files/Microsoft Visual Studio/2022/Community/MSBuild/Current/Bin/amd64/MSBuild.exe\" ManageNotepadWindows.sln /p:Configuration=Release /v:minimal)",
"Bash(ls:*)",
"Bash(\"/c/Program Files/Microsoft Visual Studio/2022/Community/MSBuild/Current/Bin/amd64/MSBuild.exe\" ManageNotepadWindows.csproj /p:Configuration=Release)",
"Bash(\"/c/Program Files/Microsoft Visual Studio/2022/Community/MSBuild/Current/Bin/amd64/MSBuild.exe\" ManageNotepadWindows.csproj //p:Configuration=Release)",
"Bash(\"/c/Program Files/Microsoft Visual Studio/2022/Community/MSBuild/Current/Bin/amd64/MSBuild.exe\" ManageNotepadWindows.csproj //p:Configuration=Release //t:Rebuild)",
"Bash(taskkill:*)",
"Bash(start ./ManageNotepadWindows.exe)",
"Bash(nuget update:*)",
"Bash(powershell -Command \"Get-Content ManageNotepadWindows.exe.manifest\")",
"Bash(cmd.exe //c \"taskkill /F /IM ManageNotepadWindows.exe\")"
]
}
}
4 changes: 4 additions & 0 deletions .github/copilot-instructions.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Copilot Instructions

## General Guidelines
- When asked to fix code, provide a single consolidated, compile-clean C# file; prefer minimal diffs and explicit compile fixes.
47 changes: 47 additions & 0 deletions CLAUDE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
# CLAUDE.md

This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.

## Build Commands

```bash
# Build (Debug)
dotnet build ManageNotepadWindows/ManageNotepadWindows.csproj

# Build (Release)
dotnet build ManageNotepadWindows/ManageNotepadWindows.csproj -c Release

# Run
dotnet run --project ManageNotepadWindows/ManageNotepadWindows.csproj
```

## Architecture

**Single-form WinForms application** targeting .NET 10 that manages open Notepad instances and browser tabs.

### Core Components

- **NotepadsManager.cs**: Main form containing all UI logic, window enumeration, and P/Invoke declarations
- **Program.cs**: Application entry point with PerMonitorV2 DPI awareness

### Key Patterns

**Window Enumeration**: Uses Win32 `EnumWindows` P/Invoke to discover open windows. Notepad windows are identified by class names `Notepad` (classic) or `CascadiaWindow` (Windows 11). Browser windows use `Chrome_WidgetWin_1` (Chromium-based) or `MozillaWindowClass` (Firefox).

**Content Extraction**: Multi-strategy approach with timeouts to prevent UI hangs:
1. `WM_GETTEXT` via `SendMessageTimeout` to Edit controls (fastest, classic Notepad)
2. UI Automation `ValuePattern`/`TextPattern` (modern Notepad, Windows 11)
3. Recursive child window search for various RichEdit classes

**UI Library**: Uses AntdUI (v2.2.7) for modern-looking WinForms controls (Button, Input, Checkbox).

**Virtualized DataGridView**: Both grids use `VirtualMode=true` with `CellValueNeeded` events for efficient display of window lists.

### Data Storage

Unsaved notepad content is backed up to `%APPDATA%\NotepadBackups` every 5 minutes and restored on application startup.

## Guidelines

- Provide minimal diffs and ensure compile-clean output
- All P/Invoke calls that communicate with external windows must use `SendMessageTimeout` with `SMTO_ABORTIFHUNG` to prevent hangs
Binary file modified ManageNotepadWindows.v12.suo
Binary file not shown.
11 changes: 9 additions & 2 deletions ManageNotepadWindows/App.config
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />
<configSections>
<section name="System.Windows.Forms.ApplicationConfigurationSection" type="System.Configuration.ConfigurationSection, System.Configuration, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
</configSections>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.8" />
</startup>
<System.Windows.Forms.ApplicationConfigurationSection>
<add key="DpiAwareness" value="PerMonitorV2" />
<add key="EnableWindowsFormsHighDpiAutoResizing" value="true" />
</System.Windows.Forms.ApplicationConfigurationSection>
</configuration>
17 changes: 12 additions & 5 deletions ManageNotepadWindows/ManageNotepadWindows.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>ManageNotepadWindows</RootNamespace>
<AssemblyName>ManageNotepadWindows</AssemblyName>
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
<TargetFrameworkVersion>v4.8</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<IsWebBootstrapper>false</IsWebBootstrapper>
<PublishUrl>publish\</PublishUrl>
Expand Down Expand Up @@ -57,14 +57,18 @@
<ManifestKeyFile>ManageNotepadWindows_TemporaryKey.pfx</ManifestKeyFile>
</PropertyGroup>
<PropertyGroup>
<GenerateManifests>true</GenerateManifests>
<GenerateManifests>false</GenerateManifests>
</PropertyGroup>
<PropertyGroup>
<SignManifests>true</SignManifests>
<SignManifests>false</SignManifests>
</PropertyGroup>
<PropertyGroup>
<ApplicationManifest>app.manifest</ApplicationManifest>
<NoWin32Manifest>false</NoWin32Manifest>
</PropertyGroup>
<ItemGroup>
<Reference Include="MaterialSkin">
<HintPath>..\packages\MaterialSkin.2.2.3.1\lib\net45\MaterialSkin.dll</HintPath>
<Reference Include="AntdUI">
<HintPath>..\packages\AntdUI.2.2.7\lib\net48\AntdUI.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
Expand All @@ -77,6 +81,8 @@
<Reference Include="System.Drawing" />
<Reference Include="System.Windows.Forms" />
<Reference Include="System.Xml" />
<Reference Include="UIAutomationClient" />
<Reference Include="UIAutomationTypes" />
</ItemGroup>
<ItemGroup>
<Compile Include="NotepadsManager.cs">
Expand All @@ -97,6 +103,7 @@
<DependentUpon>Resources.resx</DependentUpon>
<DesignTime>True</DesignTime>
</Compile>
<None Include="app.manifest" />
<None Include="ManageNotepadWindows_TemporaryKey.pfx" />
<None Include="packages.config" />
<None Include="Properties\Settings.settings">
Expand Down
5 changes: 4 additions & 1 deletion ManageNotepadWindows/ManageNotepadWindows.csproj.user
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="12.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<PublishUrlHistory />
Expand All @@ -10,4 +10,7 @@
<FallbackCulture>en-US</FallbackCulture>
<VerifyUploadedFiles>false</VerifyUploadedFiles>
</PropertyGroup>
<PropertyGroup>
<EnableSecurityDebugging>false</EnableSecurityDebugging>
</PropertyGroup>
</Project>
Loading
Loading