Ejemplo n.º 1
0
        private void Move_Click(object sender, RoutedEventArgs e)
        {
            if (sideRight.SelectedElement != null)
            {
                selectedSite = SelectedSide.right;
            }
            else
            {
                selectedSite = SelectedSide.left;
            }

            DiscElement presentElement = selectedSite == SelectedSide.left ? sideLeft.SelectedElement : sideRight.SelectedElement;
            string      dirName        = selectedSite == SelectedSide.left ? sideLeft.SelectedElement.Path : sideRight.SelectedElement.Path;
            string      fileName       = selectedSite == SelectedSide.left ? sideLeft.SelectedElement.getName() : sideRight.SelectedElement.getName();
            string      sourcePath     = selectedSite == SelectedSide.left ? sideLeft.mainPath.Text : sideRight.mainPath.Text;
            string      targetPath     = selectedSite == SelectedSide.left ? sideRight.mainPath.Text : sideLeft.mainPath.Text;
            string      sourceFile     = System.IO.Path.Combine(sourcePath, fileName);
            string      destFile       = System.IO.Path.Combine(targetPath, fileName);

            if (sourcePath == targetPath)
            {
                return;
            }

            if (presentElement.isFile())
            {
                if (!Directory.Exists(targetPath))
                {
                    Directory.CreateDirectory(targetPath);
                }

                var paths = new PathToMove(sourceFile, destFile, presentElement.isFile());
                var bW    = new BackgroundWorker();
                bW.DoWork             += asyncMove;
                bW.RunWorkerCompleted += backgroundWorker_RunWorkerCompleted;
                bW.RunWorkerAsync(paths);
            }

            else
            {
                if (!Directory.Exists(destFile))
                {
                    var paths = new PathToMove(dirName, destFile, presentElement.isFile());
                    var bW    = new BackgroundWorker();
                    bW.DoWork             += asyncMove;
                    bW.RunWorkerCompleted += backgroundWorker_RunWorkerCompleted;
                    bW.RunWorkerAsync(paths);
                }
                else
                {
                    MessageBox.Show("Папка с указанным именем уже существует");
                    return;
                }
            }
        }
Ejemplo n.º 2
0
        private void copy_Click(object sender, RoutedEventArgs e)
        {
            if (sideRight.SelectedElement != null)
            {
                selectedSite = SelectedSide.right;
            }
            else
            {
                selectedSite = SelectedSide.left;
            }

            DiscElement presentElement = selectedSite == SelectedSide.left ? sideLeft.SelectedElement : sideRight.SelectedElement;
            string      dirName        = selectedSite == SelectedSide.left ? sideLeft.SelectedElement.Path : sideRight.SelectedElement.Path;
            string      fileName       = selectedSite == SelectedSide.left ? sideLeft.SelectedElement.getName() : sideRight.SelectedElement.getName();
            string      sourcePath     = selectedSite == SelectedSide.left ? sideLeft.mainPath.Text : sideRight.mainPath.Text;
            string      targetPath     = selectedSite == SelectedSide.left ? sideRight.mainPath.Text : sideLeft.mainPath.Text;
            string      sourceFile     = System.IO.Path.Combine(sourcePath, fileName);
            string      destFile       = System.IO.Path.Combine(targetPath, fileName);

            if (presentElement.isFile())
            {
                if (!System.IO.Directory.Exists(targetPath))
                {
                    System.IO.Directory.CreateDirectory(targetPath);
                }
                File.Copy(sourceFile, destFile, true);
                onShowAfterDeleted();
            }

            else
            {
                DirectoryCopy(dirName, destFile, true);
                onShowAfterDeleted();
            }
        }
Ejemplo n.º 3
0
        private void rename_Click(object sender, RoutedEventArgs e)
        {
            if (sideRight.SelectedElement != null)
            {
                selectedSite = SelectedSide.right;
            }
            else
            {
                selectedSite = SelectedSide.left;
            }
            DiscElement presentElement = selectedSite == SelectedSide.left ? sideLeft.SelectedElement : sideRight.SelectedElement;
            string      path           = selectedSite == SelectedSide.left ? sideLeft.SelectedElement.Path : sideRight.SelectedElement.Path;
            string      sourcePath     = selectedSite == SelectedSide.left ? sideLeft.mainPath.Text : sideRight.mainPath.Text;

            string fileName = selectedSite == SelectedSide.left ? sideLeft.SelectedElement.getName() : sideRight.SelectedElement.getName();
            var    dialog   = new RenamePanel(path, sourcePath, presentElement.isFile(), fileName);

            dialog.Show();
            dialog.RenameObject += RefreshAllList;
        }