示例#1
0
        /// <summary>
        /// Verifies a project has unsaved files and warns.
        /// </summary>
        /// <param name="project">Project</param>
        /// <param name="warningMessageTitle">Message title</param>
        /// <returns>true if it has, false if not.</returns>
        public static bool WarnForUnsavedFiles(IOTAProject project, string warningMessageTitle)
        {
            if (project == null)
            {
                return false;
            }

            IOTAModuleServices _ModuleServices = GetModuleServices();
            if (_ModuleServices == null)
            {
                return false;
            }

            for (int k = 0; k < project.ModuleCount; k++)
            {
                IOTAModuleInfo _ModuleInfo = project.GetModuleInfo(k);

                IOTAModule _Module = _ModuleServices.FindModule(_ModuleInfo.FileName);

                if (_Module != null)
                {

                    IOTAEditor _Editor = GetEditorWithSourceEditor(_Module);

                    if (_Editor != null && _Editor.IsModified)
                    {
                        if (Lextm.Windows.Forms.MessageBoxFactory.Confirm(null, "The project contains unsaved files", "Do you still want to compile the project?") == DialogResult.No)
                        {
                            return true;
                        }
                    }
                }
            }
            return false;
        }
示例#2
0
        /// <summary>
        /// Gets module info from project.
        /// </summary>
        /// <param name="project">Project</param>
        /// <param name="fileName">File name</param>
        /// <returns>The module info, or null.</returns>
        public static IOTAModuleInfo GetModuleInfoFromProject(IOTAProject project, string fileName)
        {
            for (int i = 0; i < project.ModuleCount; i++)
            {
                if (project.GetModuleInfo(i).FileName == fileName)
                {
                    return project.GetModuleInfo(i);
                }
            }

            return null;
        }
示例#3
0
        /// <summary>
        /// Gets project source file list.
        /// </summary>
        /// <param name="project">Project</param>
        /// <returns></returns>
        public static IList<string> GetProjectSourceFiles(IOTAProject project)
        {
            IList<string> result = new List<string>();
            if (project == null)
            {
                return result;
            }

            for (int i = 0; i < project.ModuleCount; i++)
            {
                IOTAModuleInfo _ModuleInfo = project.GetModuleInfo(i);

                if (IsSourceFile(_ModuleInfo.FileName))
                {
                    result.Add(_ModuleInfo.FileName);
                }
            }
            return result;
        }
示例#4
0
 /// <summary>
 /// Gets all module info of a project.
 /// </summary>
 /// <param name="project">Project</param>
 /// <returns></returns>
 /// <remarks>The real project file (*.dpr or *.dpk) is added, too.</remarks>
 public static IList<IOTAModuleInfo> GetAllModuleInfoOf(IOTAProject project)
 {
     if (project == null || project.ModuleCount == 0)
     {
         return null;
     }
     IList<IOTAModuleInfo> result = new List<IOTAModuleInfo>();
     for (int i = 0; i < project.ModuleCount; i++)
     {
         IOTAModuleInfo info = project.GetModuleInfo(i);
         result.Add(info);
     }
     if (IsDelphiProject(project))
     {
         string projectFile = OtaUtils.GetDelphiProjectFileName(project.FileName);
         if (File.Exists(projectFile))
         {
             result.Add(new DelphiProjectModuleInfo(projectFile));
         }
     }
     return result;
 }