コード例 #1
0
ファイル: MainMdi.cs プロジェクト: rpgtoolkit/rpgcodeexpress
        private void ProjectExplorer_NodeRename(object sender, NodeLabelRenameEventArgs e)
        {
            if (editorDictionary.ContainsKey(e.OldFile.ToLower()))
            {
                EditorForm editorForm = new EditorForm();
                editorDictionary.TryGetValue(e.OldFile.ToLower(), out editorForm);

                CodeEditor codeEditor = (CodeEditor)editorForm;
                codeEditor.EditorFile = e.NewFile;

                if (codeEditor.IsUpdated)
                {
                    codeEditor.TabText = Path.GetFileName(e.NewFile);
                }
                else
                {
                    codeEditor.TabText = Path.GetFileName(e.NewFile + "*");
                }

                editorDictionary.Remove(e.OldFile.ToLower());
                editorDictionary.Add(e.NewFile.ToLower(), editorForm);
            }
        }
コード例 #2
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="children"></param>
        /// <param name="parentOldPath"></param>
        /// <param name="parentNewPath"></param>
        private void UpdateChildren(List<ExplorerNode> children, string parentOldPath, string parentNewPath)
        {
            foreach (ExplorerNode child in children)
            {
                if (child is FolderNode)
                {
                    if (child.Children.Count > 0)
                    {
                        UpdateChildren(child.Children, parentOldPath + child.File + @"\", parentNewPath + child.File + @"\");
                    }
                }

                NodeLabelRenameEventArgs args = new NodeLabelRenameEventArgs(parentOldPath + child.File,
                    parentNewPath + child.File);
                this.OnNodeRename(args);
            }
        }
コード例 #3
0
        /// <summary>
        /// Renames a file.
        /// </summary>
        /// <param name="e">Event information.</param>
        /// <param name="editedNode">The parentNode that was edited.</param>
        private void RenameNode(NodeLabelEditEventArgs e, ExplorerNode editedNode)
        {
            try
            {
                string oldFile = editedNode.AbsolutePath;
                string newFile = System.IO.Path.Combine(editedNode.ParentNode.AbsolutePath, e.Label);

                if (editedNode is FileNode)
                {
                    File.Move(oldFile, newFile);
                }
                else if (editedNode is FolderNode)
                {
                    Directory.Move(oldFile, newFile);

                    if (editedNode.Children.Count > 0)
                    {
                        UpdateChildren(editedNode.Children, oldFile + @"\", newFile + @"\");
                    }
                }

                editedNode.File = e.Label;

                NodeLabelRenameEventArgs args2 = new NodeLabelRenameEventArgs(oldFile, newFile);
                this.OnNodeRename(args2);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, Application.ExecutablePath, MessageBoxButtons.OK, MessageBoxIcon.Error);
                e.CancelEdit = true;
            }
        }
コード例 #4
0
        private void treFileBrowser_DragDrop(object sender, DragEventArgs e)
        {
            bool isFile = e.Data.GetDataPresent(typeof(FileNode));
            bool isFolder = e.Data.GetDataPresent(typeof(FolderNode));

            if (!isFile && !isFolder)
            {
                return;
            }

            TreeView treeView = (TreeView)sender;
            ExplorerNode targetNode = (ExplorerNode)treeView.SelectedNode;
            ExplorerNode dropNode;

            if (isFile)
            {
                dropNode = (FileNode)e.Data.GetData(typeof(FileNode));
            }
            else
            {
                dropNode = (FolderNode)e.Data.GetData(typeof(FolderNode));
            }

            if (targetNode == null)
            {
                return;
            }
            else if (targetNode is FileNode)
            {
                return;
            }
            else
                try
                {
                    if (dropNode is FolderNode)
                    {
                        Directory.Move(dropNode.AbsolutePath, targetNode.AbsolutePath + @"\" + dropNode.File);
                        UpdateChildren(dropNode.Children, dropNode.AbsolutePath + @"\",
                            targetNode.AbsolutePath + @"\" +  dropNode.File + @"\");
                    }
                    else
                    {
                        NodeLabelRenameEventArgs args2 = new NodeLabelRenameEventArgs(dropNode.AbsolutePath,
                        targetNode.AbsolutePath + @"\" + dropNode.Text);
                        this.OnNodeRename(args2);

                        File.Move(dropNode.AbsolutePath, targetNode.AbsolutePath + @"\" + dropNode.Text);
                    }

                    dropNode.ParentNode.Children.Remove(dropNode);
                    dropNode.ParentNode = targetNode;

                    targetNode.Children.Add(dropNode);

                    dropNode.Remove();
                    targetNode.Nodes.Add(dropNode);
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message, Application.ExecutablePath, MessageBoxButtons.OK,
                        MessageBoxIcon.Error);
                }

            dropNode.EnsureVisible();
            treeView.SelectedNode = dropNode;
        }
コード例 #5
0
 protected virtual void OnNodeRename(NodeLabelRenameEventArgs e)
 {
     if (NodeRename != null)
     {
         NodeRename(this, e);
     }
 }