예제 #1
0
        private void mainFrm_Load(object sender, EventArgs e)
        {
            DataManager.initDataManager();
            AutoCompleteItemManager.load();

            if (DataManager.settings.openedPersonas.Count > 0)
            {
                foreach (string personaPath in DataManager.settings.openedPersonas)
                {
                    OpenPersonaIgnoreChecks(personaPath);
                }
            }

            foreach (string filePath in DataManager.settings.openedTabs)
            {
                OpenableFile file = findFileInTree(this.projectView.Nodes, filePath);
                if (file == null)
                {
                    file = PersonaFile.CreateInstance(filePath);
                }
                openFileIgnoreChecks(file);
            }

            this.recentlyOpenedScriptsToolStripMenuItem.Entries       = DataManager.settings.last10OpenedScripts;
            this.recentlyOpenedPersonalitiesToolStripMenuItem.Entries = DataManager.settings.last10OpenedPersonas;

            this.toolStripMakroBtnRecord.Enabled  = false;
            this.toolStripMakroBtnExecute.Enabled = false; //TODO: enable in later version after implementation
        }
예제 #2
0
        private void addAssociatedFile(PersonaFile file, TreeNode parentNode)
        {
            TreeNode node = new TreeNode(file.File.Name, 1, 1)
            {
                Tag = file
            };

            parentNode.Nodes.Add(node);
        }
예제 #3
0
        private void openScript_Click(object sender, EventArgs e)
        {
            OpenFileDialog ofd = new OpenFileDialog();

            ofd.InitialDirectory = DataManager.settings.lastOpenedSingleFileDirectory;


            if (ofd.ShowDialog() == DialogResult.OK)
            {
                PersonaFile newFile = PersonaFile.CreateInstance(ofd.FileName);
                openFile(newFile);

                DataManager.settings.lastOpenedSingleFileDirectory = newFile.File.Directory.FullName;
            }
        }
예제 #4
0
        public Folder(DirectoryInfo dir)
        {
            this.Directory = dir;

            foreach (DirectoryInfo subDir in this.Directory.GetDirectories())
            {
                this.Folders.Add(subDir.Name, new Folder(subDir));
            }

            foreach (FileInfo file in this.Directory.GetFiles())
            {
                PersonaFile newFile = PersonaFile.CreateInstance(file);

                this.Files.Add(file.Name, newFile);
            }
        }
예제 #5
0
        public frmMain()
        {
            InitializeComponent();
            this.projectView.ImageList = DataManager.iconList;
            //this.renameToolStripMenuItem.Enabled = false;

            this.recentlyOpenedScriptsToolStripMenuItem.EntryClicked += (object sender, EventArgs e) => {
                ToolStripMenuItem menuItem = (ToolStripMenuItem)sender;
                OpenableFile      file     = PersonaFile.CreateInstance(menuItem.Text);
                openFile(file);
            };

            this.recentlyOpenedPersonalitiesToolStripMenuItem.EntryClicked += (object sender, EventArgs e) => {
                ToolStripMenuItem menuItem = (ToolStripMenuItem)sender;
                OpenPersona(menuItem.Text);
            };
        }
예제 #6
0
        private void newScriptToolStripMenuItem_Click(object sender, EventArgs e)
        {
            SaveFileDialog sfd = new SaveFileDialog();

            sfd.InitialDirectory = ((Folder)this.projectView.SelectedNode.Tag).Directory.FullName;

            if (sfd.ShowDialog() == DialogResult.OK)
            {
                PersonaFile file = PersonaFile.CreateInstance(sfd.FileName);
                file.Persona = ((Folder)this.projectView.SelectedNode.Tag)?.Persona; //if persona is set in parent folder set it to the new file too

                File.Create(file.File.FullName).Close();

                this.addAssociatedFile(file, this.projectView.SelectedNode);

                openFile(file);
            }
        }
예제 #7
0
 private void addAssociatedFile(PersonaFile file, TreeNode parentNode)
 {
     TreeNode node = new TreeNode(file.File.Name, 1, 1) { Tag = file };
     parentNode.Nodes.Add(node);
 }
예제 #8
0
 public static PersonaFile CreateInstance(string path)
 {
     return(PersonaFile.CreateInstance(new FileInfo(path)));
 }
예제 #9
0
        private void projectView_AfterLabelEdit(object sender, NodeLabelEditEventArgs e)
        {
            if (e.Label == null) //no rename occured
            {
                return;
            }

            if (e.Node.Tag is Folder)
            {
                TreeNode parentNode    = e.Node.Parent;
                Folder   renamedFolder = (Folder)this.projectView.SelectedNode.Tag;

                string        parentDir     = ((Folder)e.Node.Parent.Tag).Directory.FullName;
                string        newFolderPath = parentDir + @"\" + e.Label;
                DirectoryInfo dirInfo       = new DirectoryInfo(newFolderPath);

                if (dirInfo.Exists)
                {
                    e.CancelEdit = true;
                    e.Node.EndEdit(true);
                    return;
                }

                e.Node.EndEdit(false);

                renamedFolder.Directory.MoveTo(newFolderPath);

                updateFolderChildrenPath(renamedFolder);
            }
            else if (e.Node.Tag is PersonaFile)
            {
                PersonaFile renamedFile = (PersonaFile)e.Node.Tag;
                string      newFullName = ((Folder)e.Node.Parent.Tag).Directory.FullName + @"\" + e.Label;
                FileInfo    fileInfo    = new FileInfo(newFullName);

                if (fileInfo.Exists)
                {
                    e.CancelEdit = true;
                    e.Node.EndEdit(true);
                    return;
                }

                e.Node.EndEdit(false);
                File.Move(renamedFile.File.FullName, newFullName);
                renamedFile.File = fileInfo;

                if (renamedFile.tab != null)
                {
                    if (TabStripUtils.isTagFlaggedAsModified(renamedFile.tab))
                    {
                        renamedFile.tab.Title = e.Label;
                        TabStripUtils.flagTabAsModified(renamedFile.tab);
                    }
                    else
                    {
                        renamedFile.tab.Title = e.Label;
                    }

                    int index = DataManager.settings.openedTabs.IndexOf(renamedFile.File.FullName);
                    if (index >= 0)
                    {
                        DataManager.settings.openedTabs[index] = newFullName;
                    }
                }
            }

            this.projectView.Invalidate();
        }