/// <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(); } }
/// <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(); }
/// <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(); } } }