|
@@ -7,28 +7,43 @@ namespace PixiEditor.Models.Commands.Search;
|
|
internal class FileSearchResult : SearchResult
|
|
internal class FileSearchResult : SearchResult
|
|
{
|
|
{
|
|
private readonly DrawingImage icon;
|
|
private readonly DrawingImage icon;
|
|
|
|
+ private readonly bool asReferenceLayer;
|
|
|
|
|
|
public string FilePath { get; }
|
|
public string FilePath { get; }
|
|
|
|
|
|
- public override string Text => $"...\\{Path.GetFileName(FilePath)}";
|
|
|
|
|
|
+ public override string Text => asReferenceLayer ? $"As reference: ...\\{Path.GetFileName(FilePath)}" : $"...\\{Path.GetFileName(FilePath)}";
|
|
|
|
|
|
public override string Description => FilePath;
|
|
public override string Description => FilePath;
|
|
|
|
|
|
- public override bool CanExecute => true;
|
|
|
|
|
|
+ public override bool CanExecute => !asReferenceLayer ||
|
|
|
|
+ CommandController.Current.Commands["PixiEditor.Layer.PasteReferenceLayerFromPath"].Methods.CanExecute(FilePath);
|
|
|
|
|
|
public override ImageSource Icon => icon;
|
|
public override ImageSource Icon => icon;
|
|
|
|
|
|
- public FileSearchResult(string path)
|
|
|
|
|
|
+ public FileSearchResult(string path, bool asReferenceLayer = false)
|
|
{
|
|
{
|
|
FilePath = path;
|
|
FilePath = path;
|
|
var drawing = new GeometryDrawing() { Brush = FileExtensionToColorConverter.GetBrush(FilePath) };
|
|
var drawing = new GeometryDrawing() { Brush = FileExtensionToColorConverter.GetBrush(FilePath) };
|
|
var geometry = new RectangleGeometry(new(0, 0, 10, 10), 3, 3) { };
|
|
var geometry = new RectangleGeometry(new(0, 0, 10, 10), 3, 3) { };
|
|
drawing.Geometry = geometry;
|
|
drawing.Geometry = geometry;
|
|
icon = new DrawingImage(drawing);
|
|
icon = new DrawingImage(drawing);
|
|
|
|
+ this.asReferenceLayer = asReferenceLayer;
|
|
}
|
|
}
|
|
|
|
|
|
public override void Execute()
|
|
public override void Execute()
|
|
{
|
|
{
|
|
- CommandController.Current.Commands["PixiEditor.File.OpenRecent"].Methods.Execute(FilePath);
|
|
|
|
|
|
+ if (!asReferenceLayer)
|
|
|
|
+ {
|
|
|
|
+ CommandController.Current.Commands["PixiEditor.File.OpenRecent"].Methods.Execute(FilePath);
|
|
|
|
+ }
|
|
|
|
+ else
|
|
|
|
+ {
|
|
|
|
+ var command = CommandController.Current.Commands["PixiEditor.Layer.PasteReferenceLayerFromPath"];
|
|
|
|
+ if (command.Methods.CanExecute(FilePath))
|
|
|
|
+ {
|
|
|
|
+ CommandController.Current.Commands["PixiEditor.Layer.PasteReferenceLayerFromPath"].Methods
|
|
|
|
+ .Execute(FilePath);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
}
|
|
}
|
|
}
|
|
}
|