Beispiel #1
0
        private void toolStripButtonRename_Click(object sender, EventArgs e)
        {
            if (listViewFile.SelectedItems.Count == 1)
            {
                string dirpath = toolStripTextBoxCurDir.Text;
                int    index   = listViewFile.SelectedIndices[0];
                string oldName = listViewFile.Items[index].SubItems[0].Text;

                string    newName = "";
                RenameBox form    = new RenameBox(oldName);

                form.ShowDialog();
                while (true)
                {
                    if (cancled)
                    {
                        cancled = false;
                        break;
                    }
                    else if (RenameBox.newName != null)
                    {
                        newName = RenameBox.newName;
                        form.Close();
                        string msg = "command,ReName," + toolStripTextBoxCurDir.Text + "," + oldName + "," + newName;

                        Send_forFileOperation(msg);
                        if (ReceiveRenameAnswer())
                        {
                            //listViewFile.Items[index].SubItems[0].Text = newName;
                            //if (index < selectedTreeNode.Nodes.Count)
                            //{
                            //    selectedTreeNode.Nodes[index].Text = dirpath + newName;
                            //    selectedTreeNode.Nodes[index].Tag.ToString().Replace(oldName, newName);
                            //}
                            RefreshNode(toolStripTextBoxCurDir.Text);
                        }
                        break;
                    }
                }
            }
            else
            {
                MessageBox.Show("请选择要重命名的文件或文件夹");
            }
        }
        private void toolStripButtonRename_Click(object sender, EventArgs e)
        {
            if (listViewFile.SelectedItems.Count == 1)
            {
                string dirpath = toolStripTextBoxCurDir.Text;
                int index = listViewFile.SelectedIndices[0];
                string oldName = listViewFile.Items[index].SubItems[0].Text;

                string newName = "";
                RenameBox form = new RenameBox(oldName);

                form.ShowDialog();
                while (true)
                {
                    if (cancled)
                    {
                        cancled = false;
                        break;
                    }
                    else if (RenameBox.newName != null)
                    {
                        newName = RenameBox.newName;
                        form.Close();
                        string msg = "command,ReName," + toolStripTextBoxCurDir.Text + "," + oldName + "," + newName;

                        Send_forFileOperation(msg);
                        if (ReceiveRenameAnswer())
                        {
                            //listViewFile.Items[index].SubItems[0].Text = newName;
                            //if (index < selectedTreeNode.Nodes.Count)
                            //{
                            //    selectedTreeNode.Nodes[index].Text = dirpath + newName;
                            //    selectedTreeNode.Nodes[index].Tag.ToString().Replace(oldName, newName);
                            //}
                            RefreshNode(toolStripTextBoxCurDir.Text);
                        }
                        break;
                    }
                }
            }
            else
            {
                MessageBox.Show("请选择要重命名的文件或文件夹");
            }
        }