示例#1
0
        public override void Execute(object parameter)
        {
            var active = MainViewModel.ActiveDirectoryContainer.ActiveView;
            //get data from clipboard
            var data = Clipboard.GetDataObject();

            //files
            var paths = (string[])data.GetData(DataFormats.FileDrop, true);

            if (paths == null)
            {
                MessageBox.Show("Schowek jest pusty");
                return;
            }

            //get flag indicating whether it is copy or cut
            var stream = (MemoryStream)data.GetData("Preferred DropEffect", true);
            bool copyFlag = stream.ReadByte() == 5 ? true : false;

            //change paths into IDirectoryViewItems
            var items = new IDirectoryViewItem[paths.Length];
            for (int i = 0; i < paths.Length; i++)
                items[i] = WindowsFile.CreateFromPath(paths[i]);

            MultiFileOperation operation;
            if (copyFlag)
                operation = new CopyOperation(items, active.FullPath, new WindowsFileSystem(), active.FileSystem);
            else
                operation = new MoveOperation(items, active.FullPath, new WindowsFileSystem(), active.FileSystem);

            OperationManager.ExecuteOperation(operation);
        }
示例#2
0
        public override void Execute(object parameter)
        {
            var source = MainViewModel.ActiveDirectoryContainer.ActiveView;
            var dest = MainViewModel.InActiveDirectoryContainer.ActiveView;

            var operation = new CopyOperation(MainViewModel.GetSelectedItems(), dest.FullPath, source.FileSystem, dest.FileSystem);
            OperationManager.ExecuteOperation(operation);
        }
示例#3
0
 public void CopyTo(string destDir, CopyOperation operation)
 {
     throw new NotImplementedException();
 }
示例#4
0
        /// <summary>
        /// Copy directory
        /// </summary>
        /// <param name="dir">Directory to copy</param>
        /// <param name="destination">Destination directory</param>
        /// <param name="operation">CopyOperation to report changes</param>
        private void CopyDirectory(DirectoryInfo dir, string destination, CopyOperation operation)
        {
            string copyDir = Path.Combine(destination, dir.Name);
            Directory.CreateDirectory(copyDir);

            foreach (FileInfo file in dir.GetFiles())
                WindowsFileSystemApi.CopyFile(file, new FileInfo(Path.Combine(copyDir, file.Name)), CopyFileOptions.None, operation.CopiedPieceOfFile);

            foreach (DirectoryInfo di in dir.GetDirectories())
                CopyDirectory(di, copyDir, operation);
        }
示例#5
0
 public void CopyTo(string destDir, CopyOperation operation)
 {
     if (!isDir)
         WindowsFileSystemApi.CopyFile((FileInfo)adapted, new FileInfo(Path.Combine(destDir, Name)), CopyFileOptions.None, operation.CopiedPieceOfFile);
     else
         CopyDirectory((DirectoryInfo)adapted, destDir, operation);
 }
        private void DropCopy(object sender, RoutedEventArgs e)
        {
            MenuItem item = (MenuItem)sender;
            IDirectoryViewItem[] files = (IDirectoryViewItem[])item.Tag;

            CopyOperation copy = new CopyOperation(files, DisplayPath, FileSystem, FileSystem);
            //Main.SupportOperation(copy);
        }
 private void ExecuteDropCopy(object parameter)
 {
     var sourceFileSystem = new WindowsFileSystem(droppedFiles.First().FullName);
     var operation = new CopyOperation(droppedFiles, ActiveView.FullPath, sourceFileSystem, ActiveView.FileSystem);
     OperationsManager.ExecuteOperation(operation);
 }