Пример #1
0
        private IEnumerable <IDropFile> GetFiles(InputFileDataObject data)
        {
            var names   = (string[])data.GetData("FileGroupDescriptorW");
            var streams = (MemoryStream[])data.GetData("FileContents");

            for (int i = 0; names != null && streams != null && i < names.Length; i++)
            {
                yield return(new DropFile(names[i], streams[i]));
            }
        }
Пример #2
0
        private bool OnCanDrop(DragEventArgs e)
        {
            var fs = e.Data.GetFormats();

            if (e.Data.GetDataPresent(DataFormats.FileDrop))
            {
                var names     = (string[])e.Data.GetData(DataFormats.FileDrop);
                var dropFiles = (names ?? new string[0]).Select(i => new DropFile(i, Stream.Null)).ToList();
                var result    = DropCommand != null && DropCommand.CanExecute(dropFiles);
                foreach (var file in dropFiles)
                {
                    file.Content.Dispose();
                }
                return(result);
            }
            else if (e.Data.GetDataPresent("FileGroupDescriptorW"))
            {
                var data      = new InputFileDataObject(e.Data);
                var names     = (string[])data.GetData("FileGroupDescriptorW");
                var dropFiles = (names ?? new string[0]).Select(i => new DropFile(i, Stream.Null)).ToList();
                var result    = DropCommand != null && DropCommand.CanExecute(dropFiles);
                foreach (var file in dropFiles)
                {
                    file.Content.Dispose();
                }
                return(result);
            }
            else
            {
                return(false);
            }
        }