|
@@ -3,6 +3,8 @@ using Avalonia;
|
|
using Avalonia.Controls;
|
|
using Avalonia.Controls;
|
|
using Avalonia.Media;
|
|
using Avalonia.Media;
|
|
using PixiEditor.Extensions.Palettes;
|
|
using PixiEditor.Extensions.Palettes;
|
|
|
|
+using PixiEditor.Helpers.Extensions;
|
|
|
|
+using PixiEditor.Models.Containers;
|
|
|
|
|
|
namespace PixiEditor.Models.Commands.Search;
|
|
namespace PixiEditor.Models.Commands.Search;
|
|
|
|
|
|
@@ -17,15 +19,15 @@ internal class ColorSearchResult : SearchResult
|
|
|
|
|
|
public override string Text => text;
|
|
public override string Text => text;
|
|
|
|
|
|
- public override AvaloniaObject Description => new TextBlock(
|
|
|
|
|
|
+ public override AvaloniaObject Description => new TextBlock()
|
|
{
|
|
{
|
|
Text = $"{color} rgba({color.R}, {color.G}, {color.B}, {color.A})",
|
|
Text = $"{color} rgba({color.R}, {color.G}, {color.B}, {color.A})",
|
|
FontSize = 16,
|
|
FontSize = 16,
|
|
- TextDecorations = GetDecoration(new Pen(new SolidColorBrush(color.ToOpaqueMediaColor()), 1))
|
|
|
|
|
|
+ TextDecorations = GetDecoration(1, new SolidColorBrush(color.ToOpaqueMediaColor()))
|
|
};
|
|
};
|
|
|
|
|
|
//public override bool CanExecute => !requiresDocument || (requiresDocument && ViewModelMain.Current.BitmapManager.ActiveDocument != null);
|
|
//public override bool CanExecute => !requiresDocument || (requiresDocument && ViewModelMain.Current.BitmapManager.ActiveDocument != null);
|
|
- public override bool CanExecute => !isPalettePaste || ViewModelMain.Current.DocumentManagerSubViewModel.ActiveDocument != null;
|
|
|
|
|
|
+ public override bool CanExecute => !isPalettePaste || (IDocumentHandler.Instance != null && IDocumentHandler.Instance.HasActiveDocument);
|
|
|
|
|
|
public override IImage Icon => icon;
|
|
public override IImage Icon => icon;
|
|
|
|
|
|
@@ -42,7 +44,7 @@ internal class ColorSearchResult : SearchResult
|
|
this.target = target;
|
|
this.target = target;
|
|
}
|
|
}
|
|
|
|
|
|
- public ColorSearchResult(DrawingApi.Core.ColorsImpl.Color color) : this(color, x => ViewModelMain.Current.ColorsSubViewModel.PrimaryColor = x)
|
|
|
|
|
|
+ public ColorSearchResult(DrawingApi.Core.ColorsImpl.Color color) : this(color, x => IColorsHandler.Instance.PrimaryColor = x)
|
|
{
|
|
{
|
|
text = $"Set color to {color}";
|
|
text = $"Set color to {color}";
|
|
}
|
|
}
|
|
@@ -50,7 +52,7 @@ internal class ColorSearchResult : SearchResult
|
|
public static ColorSearchResult PastePalette(DrawingApi.Core.ColorsImpl.Color color, string searchTerm = null)
|
|
public static ColorSearchResult PastePalette(DrawingApi.Core.ColorsImpl.Color color, string searchTerm = null)
|
|
{
|
|
{
|
|
var result = new ColorSearchResult(color, x =>
|
|
var result = new ColorSearchResult(color, x =>
|
|
- ViewModelMain.Current.DocumentManagerSubViewModel.ActiveDocument!.Palette.Add(new PaletteColor(x.R, x.G, x.B)))
|
|
|
|
|
|
+ IDocumentHandler.Instance.ActiveDocument.Palette.Add(new PaletteColor(x.R, x.G, x.B)))
|
|
{
|
|
{
|
|
SearchTerm = searchTerm,
|
|
SearchTerm = searchTerm,
|
|
isPalettePaste = true
|
|
isPalettePaste = true
|
|
@@ -63,14 +65,22 @@ internal class ColorSearchResult : SearchResult
|
|
|
|
|
|
public static DrawingImage GetIcon(DrawingApi.Core.ColorsImpl.Color color)
|
|
public static DrawingImage GetIcon(DrawingApi.Core.ColorsImpl.Color color)
|
|
{
|
|
{
|
|
- var drawing = new GeometryDrawing() { Brush = new SolidColorBrush(color.ToOpaqueMediaColor()), Pen = new(Brushes.White, 1) };
|
|
|
|
- var geometry = new EllipseGeometry(new(5, 5), 5, 5) { };
|
|
|
|
|
|
+ var drawing = new GeometryDrawing() { Brush = new SolidColorBrush(color.ToOpaqueMediaColor()), Pen = new Pen(Brushes.White, 1) };
|
|
|
|
+ var geometry = new EllipseGeometry(new Rect(5, 5,5, 5));
|
|
drawing.Geometry = geometry;
|
|
drawing.Geometry = geometry;
|
|
return new DrawingImage(drawing);
|
|
return new DrawingImage(drawing);
|
|
}
|
|
}
|
|
|
|
|
|
- private static TextDecorationCollection GetDecoration(Pen pen) => new()
|
|
|
|
|
|
+ private static TextDecorationCollection GetDecoration(double strokeThickness, SolidColorBrush solidColorBrush) => new()
|
|
{
|
|
{
|
|
- new TextDecoration(TextDecorationLocation.Underline, pen, 0, TextDecorationUnit.Pixel, TextDecorationUnit.Pixel)
|
|
|
|
|
|
+ new TextDecoration()
|
|
|
|
+ {
|
|
|
|
+ Location = TextDecorationLocation.Underline,
|
|
|
|
+ StrokeThicknessUnit = TextDecorationUnit.Pixel,
|
|
|
|
+ StrokeOffsetUnit = TextDecorationUnit.Pixel,
|
|
|
|
+ StrokeThickness = strokeThickness,
|
|
|
|
+ Stroke = solidColorBrush,
|
|
|
|
+ StrokeOffset = 0,
|
|
|
|
+ },
|
|
};
|
|
};
|
|
}
|
|
}
|