private void OnDraggedFiles(DraggedFilesEventArgs draggedFilesEventArgs) { var items = new List <Item>(); Random rnd = new Random(); foreach (string file in draggedFilesEventArgs.Files) { FileInfo fileInfo = new FileInfo(file); if (fileInfo.Attributes != FileAttributes.Directory && fileInfo.Exists) { items.Add( new Item() { CategoryId = draggedFilesEventArgs.CategoryId, Format = fileInfo.Extension, Id = Guid.NewGuid().ToString(), Name = fileInfo.Name, Path = fileInfo.DirectoryName, Size = fileInfo.Length / 1024 / 1024 + "", Type = fileInfo.Attributes.HasFlag(FileAttributes.Directory) ? ItemType.Folder : ItemType.File, CreatedDate = DateTime.Now, UpdatedDate = DateTime.Now } );;; } } Logger.LogDebug(this, $"Dragged {items.Count} Items in Category : {draggedFilesEventArgs.CategoryId}"); _service.AddItems(items); _eventAggregator.GetEvent <CategorySelectedEvent>().Publish(draggedFilesEventArgs.CategoryId); ReloadCategories(); }
private void CategoryItemControl_Drop(object sender, DragEventArgs e) { string[] draggedFiles = (string[])e.Data.GetData(DataFormats.FileDrop); DraggedFilesEventArgs args = new DraggedFilesEventArgs() { Files = draggedFiles, CategoryId = ((CategoryItemControl)sender).CatId }; _eventAggregator.GetEvent <DraggedFilesEvent>().Publish(args); }