コード例 #1
0
        private void NewButton_Click(object sender, EventArgs e)
        {
            NewFileOrFolder dialog = new NewFileOrFolder(TypeOfDialog.Add);

            if (dialog.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {
                string newName = dialog.nameOfNewFileOrFolder;

                try
                {
                    if (newName.Contains('.'))
                    {
                        System.IO.File.Create(selectedItemPath + "\\" + newName).Close();
                    }
                    else
                    {
                        System.IO.Directory.CreateDirectory(selectedItemPath + "\\" + newName);
                        newFolder = selectedItemPath + "\\" + newName;
                    }
                }
                catch
                {
                }

                Model.InitTreeViewAndListView(pathArray[SelectedIndex], treeViewArray[SelectedIndex], listViewArray[SelectedIndex]);
            }
        }
コード例 #2
0
        private void RenameButton_Click(object sender, EventArgs e)
        {
            NewFileOrFolder dlg = new NewFileOrFolder(TypeOfDialog.Rename);

            if (dlg.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {
                try
                {
                    if (listViewArray[SelectedIndex].Focused)
                    {
                        Model.RenameFileOrFolder(listViewArray[SelectedIndex].SelectedItems[0].ToolTipText, listViewArray[SelectedIndex].SelectedItems[0].ToolTipText.Remove(listViewArray[SelectedIndex].SelectedItems[0].ToolTipText.LastIndexOf('\\')) + "\\" + dlg.nameOfNewFileOrFolder);
                        listViewArray[SelectedIndex].SelectedItems[0].ToolTipText = listViewArray[SelectedIndex].SelectedItems[0].ToolTipText.Remove(listViewArray[SelectedIndex].SelectedItems[0].ToolTipText.LastIndexOf('\\')) + "\\" + dlg.nameOfNewFileOrFolder;
                        listViewArray[SelectedIndex].SelectedItems[0].Text        = dlg.nameOfNewFileOrFolder;
                    }
                    else
                    {
                        Model.RenameFileOrFolder(treeViewArray[SelectedIndex].SelectedNode.ToolTipText, treeViewArray[SelectedIndex].SelectedNode.ToolTipText.Remove(treeViewArray[SelectedIndex].SelectedNode.ToolTipText.LastIndexOf('\\')) + "\\" + dlg.nameOfNewFileOrFolder);
                        treeViewArray[SelectedIndex].SelectedNode.ToolTipText = treeViewArray[SelectedIndex].SelectedNode.ToolTipText.Remove(treeViewArray[SelectedIndex].SelectedNode.ToolTipText.LastIndexOf('\\')) + "\\" + dlg.nameOfNewFileOrFolder;
                        treeViewArray[SelectedIndex].SelectedNode.Text        = dlg.nameOfNewFileOrFolder;
                        pathTextBox.Text = treeViewArray[SelectedIndex].SelectedNode.ToolTipText;
                    }
                    Model.InitTreeViewAndListView(pathArray[SelectedIndex], treeViewArray[SelectedIndex], listViewArray[SelectedIndex]);
                }
                catch
                {
                }
            }
        }