Skip to content

Commit c54e7f7

Browse files
committed
refactor: update acrylic controller implementation and version bump
- Changed type of acrylicController from DesktopAcrylicController to IDisposable for better resource management. - Updated ApplyToWindow method to accommodate new controller type and improved backdrop configuration handling. - Bumped application version from 0.1.0 to 0.1.1. - Adjusted target framework in project files and README to .NET 10. - Enhanced installer configuration to reflect changes in file paths and versioning.
1 parent 576e05f commit c54e7f7

9 files changed

Lines changed: 61 additions & 35 deletions

‎AcrylicSettingsWindow.xaml.cs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ public sealed partial class AcrylicSettingsWindow : Window
1313
private bool _suppressChanges = true;
1414
private string _currentKind = "Base";
1515

16-
private DesktopAcrylicController? _acrylicController;
16+
private IDisposable? _acrylicController;
1717
private SystemBackdropConfiguration? _configSource;
1818

1919
private bool _isDragging;

‎AppSettings.cs‎

Lines changed: 48 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -165,21 +165,42 @@ public static void SaveWebDavSettings(string url, string username, string passwo
165165
// ── Apply to any window ─────────────────────────────────────
166166

167167
public static void ApplyToWindow(Window window, BackdropSettings settings,
168-
ref DesktopAcrylicController? controller, ref SystemBackdropConfiguration? configSource)
168+
ref IDisposable? controller, ref SystemBackdropConfiguration? configSource)
169169
{
170170
controller?.Dispose();
171171
controller = null;
172+
configSource = null;
173+
window.SystemBackdrop = null;
172174

173-
if (settings.Type == "acrylic_custom")
175+
if (settings.Type == "none")
176+
return;
177+
178+
controller = CreateBackdropController(settings);
179+
if (controller is null)
180+
return;
181+
182+
configSource = new SystemBackdropConfiguration
174183
{
175-
window.SystemBackdrop = null;
184+
IsInputActive = true,
185+
Theme = SystemBackdropTheme.Default
186+
};
187+
188+
if (window.Content is FrameworkElement fe)
189+
configSource.Theme = (SystemBackdropTheme)fe.ActualTheme;
176190

177-
configSource = new SystemBackdropConfiguration();
178-
configSource.IsInputActive = true;
179-
if (window.Content is FrameworkElement fe)
180-
configSource.Theme = (SystemBackdropTheme)fe.ActualTheme;
191+
ConfigureBackdropController(
192+
controller,
193+
window.As<Microsoft.UI.Composition.ICompositionSupportsSystemBackdrop>(),
194+
configSource);
195+
}
181196

182-
controller = new DesktopAcrylicController
197+
private static IDisposable? CreateBackdropController(BackdropSettings settings)
198+
{
199+
return settings.Type switch
200+
{
201+
"mica" when MicaController.IsSupported() => new MicaController(),
202+
"mica_alt" when MicaController.IsSupported() => new MicaController { Kind = MicaKind.BaseAlt },
203+
"acrylic_custom" when DesktopAcrylicController.IsSupported() => new DesktopAcrylicController
183204
{
184205
TintOpacity = (float)settings.TintOpacity,
185206
LuminosityOpacity = (float)settings.LuminosityOpacity,
@@ -188,22 +209,27 @@ public static void ApplyToWindow(Window window, BackdropSettings settings,
188209
Kind = settings.Kind == "Thin"
189210
? DesktopAcrylicKind.Thin
190211
: DesktopAcrylicKind.Base,
191-
};
212+
},
213+
_ when DesktopAcrylicController.IsSupported() => new DesktopAcrylicController(),
214+
_ => null
215+
};
216+
}
192217

193-
controller.AddSystemBackdropTarget(
194-
window.As<Microsoft.UI.Composition.ICompositionSupportsSystemBackdrop>());
195-
controller.SetSystemBackdropConfiguration(configSource);
196-
}
197-
else
218+
private static void ConfigureBackdropController(
219+
IDisposable controller,
220+
Microsoft.UI.Composition.ICompositionSupportsSystemBackdrop target,
221+
SystemBackdropConfiguration config)
222+
{
223+
switch (controller)
198224
{
199-
configSource = null;
200-
window.SystemBackdrop = settings.Type switch
201-
{
202-
"mica" => new MicaBackdrop(),
203-
"mica_alt" => new MicaBackdrop { Kind = MicaKind.BaseAlt },
204-
"none" => null,
205-
_ => new DesktopAcrylicBackdrop()
206-
};
225+
case MicaController mica:
226+
mica.AddSystemBackdropTarget(target);
227+
mica.SetSystemBackdropConfiguration(config);
228+
break;
229+
case DesktopAcrylicController acrylic:
230+
acrylic.AddSystemBackdropTarget(target);
231+
acrylic.SetSystemBackdropConfiguration(config);
232+
break;
207233
}
208234
}
209235

‎MainWindow.xaml.cs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ public sealed partial class MainWindow : Window
1717
private readonly List<NoteWindow> _openNoteWindows = [];
1818
private ReminderService? _reminderService;
1919

20-
private DesktopAcrylicController? _acrylicController;
20+
private IDisposable? _acrylicController;
2121
private SystemBackdropConfiguration? _configSource;
2222

2323
private TrayIcon? _trayIcon;

‎NoteUI.csproj‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22
<PropertyGroup>
33
<OutputType>WinExe</OutputType>
4-
<TargetFramework>net8.0-windows10.0.19041.0</TargetFramework>
4+
<TargetFramework>net10.0-windows10.0.19041.0</TargetFramework>
55
<TargetPlatformMinVersion>10.0.17763.0</TargetPlatformMinVersion>
66
<RootNamespace>NoteUI</RootNamespace>
77
<ApplicationManifest>app.manifest</ApplicationManifest>

‎NoteWindow.xaml.cs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ public sealed partial class NoteWindow : Window
1818
private bool _isPinnedOnTop;
1919
private bool _suppressTextChanged;
2020

21-
private DesktopAcrylicController? _acrylicController;
21+
private IDisposable? _acrylicController;
2222
private SystemBackdropConfiguration? _configSource;
2323

2424
private bool _isCompact;

‎NotepadWindow.xaml.cs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ public sealed partial class NotepadWindow : Window
1717
private readonly NotesManager _notesManager;
1818
private SnippetManager? _snippetManager;
1919

20-
private DesktopAcrylicController? _acrylicController;
20+
private IDisposable? _acrylicController;
2121
private SystemBackdropConfiguration? _configSource;
2222

2323
private bool _isPinned;

‎README.md‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
# NoteUI
22

3-
A modern sticky notes application for Windows, built with **WinUI 3** (Windows App SDK 1.8) and **.NET 8**.
3+
A modern sticky notes application for Windows, built with **WinUI 3** (Windows App SDK 1.8) and **.NET 10**.
44

5-
![Windows](https://img.shields.io/badge/Windows-10%2F11-blue) ![.NET 8](https://img.shields.io/badge/.NET-8.0-purple) ![WinUI 3](https://img.shields.io/badge/WinUI-3-green)
5+
![Windows](https://img.shields.io/badge/Windows-10%2F11-blue) ![.NET 10](https://img.shields.io/badge/.NET-10.0-purple) ![WinUI 3](https://img.shields.io/badge/WinUI-3-green)
66

77
## Features
88

@@ -113,7 +113,7 @@ Options during installation:
113113
## Build from Source
114114

115115
### Prerequisites
116-
- [.NET 8 SDK](https://dotnet.microsoft.com/download/dotnet/8.0)
116+
- [.NET 10 SDK](https://dotnet.microsoft.com/download/dotnet/10.0)
117117
- [Windows App SDK 1.8](https://learn.microsoft.com/windows/apps/windows-app-sdk/)
118118
- Windows 10 (build 19041) or later
119119

@@ -127,7 +127,7 @@ dotnet build
127127
dotnet publish -c Release -r win-x64 --self-contained true
128128
```
129129

130-
Output: `bin/Release/net8.0-windows10.0.19041.0/win-x64/publish/`
130+
Output: `bin/Release/net10.0-windows10.0.19041.0/win-x64/publish/`
131131

132132
### Create Installer
133133
Requires [Inno Setup 6](https://jrsoftware.org/isinfo.php):
@@ -148,7 +148,7 @@ Output: `installer/NoteUI-Setup.exe`
148148
## Tech Stack
149149

150150
- **Framework**: WinUI 3 / Windows App SDK 1.8
151-
- **Runtime**: .NET 8 (self-contained, win-x64)
151+
- **Runtime**: .NET 10 (self-contained, win-x64)
152152
- **AI (local)**: LLamaSharp 0.26.0 (CPU + CUDA 12)
153153
- **AI (cloud)**: OpenAI, Anthropic Claude, Google Gemini REST APIs
154154
- **Audio**: NAudio 2.2.1

‎VoiceNoteWindow.xaml.cs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ public sealed partial class VoiceNoteWindow : Window
1616
{
1717
private readonly NotesManager _notesManager;
1818

19-
private DesktopAcrylicController? _acrylicController;
19+
private IDisposable? _acrylicController;
2020
private SystemBackdropConfiguration? _configSource;
2121

2222
private bool _isPinnedOnTop;

‎installer.iss‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[Setup]
22
AppId={{B8A3D1E7-4F2C-4B9A-8E6D-1A5C3F7E9D2B}
33
AppName=NoteUI
4-
AppVersion=0.1.0
4+
AppVersion=0.1.1
55
AppPublisher=NoteUI
66
DefaultDirName={localappdata}\Programs\NoteUI
77
DefaultGroupName=NoteUI
@@ -23,7 +23,7 @@ Name: "desktopicon"; Description: "Créer un raccourci sur le bureau"; GroupDesc
2323
Name: "startup"; Description: "Lancer au démarrage de Windows"; GroupDescription: "Options:"
2424

2525
[Files]
26-
Source: "bin\Release\net8.0-windows10.0.19041.0\win-x64\publish\*"; DestDir: "{app}"; Flags: ignoreversion recursesubdirs createallsubdirs; Excludes: "runtimes\linux-*\*"
26+
Source: "bin\Release\net10.0-windows10.0.19041.0\win-x64\publish\*"; DestDir: "{app}"; Flags: ignoreversion recursesubdirs createallsubdirs; Excludes: "runtimes\linux-*\*"
2727

2828
[Icons]
2929
Name: "{group}\NoteUI"; Filename: "{app}\NoteUI.exe"

0 commit comments

Comments
 (0)