Пример #1
0
		/// <summary>
		/// Creates a new project based on the specified template directory.
		/// </summary>
		public Project CreateProject(string templateDirectory, string projectLocation, string projectName, string packageName)
		{
            isRunning = true;
            if (!projectTypesSet) SetInitialProjectHash();
			this.projectName = projectName;
            this.packageName = packageName;
            projectId = Regex.Replace(Project.RemoveDiacritics(projectName), "[^a-z0-9]", "", RegexOptions.IgnoreCase);
            packagePath = packageName.Replace('.', '\\');
            if (packageName.Length > 0)
            {
                packageDot = packageName + ".";
                packageSlash = packagePath + "\\";
            }
            string projectTemplate = FindProjectTemplate(templateDirectory);
            string projectPath = Path.Combine(projectLocation, projectName + Path.GetExtension(projectTemplate));
            projectPath = PathHelper.GetPhysicalPathName(projectPath);
            // notify & let a plugin handle project creation
            Hashtable para = new Hashtable();
            para["template"] = projectTemplate;
            para["location"] = projectLocation;
            para["project"] = projectPath;
            para["id"] = projectId;
            para["package"] = packageName;
            DataEvent de = new DataEvent(EventType.Command, ProjectManagerEvents.CreateProject, para);
            EventManager.DispatchEvent(this, de);
            if (!de.Handled)
            {
                int addArgs = 1;
                arguments = new Argument[PluginBase.MainForm.Settings.CustomArguments.Count + addArgs];
                arguments[0] = new Argument("FlexSDK", PluginBase.MainForm.ProcessArgString("$(FlexSDK)"));
                PluginBase.MainForm.Settings.CustomArguments.CopyTo(arguments, addArgs);
                Directory.CreateDirectory(projectLocation);
                // manually copy important files
                CopyFile(projectTemplate, projectPath);
                CopyProjectFiles(templateDirectory, projectLocation, true);
            }
            isRunning = false;
            if (File.Exists(projectPath))
            {
                projectPath = PathHelper.GetPhysicalPathName(projectPath);
                de = new DataEvent(EventType.Command, ProjectManagerEvents.ProjectCreated, para);
                EventManager.DispatchEvent(this, de);
                return ProjectLoader.Load(projectPath);
            }
            else return null;
		}
Пример #2
0
 /// <summary>
 /// Adds a new empty argument
 /// </summary>
 private void AddButtonClick(Object sender, EventArgs e)
 {
     Argument argument = new Argument();
     ListViewItem item = new ListViewItem();
     String message = TextHelper.GetString("Info.Argument");
     String undefined = TextHelper.GetString("Info.Undefined");
     item.ImageIndex = 0; argument.Key = undefined;
     item.Text = message + " $(" + undefined + ")";
     this.argsListView.Items.Add(item);
     this.argumentGroup.Items.Add(item);
     foreach (ListViewItem other in this.argsListView.Items)
     {
         other.Selected = false;
     }
     item.Tag = argument;
     item.Selected = true;
     arguments.Add(argument);
 }