private void RenameFileButtonClick(object sender, EventArgs e) { if (!funPanel.Visible || fileOpera != FileOpera.Rename) { funPanel.Visible = true; fileOpera = FileOpera.Rename; operaLabel.Text = string.Format("重命名{0}文件:", fileTag); nameTextBox.Text = selectFileName.Text; nameTextBox.Enabled = true; msgLabel.Text = "再次点击<重命名文件>确认重命名文件!"; msgLabel.ForeColor = SystemColors.ActiveCaptionText; Common.ReportCmdKeyProgress(CmdKey.F0022); } else { string path = pathView.SelectedNode.Tag.ToString(); if (selectFileName.Tag != null) { if (CheckFileNameExists(path, nameTextBox.Text, fileAtt)) { if (pathView.SelectedNode != null && pathView.SelectedNode.Tag != null) { string newName = string.Format("{0}\\{1}{2}", path, nameTextBox.Text, fileAtt.Remove(0, 1)); File.Move(selectFileName.Tag.ToString(), newName); funPanel.Visible = false; fileOpera = FileOpera.None; LoadFileName(pathView.SelectedNode.Tag.ToString()); Common.ReportCmdKeyProgress(CmdKey.F0014); } else { Common.ReportCmdKeyProgress(CmdKey.F0005); msgLabel.Text = "请选择重命名文件所属目录"; msgLabel.ForeColor = Color.Red; } } else { Common.ReportCmdKeyProgress(CmdKey.F0012); msgLabel.Text = "重命名文件名无效,请重新输入"; msgLabel.ForeColor = Color.Red; } } else { Common.ReportCmdKeyProgress(CmdKey.F0011); msgLabel.Text = "请先选择要重命名的文件"; msgLabel.ForeColor = Color.Red; } } }
private void FileManager_CancelClick(object sender, EventArgs e) { if (funPanel.Visible || fileOpera != FileOpera.None) { funPanel.Visible = false; fileOpera = FileOpera.None; } else { if (this.Parent != null) { this.ParentForm.OnCancelClick(); } } }
private void DeleteFolderButtonClick(object sender, EventArgs e) { if (pathView.SelectedNode == null) { return; } if (!funPanel.Visible || fileOpera != FileOpera.DeleteFolder) { funPanel.Visible = true; fileOpera = FileOpera.DeleteFolder; operaLabel.Text = string.Format("删除{0}目录:", fileTag); nameTextBox.Text = pathView.SelectedNode.Text; nameTextBox.Enabled = false; msgLabel.Text = "再次点击<删除目录>确认删除目录!"; msgLabel.ForeColor = SystemColors.ActiveCaptionText; Common.ReportCmdKeyProgress(CmdKey.F0024); } else { nameTextBox.Text = pathView.SelectedNode.Text; string folder = pathView.SelectedNode.Tag.ToString(); if (Directory.Exists(folder)) { if (Directory.GetFiles(folder, fileAtt).Count() == 0) { Directory.Delete(folder); funPanel.Visible = false; fileOpera = FileOpera.None; LoadDefaultFile(); Common.ReportCmdKeyProgress(CmdKey.F0018); } else { msgLabel.Text = "该目录无法删除,请先删除目录下文件"; msgLabel.ForeColor = Color.Red; Common.ReportCmdKeyProgress(CmdKey.F0017); } } else { msgLabel.Text = "请先选择要删除的目录"; msgLabel.ForeColor = Color.Red; Common.ReportCmdKeyProgress(CmdKey.F0005); } } }
private void CreateFolderButtonClick(object sender, EventArgs e) { if (!funPanel.Visible || fileOpera != FileOpera.CreateFolder) { funPanel.Visible = true; fileOpera = FileOpera.CreateFolder; operaLabel.Text = string.Format("新建{0}目录:", fileTag); nameTextBox.Text = ""; nameTextBox.Enabled = true; msgLabel.Text = "再次点击<新建目录>确认新建目录!"; msgLabel.ForeColor = SystemColors.ActiveCaptionText; Common.ReportCmdKeyProgress(CmdKey.F0023); } else { string path = pathView.SelectedNode.Tag.ToString(); if (!string.IsNullOrWhiteSpace(nameTextBox.Text)) { string newPath = string.Format("{0}\\{1}", path, nameTextBox.Text); if (!Directory.Exists(newPath)) { Directory.CreateDirectory(newPath); funPanel.Visible = false; fileOpera = FileOpera.None; LoadDefaultFile(); Common.ReportCmdKeyProgress(CmdKey.F0016); } else { msgLabel.Text = "目录已存在,请重新输入"; msgLabel.ForeColor = Color.Red; Common.ReportCmdKeyProgress(CmdKey.F0015); } } else { msgLabel.Text = "新建目录名无效,请重新输入"; msgLabel.ForeColor = Color.Red; Common.ReportCmdKeyProgress(CmdKey.F0015); } } }
private void DeleteFileButtonClick(object sender, EventArgs e) { if (!funPanel.Visible || fileOpera != FileOpera.DeleteFile) { fileOpera = FileOpera.DeleteFile; funPanel.Visible = true; operaLabel.Text = string.Format("删除{0}文件:", fileTag); nameTextBox.Text = selectFileName.Text; nameTextBox.Enabled = false; msgLabel.Text = "再次点击<删除文件>确认删除文件!"; msgLabel.ForeColor = SystemColors.ActiveCaptionText; Common.ReportCmdKeyProgress(CmdKey.F0008); } else { if (fileListView.SelectedItems.Count > 0) { string fn = fileListView.SelectedItems[0].Tag.ToString(); if (fn.Equals(usedFileFullName)) { msgLabel.Text = "无法删除当前选中的文件"; msgLabel.ForeColor = Color.Red; Common.ReportCmdKeyProgress(CmdKey.F0009); } else { File.Delete(fn); funPanel.Visible = false; fileOpera = FileOpera.None; Common.ReportCmdKeyProgress(CmdKey.F0010); LoadFileName(pathView.SelectedNode.Tag.ToString()); } } else { Common.ReportCmdKeyProgress(CmdKey.F0011); msgLabel.Text = "请选择要删除的文件"; msgLabel.ForeColor = Color.Red; } } }
private void CreateFileButtonClick(object sender, EventArgs e) { if (!funPanel.Visible || fileOpera != FileOpera.CreatFile) { funPanel.Visible = true; fileOpera = FileOpera.CreatFile; operaLabel.Text = string.Format("新建{0}文件:", fileTag); nameTextBox.Text = selectFileName.Text; nameTextBox.Enabled = true; msgLabel.Text = "再次点击<新建文件>确认新建文件!"; msgLabel.ForeColor = SystemColors.ActiveCaptionText; Common.ReportCmdKeyProgress(CmdKey.F0007); } else { string path = pathView.SelectedNode.Tag.ToString(); if (CheckFileNameExists(path, nameTextBox.Text, fileAtt)) { if (pathView.SelectedNode != null && pathView.SelectedNode.Tag != null) { File.Create(string.Format("{0}\\{1}{2}", path, nameTextBox.Text, fileAtt.Remove(0, 1))).Close(); funPanel.Visible = false; fileOpera = FileOpera.None; LoadFileName(pathView.SelectedNode.Tag.ToString()); Common.ReportCmdKeyProgress(CmdKey.F0004); } else { msgLabel.Text = "请选择新建文件所属目录"; msgLabel.ForeColor = Color.Red; Common.ReportCmdKeyProgress(CmdKey.F0005); } } else { msgLabel.Text = "新建文件名无效,请重新输入"; msgLabel.ForeColor = Color.Red; Common.ReportCmdKeyProgress(CmdKey.F0006); } } }