Esempio n. 1
0
 private void saveTab(FATabStripItem tab)
 {
     if (TabStripUtils.isTagFlaggedAsModified(tab))
     {
         ((OpenableFile)tab.Tag).Save();
     }
 }
Esempio n. 2
0
        private bool unsavedChanges(IList <FATabStripItem> items)
        {
            bool unsaved = false;

            foreach (FATabStripItem tab in items)
            {
                if (TabStripUtils.isTagFlaggedAsModified(tab))
                {
                    unsaved = true;
                    break;
                }
            }

            return(unsaved);
        }
Esempio n. 3
0
        private void ApplyStyle()
        {
            bool unsavedChangesBefore = false;

            if (TabStripUtils.isTagFlaggedAsModified(this.CurrentTab))
            {
                unsavedChangesBefore = true;
            }

            ((OpenableFile)this.CurrentTab.Tag).Redraw();

            if (!unsavedChangesBefore)
            {
                TabStripUtils.unflagTabAsModified(this.CurrentTab);
            }
        }
Esempio n. 4
0
        private bool tryCloseTab(FATabStripItem tab)
        {
            if (TabStripUtils.isTagFlaggedAsModified(tab))
            {
                DialogResult result = MessageBox.Show("Save all changes to this file?", "Unsaved changes", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Warning);
                switch (result)
                {
                case DialogResult.Yes:
                    saveTab(tab);
                    break;

                case DialogResult.No:
                    break;

                case DialogResult.Cancel:
                default:
                    return(false);
                }
            }
            closeTab(tab);
            return(true);
        }
Esempio n. 5
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();
        }