diff --git a/App.xaml.cs b/App.xaml.cs
index e597ea3..fc4f826 100644
--- a/App.xaml.cs
+++ b/App.xaml.cs
@@ -21,17 +21,27 @@
*
*/
+using LunaDraw.Logic.Utils;
+
namespace LunaDraw;
public partial class App : Application
{
- public App()
- {
- InitializeComponent();
- }
+ public App(IPreferencesFacade preferencesFacade)
+ {
+ InitializeComponent();
+
+ var theme = preferencesFacade.Get(AppPreference.AppTheme);
+ UserAppTheme = theme switch
+ {
+ "Light" => AppTheme.Light,
+ "Dark" => AppTheme.Dark,
+ _ => AppTheme.Unspecified
+ };
+ }
- protected override Window CreateWindow(IActivationState? activationState)
- {
- return new Window(new AppShell());
- }
+ protected override Window CreateWindow(IActivationState? activationState)
+ {
+ return new Window(new AppShell());
+ }
}
\ No newline at end of file
diff --git a/Components/AdvancedSettingsPopup.xaml b/Components/AdvancedSettingsPopup.xaml
new file mode 100644
index 0000000..6765595
--- /dev/null
+++ b/Components/AdvancedSettingsPopup.xaml
@@ -0,0 +1,50 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/Platforms/Windows/TransparentBackdrop.cs.cs b/Components/AdvancedSettingsPopup.xaml.cs
similarity index 67%
rename from Platforms/Windows/TransparentBackdrop.cs.cs
rename to Components/AdvancedSettingsPopup.xaml.cs
index f9c0f91..72bbac5 100644
--- a/Platforms/Windows/TransparentBackdrop.cs.cs
+++ b/Components/AdvancedSettingsPopup.xaml.cs
@@ -21,20 +21,21 @@
*
*/
-using WinComp = Windows.UI.Composition;
+using CommunityToolkit.Maui.Views;
+using LunaDraw.Logic.ViewModels;
-namespace LunaDraw.WinUI;
+namespace LunaDraw.Components;
-///
-/// Transparent or tinted backdrop for .NET 10
-///
-public partial class TransparentBackdrop : CompositionBrushBackdrop
+public partial class AdvancedSettingsPopup : Popup
{
- protected override WinComp.CompositionBrush CreateBrush(WinComp.Compositor compositor)
+ public AdvancedSettingsPopup(MainViewModel viewModel)
{
- // 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();
+ InitializeComponent();
+ BindingContext = viewModel;
}
-}
\ No newline at end of file
+
+ private void OnCloseClicked(object sender, EventArgs e)
+ {
+ this.CloseAsync();
+ }
+}
diff --git a/Components/BrushPreviewControl.cs b/Components/BrushPreviewControl.cs
index 6cfc048..fc02806 100644
--- a/Components/BrushPreviewControl.cs
+++ b/Components/BrushPreviewControl.cs
@@ -138,14 +138,14 @@ protected override void OnPaintSurface(SKPaintSurfaceEventArgs e)
// Draw Glow if enabled
if (IsGlowEnabled)
{
- using var glowPaint = new SKPaint
- {
- Style = SKPaintStyle.StrokeAndFill,
- Color = GlowColor,
- IsAntialias = true,
- MaskFilter = SKMaskFilter.CreateBlur(SKBlurStyle.Normal, GlowRadius)
- };
- canvas.DrawPath(BrushShape.Path, glowPaint);
+ using var glowPaint = new SKPaint
+ {
+ Style = SKPaintStyle.StrokeAndFill,
+ Color = GlowColor,
+ IsAntialias = true,
+ MaskFilter = SKMaskFilter.CreateBlur(SKBlurStyle.Normal, GlowRadius)
+ };
+ canvas.DrawPath(BrushShape.Path, glowPaint);
}
using var paint = new SKPaint
diff --git a/Components/BrushesFlyoutPanel.xaml b/Components/BrushesFlyoutPanel.xaml
index 931c6e0..f2e6acc 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">
-
+
+ HorizontalItemSpacing="10"/>
@@ -43,23 +44,23 @@
Padding="4"
Margin="1">
-
+
+ VerticalOptions="Fill"/>
+ LineBreakMode="TailTruncation"/>
diff --git a/Components/BrushesFlyoutPanel.xaml.cs b/Components/BrushesFlyoutPanel.xaml.cs
index 53923db..7a9e5c6 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();
@@ -37,7 +39,7 @@ private void OnBrushesFlyoutPanelLoaded(object? sender, EventArgs e)
{
if (BindingContext is ToolbarViewModel toolbarViewModel)
{
- // No settings to load here anymore, just brush shapes which are data bound
+ // No settings to load here anymore, just brush shapes which are data bound
}
}
}
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/FlyoutPanel.xaml.cs b/Components/FlyoutPanel.xaml.cs
index b0654f8..024311d 100644
--- a/Components/FlyoutPanel.xaml.cs
+++ b/Components/FlyoutPanel.xaml.cs
@@ -72,7 +72,6 @@ public FlyoutPanel()
AbsoluteLayout.SetLayoutBounds(this, new Rect(-1000, -1000, -1, -1));
}
-
public View FlyoutContent
{
get => (View)GetValue(FlyoutContentProperty);
@@ -236,47 +235,47 @@ private async Task PositionFlyout()
// 1. Try positioning to the right of the target (preferred)
if (flyoutBounds.Right > screenWidth - margin)
{
- // It overflows right. Try positioning to the left of the target.
- double leftX = targetBounds.Left - flyoutBounds.Width - 10;
- if (leftX >= margin)
- {
- finalX = leftX;
- }
- else
+ // It overflows right. Try positioning to the left of the target.
+ double leftX = targetBounds.Left - flyoutBounds.Width - 10;
+ if (leftX >= margin)
+ {
+ finalX = leftX;
+ }
+ else
+ {
+ // Neither side fits perfectly.
+ // Position at the left-most valid position or right-most valid position?
+ // Let's constrain to the screen width.
+ finalX = Math.Max(margin, Math.Min(x, screenWidth - flyoutBounds.Width - margin));
+
+ // If the flyout is wider than the screen (minus margins), constrain width.
+ if (flyoutBounds.Width > screenWidth - 2 * margin)
{
- // Neither side fits perfectly.
- // Position at the left-most valid position or right-most valid position?
- // Let's constrain to the screen width.
- finalX = Math.Max(margin, Math.Min(x, screenWidth - flyoutBounds.Width - margin));
-
- // If the flyout is wider than the screen (minus margins), constrain width.
- if (flyoutBounds.Width > screenWidth - 2 * margin)
- {
- finalX = margin;
- finalWidth = screenWidth - 2 * margin;
- }
+ finalX = margin;
+ finalWidth = screenWidth - 2 * margin;
}
+ }
}
// --- Vertical Positioning Strategy ---
-
+
// If the flyout overflows the bottom edge
if (flyoutBounds.Bottom > screenHeight - margin)
{
- // Try moving it up
- double diff = flyoutBounds.Bottom - (screenHeight - margin);
- double newY = y - diff;
+ // Try moving it up
+ double diff = flyoutBounds.Bottom - (screenHeight - margin);
+ double newY = y - diff;
- if (newY >= margin)
- {
- finalY = newY;
- }
- else
- {
- // Moving up hits the top edge. Constrain Height.
- finalY = margin;
- finalHeight = screenHeight - 2 * margin;
- }
+ if (newY >= margin)
+ {
+ finalY = newY;
+ }
+ else
+ {
+ // Moving up hits the top edge. Constrain Height.
+ finalY = margin;
+ finalHeight = screenHeight - 2 * margin;
+ }
}
// Re-apply the adjusted bounds
diff --git a/Components/LayerControlView.xaml b/Components/LayerControlView.xaml
index da0938b..aaf1a7c 100644
--- a/Components/LayerControlView.xaml
+++ b/Components/LayerControlView.xaml
@@ -4,6 +4,8 @@
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:strings="clr-namespace:LunaDraw.Resources.Strings"
xmlns:toolkit="http://schemas.microsoft.com/dotnet/2022/maui/toolkit"
x:Class="LunaDraw.Components.LayerControlView"
x:DataType="viewModels:MainViewModel"
@@ -21,7 +23,8 @@
Padding="10"
StrokeShape="RoundRectangle 10"
x:Name="LayerControlBorder"
- WidthRequest="{Binding Source={x:Reference Root}, Path=IsLayerPanelExpanded, Converter={StaticResource BoolToLayerPanelWidthConverter}}">
+ IsVisible="{Binding ShowLayersPanel}"
+ WidthRequest="{Binding Source={x:Reference Root}, Path=IsLayerPanelExpanded, Converter={StaticResource BoolToLayerPanelWidthConverter}, x:DataType=components:LayerControlView}">
@@ -31,11 +34,12 @@
-
diff --git a/Components/LayerControlView.xaml.cs b/Components/LayerControlView.xaml.cs
index 22a9a66..79664b6 100644
--- a/Components/LayerControlView.xaml.cs
+++ b/Components/LayerControlView.xaml.cs
@@ -26,65 +26,67 @@
namespace LunaDraw.Components;
- public partial class LayerControlView : ContentView
- {
- public static readonly BindableProperty IsLayerPanelExpandedProperty =
- BindableProperty.Create(nameof(IsLayerPanelExpanded), typeof(bool), typeof(LayerControlView), false, propertyChanged: OnIsLayerPanelExpandedChanged);
+public partial class LayerControlView : ContentView
+{
+ public MainViewModel? ViewModel => BindingContext as MainViewModel;
- public bool IsLayerPanelExpanded
- {
- get => (bool)GetValue(IsLayerPanelExpandedProperty);
- set => SetValue(IsLayerPanelExpandedProperty, value);
- }
+ public static readonly BindableProperty IsLayerPanelExpandedProperty =
+ BindableProperty.Create(nameof(IsLayerPanelExpanded), typeof(bool), typeof(LayerControlView), false, propertyChanged: OnIsLayerPanelExpandedChanged);
- public List MaskingModes { get; } = Enum.GetValues().Cast().ToList();
+ public bool IsLayerPanelExpanded
+ {
+ get => (bool)GetValue(IsLayerPanelExpandedProperty);
+ set => SetValue(IsLayerPanelExpandedProperty, value);
+ }
- public LayerControlView()
- {
- InitializeComponent();
- }
+ public List MaskingModes { get; } = Enum.GetValues().Cast().ToList();
- private static void OnIsLayerPanelExpandedChanged(BindableObject bindable, object oldValue, object newValue)
- {
- var control = (LayerControlView)bindable;
- control.ContentGrid.IsVisible = (bool)newValue;
- control.CollapseButton.Text = (bool)newValue ? "▼" : "▶";
- }
+ public LayerControlView()
+ {
+ InitializeComponent();
+ }
- private void OnCollapseClicked(object sender, EventArgs e)
- {
- IsLayerPanelExpanded = !IsLayerPanelExpanded;
- }
+ private static void OnIsLayerPanelExpandedChanged(BindableObject bindable, object oldValue, object newValue)
+ {
+ var control = (LayerControlView)bindable;
+ control.ContentGrid.IsVisible = (bool)newValue;
+ control.CollapseButton.Text = (bool)newValue ? "▼" : "▶";
+ }
- private void OnDragStarting(object sender, DragStartingEventArgs e)
- {
- if (sender is Element element && element.BindingContext is Layer layer)
- {
- e.Data.Properties["SourceLayer"] = layer;
- // Ensure the dragged layer is selected
- if (this.BindingContext is MainViewModel viewModel)
- {
- viewModel.CurrentLayer = layer;
- }
- }
- }
+ private void OnCollapseClicked(object sender, EventArgs e)
+ {
+ IsLayerPanelExpanded = !IsLayerPanelExpanded;
+ }
- private void OnDragOver(object sender, DragEventArgs e)
+ private void OnDragStarting(object sender, DragStartingEventArgs e)
+ {
+ if (sender is Element element && element.BindingContext is Layer layer)
+ {
+ e.Data.Properties["SourceLayer"] = layer;
+ // Ensure the dragged layer is selected
+ if (this.BindingContext is MainViewModel viewModel)
{
- e.AcceptedOperation = DataPackageOperation.Copy;
+ viewModel.CurrentLayer = layer;
}
+ }
+ }
+
+ private void OnDragOver(object sender, DragEventArgs e)
+ {
+ e.AcceptedOperation = DataPackageOperation.Copy;
+ }
- private void OnDrop(object sender, DropEventArgs e)
+ private void OnDrop(object sender, DropEventArgs e)
+ {
+ if (e.Data.Properties.TryGetValue("SourceLayer", out var sourceObj) && sourceObj is Layer sourceLayer)
+ {
+ if (sender is Element element && element.BindingContext is Layer targetLayer)
{
- if (e.Data.Properties.TryGetValue("SourceLayer", out var sourceObj) && sourceObj is Layer sourceLayer)
- {
- if (sender is Element element && element.BindingContext is Layer targetLayer)
- {
- if (this.BindingContext is MainViewModel viewModel)
- {
- viewModel.ReorderLayer(sourceLayer, targetLayer);
- }
- }
- }
+ if (this.BindingContext is MainViewModel viewModel)
+ {
+ viewModel.ReorderLayer(sourceLayer, targetLayer);
+ }
}
+ }
}
+}
diff --git a/Components/MiniMapView.xaml b/Components/MiniMapView.xaml
index e17521c..825e120 100644
--- a/Components/MiniMapView.xaml
+++ b/Components/MiniMapView.xaml
@@ -3,11 +3,11 @@
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:skiasharp="clr-namespace:SkiaSharp.Views.Maui.Controls;assembly=SkiaSharp.Views.Maui.Controls"
x:Class="LunaDraw.Components.MiniMapView">
-
-
-
+
+
+
diff --git a/Components/MiniMapView.xaml.cs b/Components/MiniMapView.xaml.cs
index 65bb4c6..04e0d1c 100644
--- a/Components/MiniMapView.xaml.cs
+++ b/Components/MiniMapView.xaml.cs
@@ -23,7 +23,9 @@
using System.Reactive.Linq;
+using LunaDraw.Logic.Extensions;
using LunaDraw.Logic.Messages;
+using LunaDraw.Logic.Utils;
using LunaDraw.Logic.ViewModels;
using ReactiveUI;
@@ -36,32 +38,27 @@ namespace LunaDraw.Components;
public partial class MiniMapView : ContentView
{
+ private readonly IMessageBus? messageBus;
+ private readonly IPreferencesFacade? preferencesFacade;
private MainViewModel? viewModel;
private SKMatrix fitMatrix;
private float density = 1.0f;
- private IMessageBus? messageBus;
- private IMessageBus? MessageBus
- {
- get
- {
- if (messageBus != null) return messageBus;
- messageBus = Handler?.MauiContext?.Services.GetService()
- ?? IPlatformApplication.Current?.Services.GetService();
- return messageBus;
- }
- }
-
public MiniMapView()
{
InitializeComponent();
- this.Loaded += (s, e) =>
+ Loaded += (s, e) =>
{
- MessageBus?.Listen()
+ messageBus?.Listen()
.Throttle(TimeSpan.FromMilliseconds(30), RxApp.MainThreadScheduler)
.Subscribe(_ => miniMapCanvas?.InvalidateSurface());
};
+
+ this.messageBus = Handler?.MauiContext?.Services.GetService()
+ ?? IPlatformApplication.Current?.Services.GetService();
+ this.preferencesFacade = Handler?.MauiContext?.Services.GetService()
+ ?? IPlatformApplication.Current?.Services.GetService();
}
protected override void OnBindingContextChanged()
@@ -83,7 +80,8 @@ private void OnPaintSurface(object? sender, SKPaintSurfaceEventArgs e)
density = (float)(info.Width / view.Width);
}
- canvas.Clear(SKColors.White);
+ var bgColor = preferencesFacade?.GetCanvasBackgroundColor() ?? SKColors.White;
+ canvas.Clear(bgColor);
// Calculate bounds of all elements
var contentBounds = SKRect.Empty;
@@ -217,7 +215,7 @@ private void OnTouch(object? sender, SKTouchEventArgs e)
var translation = SKMatrix.CreateTranslation(delta.X, delta.Y);
viewModel.NavigationModel.ViewMatrix = viewModel.NavigationModel.ViewMatrix.PostConcat(translation);
- MessageBus?.SendMessage(new CanvasInvalidateMessage());
+ messageBus?.SendMessage(new CanvasInvalidateMessage());
}
e.Handled = true;
break;
diff --git a/Components/SettingsFlyoutPanel.xaml b/Components/SettingsFlyoutPanel.xaml
index 29fd1f6..87f9a44 100644
--- a/Components/SettingsFlyoutPanel.xaml
+++ b/Components/SettingsFlyoutPanel.xaml
@@ -3,227 +3,227 @@
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:controls="clr-namespace:Maui.ColorPicker;assembly=Maui.ColorPicker"
x:Class="LunaDraw.Components.SettingsFlyoutPanel">
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/Components/SettingsFlyoutPanel.xaml.cs b/Components/SettingsFlyoutPanel.xaml.cs
index a8fc38b..765f3d6 100644
--- a/Components/SettingsFlyoutPanel.xaml.cs
+++ b/Components/SettingsFlyoutPanel.xaml.cs
@@ -79,25 +79,16 @@ public partial class SettingsFlyoutPanel : ContentView
typeof(SettingsFlyoutPanel),
0.25f,
propertyChanged: OnSpacingPropertyChanged);
-
- private bool suppressEvents;
-
private IMessageBus? messageBus;
- private IMessageBus? MessageBus
- {
- get
- {
- if (messageBus != null) return messageBus;
- messageBus = Handler?.MauiContext?.Services.GetService()
- ?? IPlatformApplication.Current?.Services.GetService();
- return messageBus;
- }
- }
+ private bool suppressEvents;
public SettingsFlyoutPanel()
{
InitializeComponent();
- this.Loaded += OnSettingsFlyoutPanelLoaded;
+ Loaded += OnSettingsFlyoutPanelLoaded;
+
+ messageBus = Handler?.MauiContext?.Services.GetService()
+ ?? IPlatformApplication.Current?.Services.GetService();
}
private void OnSettingsFlyoutPanelLoaded(object? sender, EventArgs e)
@@ -163,99 +154,99 @@ public float Spacing
private static void OnStrokeColorPropertyChanged(BindableObject bindable, object oldValue, object newValue)
{
- try
+ try
+ {
+ var panel = (SettingsFlyoutPanel)bindable;
+ if (panel.BindingContext is ToolbarViewModel toolbarViewModel && newValue is SKColor color)
{
- var panel = (SettingsFlyoutPanel)bindable;
- if (panel.BindingContext is ToolbarViewModel toolbarViewModel && newValue is SKColor color)
- {
- if (panel.MessageBus != null)
- panel.MessageBus.SendMessage(new BrushSettingsChangedMessage(strokeColor: color));
- if (panel.StrokeColorPicker != null)
- panel.StrokeColorPicker.PickedColor = SKColorToMauiColor(color);
- }
+ if (panel.messageBus != null)
+ panel.messageBus.SendMessage(new BrushSettingsChangedMessage(strokeColor: color));
+ if (panel.StrokeColorPicker != null)
+ panel.StrokeColorPicker.PickedColor = SKColorToMauiColor(color);
}
- catch { }
+ }
+ catch { }
}
private static void OnFillColorPropertyChanged(BindableObject bindable, object oldValue, object newValue)
{
- try
+ try
+ {
+ var panel = (SettingsFlyoutPanel)bindable;
+ if (panel.BindingContext is ToolbarViewModel toolbarViewModel)
{
- var panel = (SettingsFlyoutPanel)bindable;
- if (panel.BindingContext is ToolbarViewModel toolbarViewModel)
- {
- var fill = newValue as SKColor?;
- if (panel.MessageBus != null)
- panel.MessageBus.SendMessage(new BrushSettingsChangedMessage(fillColor: fill));
- if (newValue is SKColor fillColor && panel.FillColorPicker != null)
- panel.FillColorPicker.PickedColor = SKColorToMauiColor(fillColor);
- }
+ var fill = newValue as SKColor?;
+ if (panel.messageBus != null)
+ panel.messageBus.SendMessage(new BrushSettingsChangedMessage(fillColor: fill));
+ if (newValue is SKColor fillColor && panel.FillColorPicker != null)
+ panel.FillColorPicker.PickedColor = SKColorToMauiColor(fillColor);
}
- catch { }
+ }
+ catch { }
}
private static void OnTransparencyPropertyChanged(BindableObject bindable, object oldValue, object newValue)
{
- try
+ try
+ {
+ var panel = (SettingsFlyoutPanel)bindable;
+ if (panel.BindingContext is ToolbarViewModel toolbarViewModel && newValue is byte transparency)
{
- var panel = (SettingsFlyoutPanel)bindable;
- if (panel.BindingContext is ToolbarViewModel toolbarViewModel && newValue is byte transparency)
- {
- if (panel.MessageBus != null)
- panel.MessageBus.SendMessage(new BrushSettingsChangedMessage(transparency: transparency));
- if (panel.TransparencySlider != null)
- panel.TransparencySlider.Value = transparency;
- }
+ if (panel.messageBus != null)
+ panel.messageBus.SendMessage(new BrushSettingsChangedMessage(transparency: transparency));
+ if (panel.TransparencySlider != null)
+ panel.TransparencySlider.Value = transparency;
}
- catch { }
+ }
+ catch { }
}
private static void OnSizePropertyChanged(BindableObject bindable, object oldValue, object newValue)
{
- try
+ try
+ {
+ var panel = (SettingsFlyoutPanel)bindable;
+ if (panel.BindingContext is ToolbarViewModel && newValue is float size)
{
- var panel = (SettingsFlyoutPanel)bindable;
- if (panel.BindingContext is ToolbarViewModel && newValue is float size)
- {
- if (panel.MessageBus != null)
- panel.MessageBus.SendMessage(new BrushSettingsChangedMessage(strokeWidth: size));
- if (panel.SizeSlider != null)
- panel.SizeSlider.Value = size;
- }
+ if (panel.messageBus != null)
+ panel.messageBus.SendMessage(new BrushSettingsChangedMessage(strokeWidth: size));
+ if (panel.SizeSlider != null)
+ panel.SizeSlider.Value = size;
}
- catch { }
+ }
+ catch { }
}
private static void OnFlowPropertyChanged(BindableObject bindable, object oldValue, object newValue)
{
- try
+ try
+ {
+ var panel = (SettingsFlyoutPanel)bindable;
+ if (panel.BindingContext is ToolbarViewModel && newValue is byte flow)
{
- var panel = (SettingsFlyoutPanel)bindable;
- if (panel.BindingContext is ToolbarViewModel && newValue is byte flow)
- {
- if (panel.MessageBus != null)
- panel.MessageBus.SendMessage(new BrushSettingsChangedMessage(flow: flow));
- if (panel.FlowSlider != null)
- panel.FlowSlider.Value = flow;
- }
+ if (panel.messageBus != null)
+ panel.messageBus.SendMessage(new BrushSettingsChangedMessage(flow: flow));
+ if (panel.FlowSlider != null)
+ panel.FlowSlider.Value = flow;
}
- catch { }
+ }
+ catch { }
}
private static void OnSpacingPropertyChanged(BindableObject bindable, object oldValue, object newValue)
{
- try
+ try
+ {
+ var panel = (SettingsFlyoutPanel)bindable;
+ if (panel.BindingContext is ToolbarViewModel && newValue is float spacing)
{
- var panel = (SettingsFlyoutPanel)bindable;
- if (panel.BindingContext is ToolbarViewModel && newValue is float spacing)
- {
- if (panel.MessageBus != null)
- panel.MessageBus.SendMessage(new BrushSettingsChangedMessage(spacing: spacing));
- if (panel.SpacingSlider != null)
- panel.SpacingSlider.Value = spacing;
- }
+ if (panel.messageBus != null)
+ panel.messageBus.SendMessage(new BrushSettingsChangedMessage(spacing: spacing));
+ if (panel.SpacingSlider != null)
+ panel.SpacingSlider.Value = spacing;
}
- catch { }
+ }
+ catch { }
}
private void OnStrokeColorChanged(object sender, EventArgs e)
@@ -263,7 +254,7 @@ private void OnStrokeColorChanged(object sender, EventArgs e)
if (sender is Maui.ColorPicker.ColorPicker colorPicker)
{
var strokeColor = MauiColorToSKColor(colorPicker.PickedColor);
- MessageBus?.SendMessage(new BrushSettingsChangedMessage(strokeColor: strokeColor));
+ messageBus?.SendMessage(new BrushSettingsChangedMessage(strokeColor: strokeColor));
}
}
@@ -274,32 +265,32 @@ private void OnFillColorChanged(object sender, EventArgs e)
if (sender is Maui.ColorPicker.ColorPicker colorPicker)
{
var fillColor = MauiColorToSKColor(colorPicker.PickedColor);
- MessageBus?.SendMessage(new BrushSettingsChangedMessage(fillColor: fillColor));
+ messageBus?.SendMessage(new BrushSettingsChangedMessage(fillColor: fillColor));
}
}
private void OnTransparencyChanged(object sender, ValueChangedEventArgs e)
{
var transparency = (byte)e.NewValue;
- MessageBus?.SendMessage(new BrushSettingsChangedMessage(transparency: transparency));
+ messageBus?.SendMessage(new BrushSettingsChangedMessage(transparency: transparency));
}
private void OnSizeChanged(object sender, ValueChangedEventArgs e)
{
var size = (float)e.NewValue;
- MessageBus?.SendMessage(new BrushSettingsChangedMessage(strokeWidth: size));
+ messageBus?.SendMessage(new BrushSettingsChangedMessage(strokeWidth: size));
}
private void OnFlowChanged(object sender, ValueChangedEventArgs e)
{
var flow = (byte)e.NewValue;
- MessageBus?.SendMessage(new BrushSettingsChangedMessage(flow: flow));
+ messageBus?.SendMessage(new BrushSettingsChangedMessage(flow: flow));
}
private void OnSpacingChanged(object sender, ValueChangedEventArgs e)
{
var spacing = (float)e.NewValue;
- MessageBus?.SendMessage(new BrushSettingsChangedMessage(spacing: spacing));
+ messageBus?.SendMessage(new BrushSettingsChangedMessage(spacing: spacing));
}
private void OnNoFillClicked(object sender, EventArgs e)
@@ -313,7 +304,7 @@ private void OnNoFillClicked(object sender, EventArgs e)
{
suppressEvents = false;
}
- MessageBus?.SendMessage(new BrushSettingsChangedMessage(shouldClearFillColor: true));
+ messageBus?.SendMessage(new BrushSettingsChangedMessage(shouldClearFillColor: true));
}
private static Color SKColorToMauiColor(SKColor skColor)
@@ -332,12 +323,12 @@ private static SKColor MauiColorToSKColor(Color mauiColor)
private void OnGlowSwitchToggled(object sender, ToggledEventArgs e)
{
- MessageBus?.SendMessage(new BrushSettingsChangedMessage(isGlowEnabled: e.Value));
+ messageBus?.SendMessage(new BrushSettingsChangedMessage(isGlowEnabled: e.Value));
}
private void OnGlowRadiusChanged(object sender, ValueChangedEventArgs e)
{
- MessageBus?.SendMessage(new BrushSettingsChangedMessage(glowRadius: (float)e.NewValue));
+ messageBus?.SendMessage(new BrushSettingsChangedMessage(glowRadius: (float)e.NewValue));
}
private void OnGlowColorTapped(object sender, TappedEventArgs e)
@@ -346,33 +337,33 @@ private void OnGlowColorTapped(object sender, TappedEventArgs e)
{
if (SKColor.TryParse(hexColor, out var color))
{
- MessageBus?.SendMessage(new BrushSettingsChangedMessage(glowColor: color));
+ messageBus?.SendMessage(new BrushSettingsChangedMessage(glowColor: color));
}
}
}
private void OnRainbowSwitchToggled(object sender, ToggledEventArgs e)
{
- MessageBus?.SendMessage(new BrushSettingsChangedMessage(isRainbowEnabled: e.Value));
+ messageBus?.SendMessage(new BrushSettingsChangedMessage(isRainbowEnabled: e.Value));
}
private void OnScatterChanged(object sender, ValueChangedEventArgs e)
{
- MessageBus?.SendMessage(new BrushSettingsChangedMessage(scatterRadius: (float)e.NewValue));
+ messageBus?.SendMessage(new BrushSettingsChangedMessage(scatterRadius: (float)e.NewValue));
}
private void OnSizeJitterChanged(object sender, ValueChangedEventArgs e)
{
- MessageBus?.SendMessage(new BrushSettingsChangedMessage(sizeJitter: (float)e.NewValue));
+ messageBus?.SendMessage(new BrushSettingsChangedMessage(sizeJitter: (float)e.NewValue));
}
private void OnAngleJitterChanged(object sender, ValueChangedEventArgs e)
{
- MessageBus?.SendMessage(new BrushSettingsChangedMessage(angleJitter: (float)e.NewValue));
+ messageBus?.SendMessage(new BrushSettingsChangedMessage(angleJitter: (float)e.NewValue));
}
private void OnHueJitterChanged(object sender, ValueChangedEventArgs e)
{
- MessageBus?.SendMessage(new BrushSettingsChangedMessage(hueJitter: (float)e.NewValue));
+ messageBus?.SendMessage(new BrushSettingsChangedMessage(hueJitter: (float)e.NewValue));
}
}
diff --git a/Components/ShapesFlyoutPanel.xaml b/Components/ShapesFlyoutPanel.xaml
index debb153..8dc494a 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">
-
-
-
-
+
+
+
+