Skip to content

DarkMode (c) Fix TitleBar issues #13468

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
92e2dcc
[main] Source code updates from dotnet/dotnet (#13469)
dotnet-maestro[bot] May 17, 2025
716bc12
[main] Source code updates from dotnet/dotnet (#13476)
dotnet-maestro[bot] May 18, 2025
4c32f29
Allow IDataObjectAsyncCapability (#13431)
JeremyKuhne May 19, 2025
ef25062
Publish unpublished APIs
LeafShi1 May 20, 2025
ee29cfd
Publish unpublished APIs (#13479)
LeafShi1 May 20, 2025
4372c9c
Fix thread safety in Application.ThreadContext.FromId (#13489)
Copilot May 20, 2025
8484b55
[main] Source code updates from dotnet/dotnet (#13493)
dotnet-maestro[bot] May 21, 2025
bceb900
Fix order for applying darkmode theming.
KlausLoeffelmann May 21, 2025
f8e01f9
Fix DarkMode StatusStrip background renderer.
KlausLoeffelmann Apr 9, 2025
6f52f33
Implement ToolStripSystemDarkModeRenderer.
KlausLoeffelmann Apr 24, 2025
d2c906d
Update ToolStripManager.
KlausLoeffelmann Apr 29, 2025
c2f452c
Fix bug where a dedicated Toolstrip Renderer would not be called for …
KlausLoeffelmann Apr 30, 2025
42b324c
Fix the StatusStripSizingGrip.
KlausLoeffelmann May 6, 2025
d3ae9f4
Undo Experimental tagging of Form-APIs..
KlausLoeffelmann May 7, 2025
127dbfd
Cleanup, refactor and optimize sharing renderer code.
KlausLoeffelmann May 7, 2025
9279c50
Fix a few rendering issues.
KlausLoeffelmann May 8, 2025
18e6270
Change Grip renderer to use predefined shape.
KlausLoeffelmann May 8, 2025
2df91d0
Fix subtle bug in the SystemRenderer base class, and...
KlausLoeffelmann May 8, 2025
d14e339
First batch of addressed review suggestions.
KlausLoeffelmann May 11, 2025
26db072
Update SystemRenderer mode.
KlausLoeffelmann May 12, 2025
192f8f1
Add GDI-Plus general optimization Co-Pilot instructions.
KlausLoeffelmann May 20, 2025
d9d5d89
Update CreateRenderer methods to use expression-bodied syntax
Copilot May 20, 2025
0e4ae78
Update XML documentation indentation in ToolStripSystemRenderer.cs
Copilot May 20, 2025
8fcce92
Update ternary formatting and remove unnecessary parentheses
Copilot May 20, 2025
b33b12d
Update ShouldPaintBackground to use null-conditional operator in expr…
Copilot May 20, 2025
20e5a99
Invert boolean expression in ToolStripSystemRenderer.cs
Copilot May 20, 2025
56a437d
Format pass over the worst issues in ToolStrip and StatusStrip.
KlausLoeffelmann May 21, 2025
b8f1950
First version of Prompt for DarkModeRenderer and class scaffolding.
KlausLoeffelmann May 1, 2025
12e81a9
Update ButtonDarkModeRenderer.
KlausLoeffelmann May 2, 2025
d06adfa
Prepare ButtonBase for DarkMode rendering.
KlausLoeffelmann May 2, 2025
b48b580
Implement ButtonDarkModeAdapter.
KlausLoeffelmann May 2, 2025
e3f2c4e
Introduce dedicated handlers for the different FlatStyles.
KlausLoeffelmann May 13, 2025
c977498
Refactor PopupButtonDarkModeRenderer
KlausLoeffelmann May 13, 2025
039cd4e
Introduce AI-Prompt for refactoring Pens and Brushes to caching.
KlausLoeffelmann May 13, 2025
3f7e816
Update rendering approaches.
KlausLoeffelmann May 13, 2025
c505a15
Fix bug where other buttons would fail due to wrong adapter request.
KlausLoeffelmann May 16, 2025
3d5c2a1
Limit the DarkModeAdapter to Button-derived classes.
KlausLoeffelmann May 21, 2025
0537d92
Introduce AI-Prompt for refactoring Pens and Brushes to caching.
KlausLoeffelmann May 13, 2025
e0697dc
Apply title coloring attributes to TopLevelWindow after handle recrea…
KlausLoeffelmann May 5, 2025
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
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
# C# Refactor: Pen & Brush to Cached Scope API

You are an expert C# code transformer.

**Goal:** Rewrite every creation and usage of `Pen` and `SolidBrush` in the input file to use our `RefCountedCache` (or `PenCache`/`SolidBrushCache`) scoped API instead of direct `new` calls or helper methods returning non-cached objects.

---

## Transformation Rules

1. **Direct Instantiations**
- **Pens**
- Replace `new Pen(color)` with:
```csharp
using var pen = color.GetCachedPenScope();
```
- Replace `new Pen(color, width)` with:
```csharp
using var pen = color.GetCachedPenScope(width);
```
- Preserve original variable names, e.g.:
```csharp
using var borderPen = color.GetCachedPenScope();
```

- **SolidBrushes**
- Replace `new SolidBrush(color)` with:
```csharp
using var brush = color.GetCachedSolidBrushScope();
```
- Preserve original variable names.

2. **Helper Methods**
- **Detection:**
- Identify any methods in the class that return `Pen` or `SolidBrush`.
- If a helper returns a raw `Pen` or `SolidBrush`, transform it to return the corresponding cache‐scope type (`PenCache.Scope` or `SolidBrushCache.Scope`).

- **Private Helpers:**
- Change the return type to the scope type.
- Update the method body to call the cache API directly (e.g., `color.GetCachedPenScope()`).

- **Public/Internal Helpers:**
- If the helper is externally visible, create a new class‐scoped helper method (e.g., `GetDarkModePenScope`) returning `PenCache.Scope` or `SolidBrushCache.Scope`, based on the original logic, and leave the original helper untouched.

3. **Usages in Drawing Calls**
- All `g.Draw...` or `g.Fill...` invocations that previously took a `Pen` or `Brush` should work unchanged with the new scoped objects via the implicit converter.

4. **Preserve Formatting & Logic**
- Do not alter any logic that is unrelated to Pen/Brush instantiation.
- Maintain existing code style and formatting.

---

## Example

**Before:**
```csharp
using (var p = new Pen(Color.Red, 2))
{
g.DrawEllipse(p, bounds);
}

private Pen GetCustomBorderPen(Color color)
{
return new Pen(color);
}
```

**After:**
```csharp
using var p = Color.Red.GetCachedPenScope(2);
g.DrawEllipse(p, bounds);

private PenCache.Scope GetCustomBorderPenScope(Color color)
=> color.GetCachedPenScope();
```

---

**Task:** Rewrite the entire input file accordingly and output the modified code.
Loading