mirror of
https://github.com/Flow-Launcher/Flow.Launcher.git
synced 2026-03-11 08:54:32 +00:00
Add Drag Test Code
This commit is contained in:
parent
05044ae00d
commit
19001a459e
2 changed files with 54 additions and 3 deletions
|
|
@ -264,7 +264,9 @@
|
|||
<flowlauncher:ResultListBox
|
||||
x:Name="ResultListBox"
|
||||
DataContext="{Binding Results}"
|
||||
PreviewMouseDown="OnPreviewMouseButtonDown" />
|
||||
MouseMove="FileView_MouseMove"
|
||||
PreviewMouseLeftButtonDown="FileView_PreviewMouseLeftButtonDown"
|
||||
PreviewMouseLeftButtonUp="OnPreviewMouseButtonDown" />
|
||||
</ContentControl>
|
||||
</Border>
|
||||
<Border Style="{DynamicResource WindowRadius}">
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
using System;
|
||||
using System;
|
||||
using System.ComponentModel;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows;
|
||||
|
|
@ -20,6 +20,9 @@ using Flow.Launcher.Infrastructure;
|
|||
using System.Windows.Media;
|
||||
using Flow.Launcher.Infrastructure.Hotkey;
|
||||
using Flow.Launcher.Plugin.SharedCommands;
|
||||
using System.Text;
|
||||
using DataObject = System.Windows.DataObject;
|
||||
using System.Diagnostics;
|
||||
|
||||
namespace Flow.Launcher
|
||||
{
|
||||
|
|
@ -383,6 +386,52 @@ namespace Flow.Launcher
|
|||
e.Handled = true;
|
||||
}
|
||||
|
||||
private Point start;
|
||||
|
||||
private void FileView_PreviewMouseLeftButtonDown(object sender, MouseButtonEventArgs e)
|
||||
{
|
||||
this.start = e.GetPosition(null);
|
||||
}
|
||||
|
||||
private void FileView_MouseMove(object sender, System.Windows.Input.MouseEventArgs e)
|
||||
{
|
||||
Point mpos = e.GetPosition(null);
|
||||
Vector diff = this.start - mpos;
|
||||
|
||||
if (e.LeftButton == MouseButtonState.Pressed &&
|
||||
Math.Abs(diff.X) > SystemParameters.MinimumHorizontalDragDistance &&
|
||||
Math.Abs(diff.Y) > SystemParameters.MinimumVerticalDragDistance)
|
||||
{
|
||||
|
||||
if (this.ResultListBox.SelectedItems.Count == 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
var r = (ResultListBox)sender;
|
||||
var d = (DependencyObject)e.OriginalSource;
|
||||
var item = ItemsControl.ContainerFromElement(r, d) as ListBoxItem;
|
||||
var result = (ResultViewModel)item?.DataContext;
|
||||
Console.WriteLine("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa");
|
||||
Console.WriteLine("result");
|
||||
|
||||
// right about here you get the file urls of the selected items.
|
||||
// should be quite easy, if not, ask.
|
||||
//string[] files = "asdf.txt";
|
||||
|
||||
string path = @"D:\test.png";
|
||||
string[] files = { path };
|
||||
var data = new DataObject(System.Windows.DataFormats.FileDrop, files);
|
||||
data.SetData(System.Windows.DataFormats.Text, files[0]);
|
||||
DragDrop.DoDragDrop(this, data, System.Windows.DragDropEffects.Copy);
|
||||
e.Handled = true;
|
||||
// string dataFormat = System.Windows.DataFormats.FileDrop;
|
||||
//System.Windows.DataObject dataObject = new System.Windows.DataObject(dataFormat, files);
|
||||
//DragDrop.DoDragDrop(this.ResultListBox, dataObject, System.Windows.DragDropEffects.Copy);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private async void OnContextMenusForSettingsClick(object sender, RoutedEventArgs e)
|
||||
{
|
||||
_viewModel.Hide();
|
||||
|
|
@ -556,4 +605,4 @@ namespace Flow.Launcher
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue