Skip to content

Commit

Permalink
Enable dragging from thumbnail to WebUI for PNGInfo
Browse files Browse the repository at this point in the history
  • Loading branch information
RupertAvery committed Dec 4, 2022
1 parent dad88f0 commit efc886e
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
1 change: 1 addition & 0 deletions Diffusion.Toolkit/Pages/Search.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@
Opacity="{Binding Path=ForDeletion, Converter={StaticResource BoolToOpacity}}"
Height="128" Width="128"
MaxWidth="128" MaxHeight="128"
MouseMove="UIElement_OnMouseMove"
HorizontalAlignment="Stretch" VerticalAlignment="Top" />
<Image Height="32" Width="32" Source="../Icons/x-mark-32.png" Visibility="{Binding ForDeletion, Converter={StaticResource boolToVis}}"/>
</Grid>
Expand Down
14 changes: 14 additions & 0 deletions Diffusion.Toolkit/Pages/Search.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
using Image = Diffusion.Database.Image;
using Path = System.IO.Path;
using Diffusion.Toolkit.Classes;
using Diffusion.Toolkit.Controls;

namespace Diffusion.Toolkit.Pages
{
Expand Down Expand Up @@ -706,5 +707,18 @@ public void ShowMarked()
_model.SearchText = "delete: true";
SearchImages(null);
}

private void UIElement_OnMouseMove(object sender, MouseEventArgs e)
{
if (e.LeftButton == MouseButtonState.Pressed)
{
var source = (Thumbnail)sender;
var path = ((ImageEntry)source.DataContext).Path;

DataObject dataObject = new DataObject();
dataObject.SetData(DataFormats.FileDrop, new[] { path });
DragDrop.DoDragDrop(source, dataObject, DragDropEffects.Copy);
}
}
}
}

0 comments on commit efc886e

Please sign in to comment.