From f8976ee40bbe09da0b54bb7893bb24359ff54f2d Mon Sep 17 00:00:00 2001 From: Jeff H Date: Sun, 14 Dec 2025 15:33:29 -0500 Subject: [PATCH 1/9] trace mode clean-up. --- Components/BrushesFlyoutPanel.xaml | 15 +++-- Components/BrushesFlyoutPanel.xaml.cs | 2 + Components/FlyoutPanel.xaml | 3 +- Components/LayerControlView.xaml | 55 +++++++++------ Components/LayerControlView.xaml.cs | 2 + Components/ShapesFlyoutPanel.xaml | 4 +- Logic/ViewModels/LayerPanelViewModel.cs | 20 ++++-- LunaDraw.csproj | 1 + MauiProgram.cs | 4 +- Pages/MainPage.xaml | 12 ++-- Platforms/Windows/CompositionBrush.cs.cs | 67 ------------------- ...PlatformHelper.cs.cs => PlatformHelper.cs} | 0 Platforms/Windows/TransparentBackdrop.cs.cs | 40 ----------- 13 files changed, 78 insertions(+), 147 deletions(-) delete mode 100644 Platforms/Windows/CompositionBrush.cs.cs rename Platforms/Windows/{PlatformHelper.cs.cs => PlatformHelper.cs} (100%) delete mode 100644 Platforms/Windows/TransparentBackdrop.cs.cs diff --git a/Components/BrushesFlyoutPanel.xaml b/Components/BrushesFlyoutPanel.xaml index 931c6e0..a6a4ec2 100644 --- a/Components/BrushesFlyoutPanel.xaml +++ b/Components/BrushesFlyoutPanel.xaml @@ -5,7 +5,8 @@ xmlns:models="clr-namespace:LunaDraw.Logic.Models" xmlns:components="clr-namespace:LunaDraw.Components" x:Class="LunaDraw.Components.BrushesFlyoutPanel" - x:DataType="viewModels:ToolbarViewModel"> + x:DataType="viewModels:ToolbarViewModel" + x:Name="Root"> - diff --git a/Components/BrushesFlyoutPanel.xaml.cs b/Components/BrushesFlyoutPanel.xaml.cs index 53923db..b520b08 100644 --- a/Components/BrushesFlyoutPanel.xaml.cs +++ b/Components/BrushesFlyoutPanel.xaml.cs @@ -27,6 +27,8 @@ namespace LunaDraw.Components; public partial class BrushesFlyoutPanel : ContentView { + public ToolbarViewModel? ViewModel => BindingContext as ToolbarViewModel; + public BrushesFlyoutPanel() { InitializeComponent(); diff --git a/Components/FlyoutPanel.xaml b/Components/FlyoutPanel.xaml index 272cf77..244fcca 100644 --- a/Components/FlyoutPanel.xaml +++ b/Components/FlyoutPanel.xaml @@ -1,11 +1,12 @@ - + \ No newline at end of file diff --git a/Components/LayerControlView.xaml b/Components/LayerControlView.xaml index da0938b..ea8afca 100644 --- a/Components/LayerControlView.xaml +++ b/Components/LayerControlView.xaml @@ -4,6 +4,7 @@ xmlns:viewModels="clr-namespace:LunaDraw.Logic.ViewModels" xmlns:models="clr-namespace:LunaDraw.Logic.Models" xmlns:converters="clr-namespace:LunaDraw.Converters" + xmlns:components="clr-namespace:LunaDraw.Components" xmlns:toolkit="http://schemas.microsoft.com/dotnet/2022/maui/toolkit" x:Class="LunaDraw.Components.LayerControlView" x:DataType="viewModels:MainViewModel" @@ -21,7 +22,7 @@ Padding="10" StrokeShape="RoundRectangle 10" x:Name="LayerControlBorder" - WidthRequest="{Binding Source={x:Reference Root}, Path=IsLayerPanelExpanded, Converter={StaticResource BoolToLayerPanelWidthConverter}}"> + WidthRequest="{Binding Source={x:Reference Root}, Path=IsLayerPanelExpanded, Converter={StaticResource BoolToLayerPanelWidthConverter}, x:DataType=components:LayerControlView}"> @@ -105,7 +106,7 @@ + - - - - - - diff --git a/Components/LayerControlView.xaml.cs b/Components/LayerControlView.xaml.cs index 22a9a66..77ad4b3 100644 --- a/Components/LayerControlView.xaml.cs +++ b/Components/LayerControlView.xaml.cs @@ -28,6 +28,8 @@ namespace LunaDraw.Components; public partial class LayerControlView : ContentView { + public MainViewModel? ViewModel => BindingContext as MainViewModel; + public static readonly BindableProperty IsLayerPanelExpandedProperty = BindableProperty.Create(nameof(IsLayerPanelExpanded), typeof(bool), typeof(LayerControlView), false, propertyChanged: OnIsLayerPanelExpandedChanged); diff --git a/Components/ShapesFlyoutPanel.xaml b/Components/ShapesFlyoutPanel.xaml index debb153..eabfa84 100644 --- a/Components/ShapesFlyoutPanel.xaml +++ b/Components/ShapesFlyoutPanel.xaml @@ -2,7 +2,9 @@ + xmlns:viewModels="clr-namespace:LunaDraw.Logic.ViewModels" + x:Class="LunaDraw.Components.ShapesFlyoutPanel" + x:DataType="viewModels:ToolbarViewModel"> + { + if (IsTransparentBackground) + { + WindowTransparency = 255; + } + else + { + WindowTransparency = 150; + } + }, outputScheduler: RxApp.MainThreadScheduler); + // Initialize state from Preferences IsTransparentBackground = preferencesService.Get("IsTransparentBackgroundEnabled", false); if (!IsTransparentBackground) @@ -175,15 +187,15 @@ private void UpdateWindowTransparency() { LunaDraw.PlatformHelper.EnableTrueTransparency(255); } -#endif + #endif } - public static bool IsTransparentBackgroundVisible => Config.FeatureFlags.EnableTransparentBackground; + public bool IsTransparentBackgroundVisible => Config.FeatureFlags.EnableTransparentBackground; - public ReactiveCommand AddLayerCommand { get; } - public ReactiveCommand RemoveLayerCommand { get; } + public ReactiveCommand AddLayerCommand { get; } public ReactiveCommand RemoveLayerCommand { get; } public ReactiveCommand MoveLayerForwardCommand { get; } public ReactiveCommand MoveLayerBackwardCommand { get; } public ReactiveCommand ToggleLayerVisibilityCommand { get; } public ReactiveCommand ToggleLayerLockCommand { get; } + public ReactiveCommand ToggleTraceModeCommand { get; } } diff --git a/LunaDraw.csproj b/LunaDraw.csproj index e622d49..2c509b4 100644 --- a/LunaDraw.csproj +++ b/LunaDraw.csproj @@ -42,6 +42,7 @@ 10.0.17763.0 6.5 $(DefaultItemExcludes);Tests\** + true diff --git a/MauiProgram.cs b/MauiProgram.cs index e84f7dc..6b7f18a 100644 --- a/MauiProgram.cs +++ b/MauiProgram.cs @@ -67,8 +67,8 @@ public static MauiApp CreateMauiApp() { wndLifeCycleBuilder.OnWindowCreated(window => { - window.SystemBackdrop = new WinUI.TransparentBackdrop(); - if (Microsoft.Maui.Storage.Preferences.Get("IsTransparentBackgroundEnabled", false)) + window.SystemBackdrop = new DesktopAcrylicBackdrop(); + if (Preferences.Get("IsTransparentBackgroundEnabled", false)) { PlatformHelper.EnableTrueTransparency(180); // Fully transparent } diff --git a/Pages/MainPage.xaml b/Pages/MainPage.xaml index 7832a39..a36039a 100644 --- a/Pages/MainPage.xaml +++ b/Pages/MainPage.xaml @@ -35,29 +35,29 @@ + BindingContext="{Binding ToolbarViewModel}"/> + BindingContext="{Binding ToolbarViewModel}"/> + BindingContext="{Binding ToolbarViewModel}"/> diff --git a/Platforms/Windows/CompositionBrush.cs.cs b/Platforms/Windows/CompositionBrush.cs.cs deleted file mode 100644 index 8cf226f..0000000 --- a/Platforms/Windows/CompositionBrush.cs.cs +++ /dev/null @@ -1,67 +0,0 @@ -/* - * Copyright (c) 2025 CodeSoupCafe LLC - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - * - */ - -using Microsoft.UI.Xaml; -using Microsoft.UI.Xaml.Media; - -// Alias namespaces to avoid ambiguity and ensure correct types are used -using WinComp = Windows.UI.Composition; -using WinUIComp = Microsoft.UI.Composition; - -namespace LunaDraw.WinUI; - -public abstract class CompositionBrushBackdrop : SystemBackdrop -{ - private WinComp.CompositionBrush? brush; - private WinComp.Compositor? compositor; - - protected abstract WinComp.CompositionBrush CreateBrush(WinComp.Compositor compositor); - - protected override void OnTargetConnected(WinUIComp.ICompositionSupportsSystemBackdrop connectedTarget, XamlRoot xamlRoot) - { - base.OnTargetConnected(connectedTarget, xamlRoot); - - compositor = new WinComp.Compositor(); - - brush = CreateBrush(compositor); - - connectedTarget.SystemBackdrop = brush; - } - - protected override void OnTargetDisconnected(WinUIComp.ICompositionSupportsSystemBackdrop disconnectedTarget) - { - base.OnTargetDisconnected(disconnectedTarget); - - if (brush != null) - { - brush.Dispose(); - brush = null; - } - - if (compositor != null) - { - compositor.Dispose(); - compositor = null; - } - } -} diff --git a/Platforms/Windows/PlatformHelper.cs.cs b/Platforms/Windows/PlatformHelper.cs similarity index 100% rename from Platforms/Windows/PlatformHelper.cs.cs rename to Platforms/Windows/PlatformHelper.cs diff --git a/Platforms/Windows/TransparentBackdrop.cs.cs b/Platforms/Windows/TransparentBackdrop.cs.cs deleted file mode 100644 index f9c0f91..0000000 --- a/Platforms/Windows/TransparentBackdrop.cs.cs +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Copyright (c) 2025 CodeSoupCafe LLC - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - * - */ - -using WinComp = Windows.UI.Composition; - -namespace LunaDraw.WinUI; - -/// -/// Transparent or tinted backdrop for .NET 10 -/// -public partial class TransparentBackdrop : CompositionBrushBackdrop -{ - protected override WinComp.CompositionBrush CreateBrush(WinComp.Compositor compositor) - { - // Use HostBackdropBrush to sample the area behind the window. - // This allows the user to see through the window (typically with blur). - // The TintColor property is unused here; apply tint via XAML. - return compositor.CreateHostBackdropBrush(); - } -} \ No newline at end of file From be1862c5c8fd192897600f9327d5560c63eb6f4d Mon Sep 17 00:00:00 2001 From: Jeff H Date: Sun, 14 Dec 2025 17:32:02 -0500 Subject: [PATCH 2/9] advanced settings modal --- Components/AdvancedSettingsPopup.xaml | 37 +++ Components/AdvancedSettingsPopup.xaml.cs | 18 ++ Components/FlyoutPanel.xaml.cs | 65 +++-- Components/LayerControlView.xaml | 143 ++++++----- Components/ToolbarView.xaml | 71 ++++-- Logic/Messages/ShowAdvancedSettingsMessage.cs | 5 + Logic/Messages/ViewOptionsChangedMessage.cs | 13 + Logic/ViewModels/MainViewModel.cs | 40 +++ Logic/ViewModels/ToolbarViewModel.cs | 19 ++ README.md | 7 +- Resources/Strings/AppResources.Designer.cs | 237 ++++++++++++++++++ Resources/Strings/AppResources.resx | 148 +++++++++++ Resources/Styles/Styles.xaml | 1 - 13 files changed, 691 insertions(+), 113 deletions(-) create mode 100644 Components/AdvancedSettingsPopup.xaml create mode 100644 Components/AdvancedSettingsPopup.xaml.cs create mode 100644 Logic/Messages/ShowAdvancedSettingsMessage.cs create mode 100644 Logic/Messages/ViewOptionsChangedMessage.cs create mode 100644 Resources/Strings/AppResources.Designer.cs create mode 100644 Resources/Strings/AppResources.resx diff --git a/Components/AdvancedSettingsPopup.xaml b/Components/AdvancedSettingsPopup.xaml new file mode 100644 index 0000000..88d6b84 --- /dev/null +++ b/Components/AdvancedSettingsPopup.xaml @@ -0,0 +1,37 @@ + + + + + + + - + + + + + + + diff --git a/Components/ToolbarView.xaml b/Components/ToolbarView.xaml index 01c832b..08cba44 100644 --- a/Components/ToolbarView.xaml +++ b/Components/ToolbarView.xaml @@ -7,6 +7,7 @@ xmlns:toolkit="http://schemas.microsoft.com/dotnet/2022/maui/toolkit" xmlns:controls="clr-namespace:Maui.ColorPicker;assembly=Maui.ColorPicker" xmlns:local="clr-namespace:LunaDraw.Components" + xmlns:strings="clr-namespace:LunaDraw.Resources.Strings" xmlns:pages="clr-namespace:LunaDraw.Pages;assembly=LunaDraw" x:Class="LunaDraw.Views.ToolbarView" x:DataType="viewModels:ToolbarViewModel"> @@ -65,20 +66,24 @@