Пример #1
0
        /// <summary>
        /// Imports a delphi Main file (DPR or DPK) into the project that has no Main file
        /// the path of the current visual studio project must exist.
        /// </summary>
        /// <param name="aDelphiMainFile">Full path of existing main file</param>
        public virtual void ImportDelphiMainFile(string aDelphiMainFile)
        {
            if (!File.Exists(aDelphiMainFile))
            {
                return;
            }
            // change to drectory where the main file exists.
            Environment.CurrentDirectory = Path.GetDirectoryName(Path.GetFullPath(aDelphiMainFile));
            // copy the file
            string lNewFile = Path.Combine(Path.GetDirectoryName(this.Url), Path.GetFileName(aDelphiMainFile));

            if (!NativeMethods.IsSamePath(aDelphiMainFile, lNewFile))
            {
                System.IO.File.Copy(aDelphiMainFile, lNewFile, true);
            }
            // TODO: this should be changed to Main file node
            // create DelphiDPRFileNode that is not attached to project
            DelphiMainFileNode lFileNode = (DelphiMainFileNode)this.CreateFileNode(lNewFile);

            // copy contained files - {%File 'filename'}
            CopyFilesToVSProject(lFileNode.GetContainedFiles(), this, false);
            // copy unit files - Unit1 in 'unit1.pas'
            CopyFilesToVSProject(lFileNode.GetUnitFiles(), this, true);
            // copy directive files - {$R 'filename'} or {$I 'filename'}
            CopyFilesToVSProject(lFileNode.GetDirectiveFiles(), lFileNode, false);

            /* Removed from project (WorkItem 8808) I may want to read them for settings though?
             * string[] lSettingFiles = new string[2];
             * lSettingFiles[0] = Path.GetFileNameWithoutExtension(aDelphiMainFile) + ".cfg";
             * lSettingFiles[1] = Path.GetFileNameWithoutExtension(aDelphiMainFile) + ".dof";
             * CopyFilesToVSProject(lSettingFiles, lFileNode, false);
             */
            lFileNode.Close();
            lFileNode = null;
        }
Пример #2
0
        private void AfterFileRenameEvent(DelphiFileNode aDelphiFileNode, string aOldUnitName, string aNewUnitName)
        {
            DelphiMainFileNode lNode = GetDelphiMainFileNode();

            if (lNode != null)
            {
                if (!lNode.IsDelphiFile(aOldUnitName))
                {
                    lNode.RenameContainedFile(aOldUnitName, aNewUnitName);
                }
            }
        }
Пример #3
0
        /// <summary>
        /// Renames the delphi project files
        /// </summary>
        /// <param name="newFile">The full path of the new project file.</param>
        protected override void RenameProjectFile(string newFile)
        {
            base.RenameProjectFile(newFile);

            DelphiMainFileNode lDelphiPrj = GetDelphiMainFileNode();

            if (lDelphiPrj != null)
            {
                string lDPRFileName = Path.GetFileNameWithoutExtension(this.FileName) + Path.GetExtension(lDelphiPrj.FileName);
                lDelphiPrj.SetEditLabel(lDPRFileName);
            }
        }
Пример #4
0
        public virtual DelphiMainFileNode GetDelphiMainFileNode()
        {
            DelphiMainFileNode result = null;

            for (HierarchyNode child = this.FirstChild; child != null; child = child.NextSibling)
            {
                result = child as DelphiMainFileNode;
                if (result != null)
                {
                    return(result);
                }
            }
            return(result);
        }
Пример #5
0
 /// <summary>
 /// I don't want the reference node so I will not add it I may want to fix this.
 /// </summary>
 /// <param name="node"></param>
 public override void AddChild(HierarchyNode node)
 {
     // do not add more than one TDelphiDPRFileNode!
     if (node is DelphiMainFileNode)
     {
         if (FDelphiMainFileNode != null)
         {
             return;
         }
         FDelphiMainFileNode = node as DelphiMainFileNode;
     }
     if (!String.IsNullOrEmpty(node.VirtualNodeName) && String.Compare(node.VirtualNodeName, ReferenceContainerNode.ReferencesNodeVirtualName, StringComparison.OrdinalIgnoreCase) == 0)
     {
         // ReferenceNode found do not add!
     }
     else
     {
         base.AddChild(node);
     }
 }