Esempio n. 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);
        }
Esempio n. 2
0
        public override void Execute(object parameter)
        {
            var source = MainViewModel.ActiveDirectoryContainer.ActiveView;
            var dest = MainViewModel.InActiveDirectoryContainer.ActiveView;
            var items = MainViewModel.GetSelectedItems();
            if (items.Length == 0)
            {
                MessageBox.Show("Zaznacz obiekty do przeniesienia");
                return;
            }

            var operation = new MoveOperation(items, dest.FullPath, source.FileSystem, dest.FileSystem);
            OperationManager.ExecuteOperation(operation);
        }
Esempio n. 3
0
 public void MoveTo(string path, MoveOperation operation)
 {
     throw new NotImplementedException();
 }
Esempio n. 4
0
        /// <summary>
        /// Moved directory with content to another place
        /// </summary>
        /// <param name="dir">Directory to move</param>
        /// <param name="destination">Destination path</param>
        /// <param name="operation">MoveOperation to report progress</param>
        private void MoveDirectory(DirectoryInfo dir, string destination, MoveOperation operation)
        {
            //TODO: Check if is WinAPI function for moving directories
            string moveDir = Path.Combine(destination, dir.Name);
            Directory.CreateDirectory(moveDir);

            foreach (FileInfo file in dir.GetFiles())
                WindowsFileSystemApi.MoveFile(file, new FileInfo(Path.Combine(moveDir, file.Name)), MoveFileOptions.CopyAllowed, operation.MovedPieceOfFile);

            foreach (DirectoryInfo di in dir.GetDirectories())
                MoveDirectory(di, moveDir, operation);

            dir.Delete(true);
        }
Esempio n. 5
0
 public void MoveTo(string destDir, MoveOperation operation)
 {
     if (!isDir)
         WindowsFileSystemApi.MoveFile((FileInfo)adapted, new FileInfo(Path.Combine(destDir, Name)), MoveFileOptions.CopyAllowed | MoveFileOptions.ReplaceExisting, operation.MovedPieceOfFile);
     else
         MoveDirectory((DirectoryInfo)adapted, destDir, operation);
 }
        private void DropMove(object sender, RoutedEventArgs e)
        {
            MenuItem item = (MenuItem)sender;
            IDirectoryViewItem[] files = (IDirectoryViewItem[])item.Tag;

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