private async void WindowDrop(object sender, DragEventArgs e) { if (!_isDragDrop) { try { Win32.Point curPosition; Win32.GetCursorPos(out curPosition); var imageSources = await ImagePaster.GetImageFromIDataObject(e.Data); if (imageSources.Count <= 0) { return; } imageSources.ForEach(m => ImageItemsSource.Add(new Image { Source = m, })); } catch (Exception ex) { App.Log.Error(ex.ToString()); Extentions.ShowMessageBox("无效的粘贴!"); } } }
private async void WindowDrop(object sender, DragEventArgs e) { try { Win32.GetCursorPos(out _curPosition); var imageSources = await ImagePaster.GetImageFromIDataObject(e.Data); if (imageSources.Count <= 0) { return; } _controlManager.SelectNone(); var translate = new Point(_curPosition.X - SystemParameters.VirtualScreenWidth / 2, _curPosition.Y - SystemParameters.VirtualScreenHeight / 2); var controls = new List <ImageControl>(imageSources.Count); controls.AddRange(imageSources.Select(imageSource => PackageImageToControl(new AnimatedGif { Source = imageSource, Stretch = Stretch.Fill }, translate))); _controlManager.AddElements(controls); } catch (Exception ex) { App.Log.Error(ex.ToString()); Extentions.ShowMessageBox("无效的粘贴!"); } }