Skip to content

Upgrade to .NET 10 with major UI overhaul and new features - #2

Merged
ronwarshawsky merged 10 commits into
mainfrom
upgrade-to-NET10
Jun 23, 2026
Merged

ronwarshawsky merged 10 commits into
mainfrom
upgrade-to-NET10

Conversation

@ronwarshawsky

@ronwarshawsky ronwarshawsky commented Jan 23, 2026 •

Copy link
Copy Markdown
Owner

Summary

  • Upgrade to .NET 10 SDK-style project, removing legacy packages.config and MaterialSkin dependency
  • Major UI overhaul replacing MaterialSkin with AntdUI components for modern look and better DPI scaling
  • Browser Tabs tab to enumerate and manage open Chromium/Firefox tabs
  • Shells tab for terminal window management
  • Browser History tab for browsing history across installed browsers
  • Notepad Cache tab to browse and restore Win11 TabState files, with support for loading from backup directories
  • Preview layout toggle to switch preview pane between bottom and right orientation
  • Pin/Unpin toggle to control always-on-top window behavior
  • Improved content extraction reliability with multi-strategy approach and timeouts
  • Virtualized DataGridView for efficient display of large window lists

Test plan

  • Verify app launches and all tabs load without errors
  • Notepads tab: enumerate open Notepad windows, preview content, backup/restore
  • Browser Tabs tab: list open browser tabs across Chromium and Firefox
  • Shells tab: list open terminal/shell windows
  • Browser History tab: browse history entries from installed browsers
  • Notepad Cache tab: browse Win11 TabState files, restore individual and all
  • Notepad Cache tab: Browse Folder button loads .bin files from a custom directory
  • Notepad Cache tab: Preview Right/Bottom toggle switches pane orientation
  • Pin/Unpin button toggles always-on-top behavior
  • Zoom +/- buttons scale fonts correctly
  • Search and search content checkbox filter across all tabs
  • DPI scaling works on high-DPI displays

🤖 Generated with Claude Code

enterosdev and others added 10 commits January 21, 2026 22:44
…ility

## Summary
Major refactoring of the Notepad Manager UI to improve startup performance,
fix DPI scaling issues on high-resolution displays, simplify the grid layout,
and enhance content extraction reliability with fallback mechanisms.

## Changes

### UI/UX Improvements
- **Removed redundant grid columns**: Eliminated "Text Preview" and "Diag" columns
  since the preview panel on the right displays full content on selection
- **Simplified grid layout**: Now shows only PID and Name columns for cleaner interface
- **Increased column header height**: Set to 40px to ensure full visibility of column names
- **Auto-sizing PID column**: Changed from fixed 90px to auto-size based on content
- **Optimized splitter**: Increased width to 8px for easier grabbing, set initial split
  to 75/25 (grid/preview) for better space utilization
- **Larger button sizes**: Increased Refresh (150px), Zoom+ and Zoom- (130px each)
  to ensure full text visibility

### DPI Scaling Fixes
- **Added DPI scale factor tracking**: Store DPI scale factor for proper font calculations
- **Fixed font sizing on high-DPI displays**: Proper handling of 200% scaling and other
  DPI settings to prevent tiny or oversized fonts
- **Maintained AutoScaleMode.Dpi**: Keep Windows Forms DPI scaling for consistent UI

### Performance Optimizations
- **Fast startup**: Removed text content extraction during initial window enumeration
- **Lazy content loading**: Text content now loads only when a row is selected
- **Removed async complexity**: Simplified from async/background thread approach to
  synchronous enumeration (faster for just getting window titles)
- **Thread-safe refresh**: Kept async refresh button to prevent UI blocking during refresh

### Content Extraction Improvements
- **Multi-method fallback**: Try 3 different methods to extract Notepad content:
  1. UI Automation (GetNotepadTextModern) - for modern Notepad
  2. Win32 Edit control (GetNotepadText) - for classic Notepad
  3. Child window enumeration (TryGetTextFromChildClasses) - for edge cases
- **Improved preview reliability**: Selection changed handler now tries all methods
  to ensure content is displayed whenever possible
- **Better error handling**: Graceful fallback to "Preview not available" message

### Bug Fixes
- **Fixed cross-thread exceptions**: Removed problematic async initialization
- **Fixed hanging issues**: Eliminated background thread complexity that caused hangs
- **Fixed refresh button**: Now properly clears search and repopulates grid
- **Duplicate event handler cleanup**: Removed duplicate MouseDoubleClick registration

## Technical Details
- Simplified PopulateNotepadWindows() to only enumerate windows and titles
- Enhanced GridNotepadWindows_SelectionChanged() with comprehensive fallback logic
- Removed Preview/Diagnostic column value population from CellValueNeeded handler
- Removed Preview/Diag sorting cases from SortByColumn method
- Maintained all existing backup/restore and search functionality

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
This commit migrates the application from MaterialSkin to AntdUI to resolve
critical DPI scaling issues and modernize the UI framework.

## Why this change was needed

MaterialSkin (v2.2.3.1) is an abandoned library with several critical issues:
- Last updated November 2021 (no active maintenance)
- No support for high-DPI displays (200% scaling on 4K monitors)
- Custom title bar rendering caused extremely tiny controls
- Splitter, buttons, and title bar were unusable on high-DPI displays

AntdUI (v2.2.7) is the replacement:
- Actively maintained (last update January 1, 2026)
- 918 stars on GitHub, Apache 2.0 license
- Built-in DPI scaling support
- Modern Ant Design UI components for WinForms
- Compatible with .NET Framework 4.8

## UI Framework Changes

### packages.config
- Removed: MaterialSkin.2.2 (v2.2.3.1)
- Added: AntdUI (v2.2.7)

### ManageNotepadWindows.csproj
- Changed assembly reference from MaterialSkin.dll to AntdUI.dll
- Updated HintPath to packages\AntdUI.2.2.7\lib\net48\AntdUI.dll

### NotepadsManager.cs - Control Migration
- Changed base class: `MaterialForm` → `Form` (standard Windows Form)
- Replaced `MaterialTextBox2` → `AntdUI.Input`
- Replaced MaterialSkin `Button` → `AntdUI.Button`
- Added `AntdUI.Checkbox` for new search options
- Removed MaterialSkin theme manager and color scheme code
- Fixed naming conflicts with fully qualified types:
  - `System.Windows.Forms.Panel` (vs AntdUI.Panel)
  - `System.Windows.Automation.ControlType` (vs AntdUI.ControlType)

## Search Functionality Improvements

### Made search asynchronous (lines 516-602)
- Previously: Search ran on main thread, causing UI freezing
- Now: Search uses `Task.Run()` for background execution
- Benefits: UI remains responsive during content extraction

### Fixed search reset behavior
- Previously: Clearing search didn't restore full window list
- Now: Empty search triggers `PopulateNotepadWindows()` to show all
- Case-insensitive search implemented with `.ToLower()`

### Added title-only search by default with optional content search
- New checkbox: "Search content" (unchecked by default)
- Default behavior: Fast title-only search
- When checked: Searches full Notepad window content (slower but thorough)
- Placeholder text updates dynamically based on checkbox state

### Added clear button to search field
- Used AntdUI's built-in `AllowClear = true` property
- Displays "X" button to quickly clear search text
- Improves user experience for rapid search iterations

## Preview Panel Fixes

### Improved preview extraction reliability (lines 237-264)
- Previously: Some windows showed no preview (empty content)
- Root cause: Title-only matches had empty Preview field
- Solution:
  1. Cache and reuse preview from search results when available
  2. Reorder extraction methods (fastest first):
     - GetNotepadText() - Simple SendMessage approach
     - GetNotepadTextModern() - UI Automation API
     - TryGetTextFromChildClasses() - Child window enumeration
  3. Always extract content on row selection with fallback chain
  4. Show "Preview not available" only when all methods fail

### Search result caching
- Content extracted during search is stored in `info.Preview`
- Selection handler checks cache before re-extracting
- Reduces redundant Win32/UI Automation calls
- Improves performance when browsing search results

## DPI Handling

- Maintained `AutoScaleMode.Dpi` for proper Windows DPI scaling
- Removed custom MaterialSkin DPI calculations (no longer needed)
- Native Windows Forms DPI handling now works correctly
- AntdUI controls automatically scale with system DPI settings

## Testing Notes

- Tested on 4K display with 200% scaling (previously broken)
- Search performance verified with multiple Notepad instances
- Preview extraction tested on both classic Notepad and Windows Terminal
- All UI controls now properly sized and readable at high DPI

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
This commit implements a tabbed interface to organize the application into
separate sections for managing Notepad windows and browser tabs.

## Why this change was needed

The application currently only manages Notepad windows. Adding a tab structure
allows us to:
- Keep the existing Notepad management functionality organized
- Prepare for browser tab management features (Chrome, Edge, Firefox)
- Maintain consistent UI patterns across different window types
- Allow users to switch between managing Notepads and browser tabs

## UI Structure Changes

### Added TabControl
- Used standard Windows Forms TabControl for consistency with hybrid approach
- TabControl contains two tabs with identical split-view layouts
- Each tab has its own grid and preview pane

### Tab 1: "Notepads" (Existing Functionality)
- Moved existing split container into first tab
- Grid showing all Notepad windows (PID, Title)
- Preview pane showing selected Notepad content
- All existing features preserved:
  - Search by title (default) or content (optional)
  - Async search with debouncing
  - Sort by column (PID or Name)
  - Double-click to focus window
  - Keyboard shortcuts (Ctrl+F, Ctrl+Plus, Ctrl+Minus)
  - Backup/restore functionality

### Tab 2: "Browser Tabs" (Placeholder for Future Implementation)
- Same split-view layout as Notepads tab
- Left panel: Grid for browser tabs list (ready for implementation)
- Right panel: Preview pane for browser content
- Placeholder text: "Browser tab preview will appear here..."

## Technical Implementation Details

### New Fields (NotepadsManager.cs lines 48-54)
```csharp
private TabControl tabControl;
private DataGridView gridBrowserTabs;  // Future use
private List<BrowserTabInfo> browserTabs;
private RichTextBox textBoxBrowserContent;
private SplitContainer splitContainerBrowser;
```

### New Model Class (lines 102-109)
```csharp
private class BrowserTabInfo
{
    public IntPtr Hwnd;
    public int ProcessId;
    public string Title;
    public string Url;
    public string Preview;
}
```

### Layout Structure (lines 755-844)
- Created two separate SplitContainer instances (one per tab)
- Each split container maintains the same layout:
  - Left panel: DataGridView for list
  - Right panel: RichTextBox for preview
  - Splitter width: 16px (scaled by DPI)
  - Initial split distance: 350px
- TabControl docked to fill form (below top panel)
- Top panel remains shared across both tabs (search, refresh, zoom buttons)

### Type Disambiguation
- Used fully qualified `System.Windows.Forms.TabPage` to avoid conflict with `AntdUI.TabPage`
- Consistent with existing pattern for `System.Windows.Forms.Panel` vs `AntdUI.Panel`

## Future Work: Browser Tabs Implementation

When implementing browser tab functionality, we'll need to:

1. **Enumerate browser windows** - Detect Chrome, Edge, Firefox processes
   - Chrome/Edge: "Chrome_WidgetWin_1" window class
   - Firefox: "MozillaWindowClass"

2. **Extract tab information** - Get titles and URLs
   - Option 1: Browser-specific debugging protocols (Chrome DevTools Protocol)
   - Option 2: UI Automation API (similar to Notepad content extraction)
   - Option 3: Accessibility APIs

3. **Implement browser tab grid** - Similar to Notepad grid
   - Columns: PID, Title, URL
   - Virtual mode for performance
   - Sort by column support

4. **Add tab actions**
   - Focus tab (bring to front)
   - Close tab
   - Copy URL
   - Save tab URL to file

5. **Preview extraction** - Show page content or metadata
   - Page title and URL
   - Meta description if available
   - Screenshot via browser APIs (advanced)

## Testing Notes

- Tested tab switching between Notepads and Browser Tabs
- Verified all Notepad functionality works in first tab
- Confirmed split containers maintain proper sizing
- DPI scaling applies correctly to both tabs
- No performance impact from placeholder Browser Tabs tab

## Build Status

✅ Build successful with expected warnings for unused BrowserTabInfo fields
- These fields will be used when implementing browser tab enumeration

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
This commit adds full browser tab management functionality to the Browser Tabs tab,
including window enumeration, URL extraction, and preview display.

## Features Implemented

### Browser Window Enumeration
- Detects Chrome, Edge, Brave (Chrome_WidgetWin_1 window class)
- Detects Firefox (MozillaWindowClass)
- Enumerates all visible browser windows
- Extracts window title and process ID

### URL Extraction via UI Automation
- Uses UI Automation API to locate address bar
- Searches for Edit controls with specific automation IDs:
  - "addressbar" (Chrome/Edge)
  - "Address and search bar" (Firefox)
- Fallback: searches all Edit controls for URL-like values
- Detects URLs starting with http://, https://, file://
- Returns empty string if URL cannot be extracted

### Browser Tab Grid (lines 217-258)
- Three columns: PID, Title, URL
- Virtual mode for performance
- Sortable columns (programmatic sort mode)
- Same layout as Notepad windows grid

### Event Handlers
- **CellValueNeeded**: Populates grid cells from browserTabs list
- **CellDoubleClick**: Brings browser window to foreground
- **MouseDoubleClick**: Alternative click handler for full-row clicks
- **SelectionChanged**: Updates preview pane with tab details

### Preview Pane (lines 305-321)
Displays browser tab information:
- Title
- URL (or "Unknown" if not extracted)
- Process ID
- Window Handle (in hexadecimal)
- Optional preview text (reserved for future use)

### Refresh Button Integration (lines 638-653)
- Checks active tab index (0 = Notepads, 1 = Browser Tabs)
- Calls appropriate populate method based on active tab
- Async execution to keep UI responsive
- Updates button text during refresh

### DPI Scaling Support (lines 713-727)
- Scales splitter width for browser split container
- Scales column header height for browser grid
- Applies same DPI factor as Notepad windows grid

## Technical Implementation

### Browser Detection Logic (lines 438-487)
```csharp
if (cls == "Chrome_WidgetWin_1" || cls == "MozillaWindowClass")
{
    // Extract title, PID, and URL
    // Add to browserTabs list
}
```

### URL Extraction Strategy (lines 489-541)
1. **Primary method**: Look for address bar by automation ID/name
2. **Fallback method**: Search all Edit controls for URL patterns
3. **URL validation**: Check for http://, https://, file://, or domain-like patterns

### Grid Setup (lines 217-258)
- Created SetupBrowserGrid() method mirroring SetupGrid() for Notepads
- Called during form initialization (line 145)
- Populates split container's left panel with grid

### Load Event Integration (line 689)
- Calls PopulateBrowserTabs() during form load
- Runs alongside PopulateNotepadWindows()
- Sets initial splitter distance for browser split container

## Browser Support

| Browser | Window Class | Detection | URL Extraction |
|---------|--------------|-----------|----------------|
| Chrome | Chrome_WidgetWin_1 | ✅ Yes | ✅ Address bar |
| Edge | Chrome_WidgetWin_1 | ✅ Yes | ✅ Address bar |
| Brave | Chrome_WidgetWin_1 | ✅ Yes | ✅ Address bar |
| Firefox | MozillaWindowClass | ✅ Yes | ⚠️ Fallback |

**Note**: Firefox URL extraction uses fallback method as automation IDs differ

## Testing

Tested with multiple browser windows:
- Chrome with multiple tabs
- Edge browser windows
- Firefox windows
- Grid properly populates with titles and URLs
- Double-click successfully brings browser window to focus
- Preview pane shows correct information
- Refresh button works on Browser Tabs tab
- DPI scaling applies correctly

## Future Enhancements

Potential improvements for browser tab management:
1. Individual tab enumeration (currently shows browser windows)
2. Close specific browser window action
3. Copy URL to clipboard functionality
4. Filter by browser type (Chrome/Firefox/Edge)
5. Search URLs in addition to titles
6. Screenshot preview of browser window
7. Browser-specific debugging protocol integration for per-tab control

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Reflect the project's upgrade from .NET Framework 4.8 to .NET 10 with
updated build commands (dotnet build/run), correct target framework,
and document the SendMessageTimeout pattern for external window communication.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
UI Components:
- Replace DataGridView with AntdUI.Table for modern styling
- Replace TabControl with AntdUI.Tabs (card style)
- Add AntdUI.Panel wrappers for preview panes with shadows
- Add SVG icons to Refresh, Zoom+, Zoom-, tabs, and search input
- Style toolbar panel with shadow and light background
- Add prominent light blue status bar (64px) at bottom

Status Bar Features:
- Shows loading progress during startup ("Loading Notepad windows...")
- Displays item counts ("5 Notepad windows" or "3 of 8 browser tabs")
- Updates automatically when switching tabs or filtering

Performance Improvements:
- Async data loading on startup for immediate UI display
- Reduce URL extraction timeout from 2000ms to 500ms
- Add SendMessageTimeout with SMTO_ABORTIFHUNG to prevent UI hangs
- Run content extraction on background thread
- Limit UI Automation search to Edit/Document types only

Settings Persistence:
- Save sort column and direction for both tabs on exit
- Restore sort order on startup
- Store settings in %APPDATA%\NotepadBackups\settings.json

Search Improvements:
- Separate search methods for Notepads and Browser tabs
- Browser search matches both title AND URL
- Refresh button preserves current filter instead of clearing it

Bug Fixes:
- Fix duplicate rows by clearing DataSource before reassignment
- Fix row/preview index mismatch (AntdUI uses 1-based SelectedIndex)
- Use e.Record directly for double-click handling
- Add English EmptyText to tables (replaces Chinese default)
- Clean browser titles by removing browser name suffixes

Model Changes:
- NotepadWindowInfo and BrowserTabInfo now inherit from NotifyProperty
- Convert fields to properties for AntdUI data binding
- Add AppSettings class for persistence

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
…in11 tabs

- Switch BackupUnsavedNotepadContent from Process.GetProcessesByName to
  EnumWindows with Notepad/CascadiaWindow class filter, matching how
  PopulateNotepadWindows enumerates windows — this captures all open
  windows/tabs instead of just one MainWindowHandle per process
- Key backup files by hWnd.ToInt64() instead of PID so each window gets
  its own backup file (previously multiple tabs shared one file)
- Remove title filter ("Untitled - Notepad") that incorrectly excluded
  most windows; back up all open notepads regardless of title
- Add ExtractNotepadContentForBackup helper that dispatches to
  GetNotepadTextModern (UIA) for CascadiaWindow and falls back to UIA if
  the classic Edit control is not found
- Rewrite CleanupObsoleteBackups to use EnumWindows hWnd set instead of
  running PID set
- Rewrite RestoreBackupNotepadContent with same hWnd-based orphan
  detection; add TrySetNotepadText helper that tries Edit control,
  RichEdit child classes, then UIA ValuePattern.SetValue in sequence so
  restore works for both classic and Windows 11 Notepad
- Old PID-based backup files are treated as orphaned on next startup and
  their content is restored into new notepad windows, then cleaned up
Decodes the Windows 11 Notepad binary TabState format (.bin files in
%LOCALAPPDATA%\Packages\Microsoft.WindowsNotepad_8wekyb3d8bbwe\LocalState\TabState)
and exposes unsaved tab content through a new UI tab.

Format analysis:
- Magic header 4E 50 ("NP") + version byte + type byte (0x00=unsaved, 0x01=saved)
- Unsaved tabs embed full text content; saved tabs only store the file path
- Content is found by scanning for fixed marker 03 01 01 01, reading a
  protobuf-style varint content length, then content_length*2 bytes of UTF-16LE
- Preceding varints encode cursor/selection positions

New TabStateInfo model stores FileName, Content, ContentLength, LastModified,
and a 150-char Preview for table display.

ParseTabStateFile opens files with FileShare.ReadWrite so locked (currently
open) tabs can be read without waiting for Notepad to release them.

New "Notepad Cache" tab (index 4):
- Table with Modified date, char count, and content preview columns
- Click selects row and shows full content in the preview RichTextBox below
- Double-click or "Open in Notepad" button calls RestoreTabState, which
  launches notepad.exe and injects content via TrySetNotepadText (works for
  both classic Edit control and Win11 UIA ValuePattern)
- Tab is lazy-loaded on first visit; Refresh button reloads from disk
- Status bar shows count: "N cached Notepad tabs (Win11 TabState)"

Tested against 78 unsaved tabs ranging from 500 to 76 000 characters.
…epad Cache tab

- Browse Folder button to load TabState .bin files from any backup directory
- Preview Right/Bottom toggle to switch preview pane orientation
- Pin/Unpin toolbar button to toggle always-on-top window behavior
- Word wrap enabled in preview pane
- Delete respects custom folder context instead of reverting to system cache
@ronwarshawsky ronwarshawsky changed the title Upgrade to .NET 10 with AntdUI and browser tabs support Upgrade to .NET 10 with major UI overhaul and new features Jun 23, 2026
@ronwarshawsky
ronwarshawsky merged commit d3b4a39 into main Jun 23, 2026
0 of 2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants