コード例 #1
0
        private void LabelEditFinished(object sender, NodeLabelEditEventArgs e)
        {
            this.tvProjectExplorer.LabelEdit = false;
            PascalABCCompiler.IFileInfo fi = items[e.Node] as PascalABCCompiler.IFileInfo;
            if (e.Label == null)
            {
                return;
            }
            if (!PascalABCCompiler.Tools.CheckFileNameValid(e.Label))
            {
                e.CancelEdit = true;
                MessageBox.Show(Form1StringResources.Get("INVALID_SOURCE_FILE_NAME"), PascalABCCompiler.StringResources.Get("!ERROR"), MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            if (string.Compare(Path.GetExtension(e.Label), ".pas", true) != 0)
            {
                e.CancelEdit = true;
                MessageBox.Show(Form1StringResources.Get("INVALID_SOURCE_FILE_EXTENSION"), PascalABCCompiler.StringResources.Get("!ERROR"), MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            if (File.Exists(Path.Combine(Path.GetDirectoryName(fi.Name), e.Label)))
            {
                e.CancelEdit = true;
                MessageBox.Show(string.Format(Form1StringResources.Get("FILE_ALREADY_EXISTS{0}"), e.Label), PascalABCCompiler.StringResources.Get("!ERROR"), MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            string oldFileName = fi.Path;

            ProjectFactory.Instance.RenameFile(fi, e.Label);
            if (oldFileName == ProjectFactory.Instance.CurrentProject.MainFile)
            {
                ProjectFactory.Instance.CurrentProject.MainFile = System.IO.Path.Combine(ProjectFactory.Instance.CurrentProject.ProjectDirectory, e.Label);
            }
            WorkbenchServiceFactory.FileService.RenameFile(oldFileName, fi.Path);
            CodeCompletionActionsManager.RenameUnit(fi.Path, Path.GetFileNameWithoutExtension(e.Label));
            string oldFileNameWithoutExt = Path.Combine(Path.GetDirectoryName(oldFileName), Path.GetFileNameWithoutExtension(oldFileName));
            string newFilePath           = Path.Combine(Path.GetDirectoryName(oldFileName), e.Label);

            if (File.Exists(oldFileNameWithoutExt + ".fmabc"))
            {
                string fmabcFullName = Path.Combine(Path.GetDirectoryName(oldFileName), oldFileNameWithoutExt + ".fmabc");
                File.Copy(fmabcFullName, Path.Combine(Path.GetDirectoryName(oldFileName), Path.GetFileNameWithoutExtension(e.Label) + ".fmabc"), true);
                File.Delete(fmabcFullName);
            }
            ProjectFactory.Instance.SaveProject();
            WorkbenchServiceFactory.FileService.SaveAll(false);
            WorkbenchServiceFactory.FileService.CloseFile(newFilePath);
            WorkbenchServiceFactory.FileService.OpenFile(newFilePath, Path.GetFileName(newFilePath));
            WorkbenchServiceFactory.DesignerService.SetActiveDesignerDirty();
            WorkbenchServiceFactory.DesignerService.GenerateAllDesignersCode();

            /*if (File.Exists(oldFileNameWithoutExt + ".resources"))
             * {
             *  string fmabcFullName = Path.Combine(Path.GetDirectoryName(oldFileName), oldFileNameWithoutExt + ".fmabc");
             *  File.Copy(fmabcFullName, Path.Combine(Path.GetDirectoryName(e.Label), Path.GetFileNameWithoutExtension(e.Label) + ".fmabc"), true);
             *  File.Delete(fmabcFullName);
             * }*/
        }
コード例 #2
0
        private void OpenFile()
        {
            object o = items[this.tvProjectExplorer.SelectedNode];

            if (o != null)
            {
                if (o is PascalABCCompiler.IFileInfo)
                {
                    PascalABCCompiler.IFileInfo fi = o as PascalABCCompiler.IFileInfo;
                    WorkbenchServiceFactory.FileService.OpenFile(fi.Path, null);
                }
            }
        }
コード例 #3
0
        public void RenameFile(PascalABCCompiler.IFileInfo fi, string new_name)
        {
            bool hasNsReference = hasNamespaceFileReference(fi.Name);

            if (hasNsReference)
            {
                RemoveNamespaceFileReference(fi.Name);
            }
            fi.Name = new_name;
            Dirty   = true;
            if (hasNsReference)
            {
                AddNamespaceFileReference(fi.Name);
            }
        }
コード例 #4
0
        private void ShowForm()
        {
            object o = items[this.tvProjectExplorer.SelectedNode];

            if (o != null)
            {
                if (o is PascalABCCompiler.IFileInfo)
                {
                    PascalABCCompiler.IFileInfo fi = o as PascalABCCompiler.IFileInfo;
                    WorkbenchServiceFactory.FileService.OpenFile(fi.Path, null);
                    if (VisualPABCSingleton.MainForm.CurrentCodeFileDocument.DesignerAndCodeTabs != null)
                    {
                        VisualPABCSingleton.MainForm.CurrentCodeFileDocument.DesignerAndCodeTabs.SelectedTab =
                            VisualPABCSingleton.MainForm.CurrentCodeFileDocument.DesignerPage;
                    }
                }
            }
        }
コード例 #5
0
        public void AddSourceFile(PascalABCCompiler.IFileInfo fi, bool is_form)
        {
            TreeNode tn = ProjectNode.Nodes.Add(fi.Name);

            tn.ImageIndex         = SourceFileImageIndex;
            tn.SelectedImageIndex = SourceFileImageIndex;
            items[tn]             = fi;
            source_item_nodes.Add(tn);
            if (VisualPABCSingleton.MainForm.IsForm(fi.Path) || is_form)
            {
                tn.ImageIndex         = FormImageIndex;
                tn.SelectedImageIndex = FormImageIndex;
                NodeInfo ni = new NodeInfo();
                ni.IsForm = true;
                tn.Tag    = ni;
            }
            ProjectFactory.Instance.SaveProject();
        }
コード例 #6
0
        //exclude from project
        private void pRJEXCLUDEToolStripMenuItem_Click(object sender, EventArgs e)
        {
            object o = items[this.tvProjectExplorer.SelectedNode];

            if (o != null)
            {
                if (o is PascalABCCompiler.IFileInfo)
                {
                    PascalABCCompiler.IFileInfo fi = o as PascalABCCompiler.IFileInfo;
                    if (ProjectFactory.Instance.CurrentProject.MainFile != fi.Path)
                    {
                        ProjectTask.ExcludeFile(fi);
                        this.tvProjectExplorer.Nodes.Remove(this.tvProjectExplorer.SelectedNode);
                        ProjectFactory.Instance.SaveProject();
                    }
                    else
                    {
                        MessageBox.Show(Form1StringResources.Get("CANNOT_EXCLUDE_MAIN_FILE"), PascalABCCompiler.StringResources.Get("!ERROR"), MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                }
            }
        }
コード例 #7
0
 public void ExcludeFile(PascalABCCompiler.IFileInfo fi)
 {
     currentProject.ExcludeFile(fi);
     Dirty = true;
 }
コード例 #8
0
 public void RenameFile(PascalABCCompiler.IFileInfo fi, string new_name)
 {
     fi.Name = new_name;
     Dirty   = true;
 }