Exemplo n.º 1
0
        private void pathTextBox_KeyUp(object sender, KeyEventArgs e)
        {
            if (e.KeyCode != Keys.Enter)
            {
                return;
            }

            string    enteredPath = pathTextBox.Text;
            eFileType fileType    = FileManagerUtils.GetCurrentPathType(enteredPath);

            if (fileType == eFileType.Folder)
            {
                m_currentPath = enteredPath;
                fillDataGridView(Directory.GetFileSystemEntries(enteredPath, "*", SearchOption.TopDirectoryOnly));
            }
            else if (fileType == eFileType.File)
            {
                System.Diagnostics.Process.Start(enteredPath);
            }
            else // TODO web site should work also from url bar.
            {
                MessageBox.Show("Windows can't find '" + enteredPath + "'. Check the spelling and try again.",
                                "File Explorer",
                                MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Exemplo n.º 2
0
        public static void Perform(eActionType i_ActionType, string i_OriginPath, string io_DestinationPath)
        {
            if (io_DestinationPath == Path.GetDirectoryName(i_OriginPath) && i_ActionType == eActionType.Move)
            {
                return;
            }

            ProcessDestinationPath(i_OriginPath, ref io_DestinationPath);

            switch (FileManagerUtils.GetCurrentPathType(i_OriginPath))
            {
            case eFileType.File:
                handleFileType(i_ActionType, i_OriginPath, io_DestinationPath);
                break;

            case eFileType.Folder:
                handleFolderType(i_ActionType, i_OriginPath, io_DestinationPath);
                break;

            case eFileType.Invalid:
                break;

            case eFileType.LogicalDrive:
                MessageBox.Show("You cannot move logical drive.", "Windows Explorer",
                                MessageBoxButtons.OK, MessageBoxIcon.Error);
                break;

            default:
                throw new ArgumentOutOfRangeException();
            }
        }
Exemplo n.º 3
0
        private void dataGridView1_CellDoubleClick(object sender, DataGridViewCellEventArgs e)
        {
            setStacks();
            eFileType fileType = FileManagerUtils.GetCurrentPathType(m_currentPath);

            if (fileType == eFileType.Folder || fileType == eFileType.LogicalDrive)
            {
                fillDataGridView(Directory.GetFileSystemEntries(m_currentPath, "*", SearchOption.TopDirectoryOnly));
            }
            else if (fileType == eFileType.File)
            {
                System.Diagnostics.Process.Start(m_currentPath);
            }
        }
Exemplo n.º 4
0
        private static void ProcessDestinationPath(string i_OriginPath, ref string io_DestinationPath)
        {
            if (FileManagerUtils.GetCurrentPathType(io_DestinationPath) != eFileType.LogicalDrive)
            {
                io_DestinationPath += "\\" + Path.GetFileName(i_OriginPath);
            }
            else
            {
                io_DestinationPath += Path.GetFileName(i_OriginPath);
            }

            if (i_OriginPath.Equals(io_DestinationPath))
            {
                while (File.Exists(io_DestinationPath) || Directory.Exists(io_DestinationPath))
                {
                    io_DestinationPath = Path.GetDirectoryName(io_DestinationPath) + Path.GetFileNameWithoutExtension(io_DestinationPath) + " - Copy" +
                                         Path.GetExtension(i_OriginPath);
                }
            }
        }
Exemplo n.º 5
0
        private void operationEventHandler(eActionType i_ActionType)
        {
            string message = string.Empty;

            FileManagerUtils.messagePreperations(ref message, i_ActionType);

            if (!checkDataGridViewBounds(message))
            {
                return;
            }

            string path = getDataGridViewCellValue();

            if (i_ActionType != eActionType.Delete && showFolderBrowseDialog(path, message))
            {
                operationEventHandlerHelper(i_ActionType, path);
            }
            else if (i_ActionType == eActionType.Delete)
            {
                operationEventHandlerHelper(i_ActionType, path); // todo add delete functionality
            }
        }