private void buttonRename_Click(object sender, EventArgs e) { FilesDataGridView focused = lastFocusedFileDataGridView; if (focused.SelectedRows.Count == 0) { MessageBox.Show("Выберите хотябы 1 элемент!", "", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } else if (focused.SelectedRows.Count > 1) { MessageBox.Show("Выберите только 1 элемент!", "", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } string fileName = focused.SelectedRows[0].Cells[0].Value.ToString(); new InputQuestion("Выберите новое название", fileName, (answer, newName) => { if (answer) { focused.RanameRow(focused.SelectedRows[0], newName); } focused.Focus(); }) { Owner = this, StartPosition = FormStartPosition.CenterParent }.ShowDialog(); }
private void buttonMove_Click(object sender, EventArgs e) { FilesDataGridView focused = lastFocusedFileDataGridView; if (focused.SelectedRows.Count == 0) { MessageBox.Show("Выберите хотябы 1 элемент!", "", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } new PathQuestions("Выберите каталог для перемещения, выбрано " + focused.SelectedRows.Count + " элементов:", (answer, newDirName) => { if (answer) { foreach (DataGridViewRow row in focused.SelectedRows) { focused.MoveRow(row, newDirName); } } focused.Focus(); }) { Owner = this, StartPosition = FormStartPosition.CenterParent }.ShowDialog(); }
private void buttonNewFolder_Click(object sender, EventArgs e) { FilesDataGridView focused = lastFocusedFileDataGridView; new InputQuestion("Введите название нового каталога:", null, (answer, newDirName) => { if (answer) { focused.CreateSubDirectory(newDirName); } focused.Focus(); }) { Owner = this, StartPosition = FormStartPosition.CenterParent }.ShowDialog(); }
private void buttonChangeFolderName_Click(object sender, EventArgs e) { FilesDataGridView focused = lastFocusedFileDataGridView; if (focused.SelectedRows.Count == 0) { MessageBox.Show("Выберите хотябы 1 элемент!", "", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } if (!focused.SelectedRows[0].Cells[1].Value.ToString().ToLower().Equals("файл")) { MessageBox.Show("Выберите хотябы 1 файл!", "", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } string fileName = focused.SelectedRows[0].Cells[0].Value.ToString(); string filePath = focused.GetCurrentPath() + fileName; FileInfo fileInfo = new FileInfo(filePath); if (!fileInfo.Extension.Equals(".txt")) { MessageBox.Show("Файл должен быть формата txt", "", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } string data = File.ReadAllText(filePath); new Editor(fileName, data, (answer, changedData) => { if (answer) { File.WriteAllText(filePath, changedData); } focused.Focus(); }) { Owner = this, StartPosition = FormStartPosition.CenterScreen }.Show(); }
private void buttonCopy_Click(object sender, EventArgs e) { FilesDataGridView focused = lastFocusedFileDataGridView; new PathQuestions("Выберите каталог для копирования, выбрано " + focused.SelectedRows.Count + " элементов:", (answer, newDirName) => { if (answer) { foreach (DataGridViewRow row in focused.SelectedRows) { focused.CopyRow(row, newDirName); } } focused.Focus(); }) { Owner = this, StartPosition = FormStartPosition.CenterParent }.ShowDialog(); }
private void buttonDelet_Click(object sender, EventArgs e) { FilesDataGridView focused = lastFocusedFileDataGridView; new Questions("Вы действительно хотите удалить все выделенные элементы ?", (answer) => { if (answer) { foreach (DataGridViewRow row in focused.SelectedRows) { focused.DeleteRow(row); } } focused.Focus(); }) { Owner = this, StartPosition = FormStartPosition.CenterParent }.ShowDialog(); }