示例#1
0
 /// <summary>
 /// Переход в подкаталог
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void buttonNextSubdirectory_Click(object sender, EventArgs e)
 {
     if (string.IsNullOrEmpty(textBoxNextSubdirectory.Text) || BunnedSymbols.IsBunned(textBoxNextSubdirectory.Text))
     {
         MessageBox.Show("Проверьте правильность имени открываемой директории, возможно, поле пустое!", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);
         textBoxNextSubdirectory.Focus();
         textBoxNextSubdirectory.ForeColor = Color.Red;
     }
     else
     {
         OpenDirectory openDirectory = new OpenDirectory(textBoxNextSubdirectory.Text, ref fileSystem);
         if (!fileSystem.ExecuteCommand(openDirectory))
         {
             MessageBox.Show("Возможно, открываемая директория не является директорией", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);
         }
         else
         {
             ReadDirectory readDirectory = new ReadDirectory(fileSystem);
             if (!fileSystem.ExecuteCommand(readDirectory))
             {
                 MessageBox.Show("Проверяй массив object-ов, похоже неверный апкаст", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                 this.Close();
             }
             textBoxSubdirectories.Clear();
             for (int i = 0; i < fileSystem.FilesAndDirectoriesInDirectory.Count; i++)
             {
                 textBoxSubdirectories.Text += "\"" + fileSystem.FilesAndDirectoriesInDirectory[i] + "\"" + " ";
             }
         }
     }
     textBoxNextSubdirectory.Clear();
 }
示例#2
0
        /// <summary>
        /// Кнопка создания директории
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void buttonCreateDirectory_Click(object sender, EventArgs e)
        {
            if (string.IsNullOrEmpty(textBoxDirectoryName.Text))
            {
                label2.Text = "Введите имя директории";
            }
            else if (BunnedSymbols.IsBunned(textBoxDirectoryName.Text))
            {
                label2.Text = "В имени есть запрещенные символы";
            }
            else
            {
                FileAllocationTable.Commands.DirectoryCommands.CreateDirectory createDirectory =
                    new FileAllocationTable.Commands.DirectoryCommands.CreateDirectory(textBoxDirectoryName.Text, checkedListBoxAttributes.GetItemChecked(0), true, FileSystem);

                if (!FileSystem.ExecuteCommand(createDirectory))
                {
                    MessageBox.Show("Не удалось создать директорию", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                }
                FileSystem.FilesAndDirectoriesInDirectory.Clear();
                ReadDirectory readDirectory = new ReadDirectory(FileSystem);
                FileSystem.ExecuteCommand(readDirectory);
                this.Close();
            }
        }
示例#3
0
 /// <summary>
 /// Созадать файл
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void buttonCreateFile_Click(object sender, EventArgs e)
 {
     if (string.IsNullOrEmpty(textBoxFileName.Text) || BunnedSymbols.IsBunned(textBoxFileName.Text))
     {
         MessageBox.Show("Некорректное значение в поле имени файла!", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);
         textBoxFileName.Focus();
     }
     else if (string.IsNullOrEmpty(textBoxFileExt.Text) || BunnedSymbols.IsBunned(textBoxFileExt.Text))
     {
         MessageBox.Show("Некорректное значение в поле расширения файла!", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);
         textBoxFileExt.Focus();
     }
     else
     {
         Attributes attributes = new Attributes(checkedListBoxAttributes.GetItemChecked(0), checkedListBoxAttributes.GetItemChecked(1),
                                                checkedListBoxAttributes.GetItemChecked(2), false, false, checkedListBoxAttributes.GetItemChecked(3));
         FileAllocationTable.Commands.FileCommands.CreateFile createFile = new FileAllocationTable.Commands.FileCommands.CreateFile(textBoxFileName.Text,
                                                                                                                                    textBoxFileExt.Text, attributes.ReadOnly, attributes.System, attributes.Hidden, ref fileSystem);
         if (!fileSystem.ExecuteCommand(createFile))
         {
             MessageBox.Show("Не удалось создать файл", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);
         }
         else
         {
             ReadDirectory readDirectory = new ReadDirectory(fileSystem);
             if (!fileSystem.ExecuteCommand(readDirectory))
             {
                 MessageBox.Show("Проверяй массив object-ов, похоже неверный апкаст", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                 this.Close();
             }
             Close();
         }
     }
 }
示例#4
0
 /// <summary>
 /// Удаляем файл
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void buttonRemoveFile_Click(object sender, EventArgs e)
 {
     if (string.IsNullOrEmpty(textBoxRemoveFile.Text))
     {
         MessageBox.Show("Поле имени файла пустое!", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);
     }
     else
     {
         string[] nameAndExt = textBoxRemoveFile.Text.Split(new char[] { '.' }, StringSplitOptions.RemoveEmptyEntries);
         string   name       = nameAndExt[0];
         string   ext        = "";
         if (nameAndExt.Length == 2)
         {
             ext = nameAndExt[1];
         }
         RemoveFile removeFile = new RemoveFile(fileSystem, name, ext);
         if (!fileSystem.ExecuteCommand(removeFile))
         {
             MessageBox.Show("Не удалось удалить файл", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);
         }
         else
         {
             ReadDirectory readDirectory = new ReadDirectory(fileSystem);
             if (!fileSystem.ExecuteCommand(readDirectory))
             {
                 MessageBox.Show("Смотри массив object-ов", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                 this.Close();
             }
             else
             {
                 textBoxSubdirectories.Clear();
                 for (int i = 0; i < fileSystem.FilesAndDirectoriesInDirectory.Count; i++)
                 {
                     textBoxSubdirectories.Text += "\"" + fileSystem.FilesAndDirectoriesInDirectory[i] + "\"" + " ";
                 }
             }
         }
     }
     textBoxRemoveFile.Clear();
 }
示例#5
0
        /// <summary>
        /// Покинуть текущий каталог
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void buttonLeaveCurrentDirectory_Click(object sender, EventArgs e)
        {
            CloseDirectory closeDirectory = new CloseDirectory(fileSystem);

            if (!fileSystem.ExecuteCommand(closeDirectory))
            {
                MessageBox.Show("Возможно, вы находимтесь в корневом каталоге. Его закрыть нельзя", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
            else
            {
                ReadDirectory readDirectory = new ReadDirectory(fileSystem);
                if (!fileSystem.ExecuteCommand(readDirectory))
                {
                    MessageBox.Show("Проверяй массив object-ов, похоже неверный апкаст", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    this.Close();
                }
                textBoxSubdirectories.Clear();
                for (int i = 0; i < fileSystem.FilesAndDirectoriesInDirectory.Count; i++)
                {
                    textBoxSubdirectories.Text += "\"" + fileSystem.FilesAndDirectoriesInDirectory[i] + "\"" + " ";
                }
            }
        }
示例#6
0
 /// <summary>
 /// Изменяем атрибуты
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void buttonChangeAttributes_Click(object sender, EventArgs e)
 {
     if (string.IsNullOrEmpty(textBoxChangeAttributes.Text))
     {
         MessageBox.Show("Поле имени файла пустое!", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);
     }
     else
     {
         string[] nameAndExt = textBoxChangeAttributes.Text.Split(new char[] { '.' }, StringSplitOptions.RemoveEmptyEntries);
         string   name       = nameAndExt[0];
         string   ext        = "";
         if (nameAndExt.Length == 2)
         {
             ext = nameAndExt[1];
         }
         OpenFile openFile = new OpenFile(name, ext, fileSystem);
         if (!fileSystem.ExecuteCommand(openFile))
         {
             MessageBox.Show("Не могу обновить ссылки", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);
         }
         else
         {
             ReadFile readFile = new ReadFile(fileSystem);
             if (!fileSystem.ExecuteCommand(readFile))
             {
                 MessageBox.Show("Смотри массив object-ов", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                 this.Close();
             }
             else
             {
                 Attributes attributes = fileSystem.GetCurrentFileAttributes();
                 if (attributes == null)
                 {
                     MessageBox.Show("Файл не открыт", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                 }
                 else
                 {
                     ChangeAttributes changeAttributes = new ChangeAttributes(fileSystem, textBoxChangeAttributes.Text);
                     changeAttributes.ShowDialog();
                     //
                     // Читаем заново текущую директорию и обновляем данные
                     //
                     ReadDirectory readDirectory = new ReadDirectory(fileSystem);
                     if (!fileSystem.ExecuteCommand(readDirectory))
                     {
                         MessageBox.Show("Смотри массив object-ов", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                         this.Close();
                     }
                     else
                     {
                         textBoxSubdirectories.Clear();
                         for (int i = 0; i < fileSystem.FilesAndDirectoriesInDirectory.Count; i++)
                         {
                             textBoxSubdirectories.Text += "\"" + fileSystem.FilesAndDirectoriesInDirectory[i] + "\"" + " ";
                         }
                     }
                 }
             }
         }
     }
     textBoxChangeAttributes.Clear();
 }