示例#1
0
        public void CreateNewProject(string path, string name)
        {
            MainForm mainForm = FindForm() as MainForm;

            if (mainForm == null || mainForm.SettingsModel == null)
            {
                return;
            }

            path = Path.GetFullPath(path);
            string wrkdir = mainForm.SettingsModel.SdkPath + @"\templates";

            Newtonsoft.Json.Linq.JObject args = new Newtonsoft.Json.Linq.JObject();
            args["inputPath"]  = wrkdir;
            args["outputPath"] = path;
            args["name"]       = name;
            if (TemplateFilesManager.ProcessTemplates("resources/settings/MakeNewProject.json", args) && Directory.Exists(path))
            {
                ProjectModel projectModel = new ProjectModel(name + ".cbp");
                projectModel.WorkingDirectory = Path.GetDirectoryName(path);
                projectModel.UpdateFromCbp();
                string json = JsonConvert.SerializeObject(projectModel, Formatting.Indented);
                File.WriteAllText(path + @"\project.zasuvka", json);
                OpenProject(path + @"\project.zasuvka");
            }
        }
        private void CreateNewAsset(string path, string name)
        {
            MainForm mainForm = FindForm() as MainForm;

            if (mainForm == null || mainForm.SettingsModel == null || mainForm.ProjectModel == null)
            {
                return;
            }

            path = Path.GetFullPath(path);
            string wrkdir = mainForm.SettingsModel.SdkPath + @"\templates";

            Newtonsoft.Json.Linq.JObject args = new Newtonsoft.Json.Linq.JObject();
            args["inputPath"]  = wrkdir;
            args["outputPath"] = path;
            args["name"]       = name;
            args["nameUpper"]  = name.ToUpperInvariant();
            if (TemplateFilesManager.ProcessTemplates("resources/settings/MakeNewAsset.json", args))
            {
                string cppPath = path + @"\" + name + ".cpp";
                string hPath   = path + @"\" + name + ".h";
                mainForm.ProjectModel.Files.Add(cppPath);
                mainForm.ProjectModel.Files.Add(hPath);
                mainForm.ProjectModel.ApplyToCbp(mainForm.SettingsModel);
                if (File.Exists(hPath))
                {
                    DialogResult result = MetroMessageBox.Show(mainForm, "Open created asset code file?", "Open asset to edit", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
                    if (result == DialogResult.Yes)
                    {
                        mainForm.OpenEditFile(hPath);
                    }
                }
            }
        }
        private void UpdateMainCpp()
        {
            MainForm mainForm = FindForm() as MainForm;

            if (mainForm == null || mainForm.SettingsModel == null || mainForm.ProjectModel == null)
            {
                return;
            }

            string path   = mainForm.ProjectModel.WorkingDirectory;
            string name   = mainForm.ProjectModel.Name;
            string wrkdir = mainForm.SettingsModel.SdkPath + @"\templates";

            Newtonsoft.Json.Linq.JObject args = new Newtonsoft.Json.Linq.JObject();
            args["inputPath"]  = wrkdir;
            args["outputPath"] = path;
            args["name"]       = name;
            TemplateFilesManager.ProcessTemplates("resources/settings/UpdateMainCpp.json", args);
        }