Beispiel #1
0
        public static bool CreateProject(string project, string projectPath)
        {
            if (projectPath == null)
            {
                projectPath = Paths.Base;
            }
            if (project == null)
            {
                if (!Configuration.SetProjectNameByConsole())
                {
                    return(false);
                }
                if (!Configuration.GetProjectName(ref project))
                {
                    return(false);
                }
            }
            else
            {
                if (!Configuration.SetProjectName(project))
                {
                    return(false);
                }
            }
            if (!Verify.Name(ref project, ref projectPath))
            {
                return(false);
            }
            projectPath += "\\" + project;
            Paths.Base   = projectPath;
            Directory.CreateDirectory(projectPath);
            if (!Configuration.CreateConfigurationFile(project))
            {
                return(false);
            }
            Configuration.SaveFile();
            string excel = project;

            Excel.AddMacroEnabledExtension(ref excel);
            Structure.CreateFolders();
            Structure.CreateDefaultFiles();
            if (!Excel.CreateExcelFile($"{projectPath}\\{excel}", VBE.CustomUI.Default))
            {
                return(false);
            }
            Console.WriteLine("Project Ready!");
            return(true);
        }
Beispiel #2
0
 public static bool AddCustomUI(bool exe, bool ignore, string excel, string excelPath, string customUI, string customUIPath)
 {
     if (exe || ignore)
     {
         excel ??= Excel.DefaultExcelFileName;
         customUI ??= CustomUI.FileDefaultName;
         excelPath ??= Project.Paths.Base;
         customUIPath ??= exe && !ignore ? Executable.Paths.VBE.CustomUI : Project.Paths.VBE.CustomUI;
         Excel.AddMacroEnabledExtension(ref excel);
         if (!Verify.Name(ref excel, ref excelPath))
         {
             return(false);
         }
     }
     else
     {
         customUIPath ??= Paths.VBE.CustomUI;
         excelPath ??= Paths.Base;
         if (Configuration.FileExists())
         {
             Configuration.LoadFile();
             if (excel == null)
             {
                 if (!Configuration.GetProjectName(ref excel))
                 {
                     return(false);
                 }
             }
             Excel.AddMacroEnabledExtension(ref excel);
             if (customUI == null)
             {
                 if (!Configuration.GetCustomUIDefaultName(ref customUI))
                 {
                     return(false);
                 }
             }
             if (!Verify.Name(ref excel, ref excelPath))
             {
                 return(false);
             }
             Directory.CreateDirectory(excelPath);
         }
         else
         {
             customUI ??= CustomUI.FileDefaultName;
             if (!Configuration.SetCustomUIDefaultName(customUI))
             {
                 return(false);
             }
             if (excel == null)
             {
                 if (!Configuration.SetProjectNameByConsole())
                 {
                     return(false);
                 }
                 if (!Configuration.GetProjectName(ref excel))
                 {
                     return(false);
                 }
             }
             else
             {
                 if (!Configuration.SetProjectName(excel))
                 {
                     return(false);
                 }
             }
             Excel.AddMacroEnabledExtension(ref excel);
             if (!Verify.Name(ref excel, ref excelPath))
             {
                 return(false);
             }
             Paths.Base = excelPath;
             Directory.CreateDirectory(excelPath);
             if (!Configuration.CreateConfigurationFile(excel))
             {
                 return(false);
             }
             Configuration.SaveFile();
         }
     }
     if (customUI != null)
     {
         CustomUI.AddXmlExtension(ref customUI);
     }
     if (!Verify.Name(ref customUI, ref customUIPath))
     {
         return(false);
     }
     if (!CustomUI.FileExists($"{customUIPath}\\{customUI}"))
     {
         return(false);
     }
     if (!Excel.FileExists($"{excelPath}\\{excel}"))
     {
         return(false);
     }
     if (!CustomUI.AddCustomUI($"{excelPath}\\{excel}", $"{customUIPath}\\{customUI}"))
     {
         return(false);
     }
     return(true);
 }