Example #1
0
 public void AddNewStaticFile()
 {
     if (ArchAngel.Interfaces.SharedData.CurrentProject.TemplateProject.IsOfficial)
     {
         if (MessageBox.Show(this, "Changes can't be made to built-in templates. Do you want to save-as a custom template?", "Built-in template", MessageBoxButtons.YesNo, MessageBoxIcon.Exclamation) == DialogResult.Yes)
         {
             SaveAs();
         }
         return;
     }
     try
     {
         if (treeFiles.SelectedNodes.Count == 0)
         {
             MessageBox.Show(this, "Select a folder to add this file to first.", "No Folder Selected", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
             return;
         }
         else if (treeFiles.SelectedNodes.Count > 1)
         {
             throw new Exception("Only one node should be selected.");
         }
         Cursor = Cursors.WaitCursor;
         Refresh();
         Node selectedNode = treeFiles.SelectedNodes[0];
         ArchAngel.Interfaces.Template.Folder parentFolder = (ArchAngel.Interfaces.Template.Folder)selectedNode.Tag;
         ArchAngel.Interfaces.Template.StaticFile newFile = new ArchAngel.Interfaces.Template.StaticFile()
         {
             Id = ArchAngel.Interfaces.SharedData.CurrentProject.TemplateProject.GetNextAvailableStaticFileId(),
             Name = "NewFile",
             Iterator = ArchAngel.Interfaces.Template.IteratorTypes.None,
             ParentFolder = parentFolder
         };
         parentFolder.StaticFiles.Add(newFile);
         CreateNewStaticFileAndAddToTree(selectedNode, newFile);
         syntaxEditorFilename.Focus();
     }
     finally
     {
         Controller.Instance.MainForm.Activate();
         Cursor = Cursors.Default;
     }
 }
Example #2
0
        private void mnuAddManyStaticFiles_Click(object sender, EventArgs e)
        {
            if (ArchAngel.Interfaces.SharedData.CurrentProject.TemplateProject.IsOfficial)
            {
                if (MessageBox.Show(this, "Changes can't be made to built-in templates. Do you want to save-as a custom template?", "Built-in template", MessageBoxButtons.YesNo, MessageBoxIcon.Exclamation) == DialogResult.Yes)
                {
                    SaveAs();
                }
                return;
            }
            FormStaticFiles form = new FormStaticFiles();

            if (form.ShowDialog(this) == DialogResult.OK)
            {
                Node selectedNode = treeFiles.SelectedNodes[0];
                ArchAngel.Interfaces.Template.Folder parentFolder = (ArchAngel.Interfaces.Template.Folder)selectedNode.Tag;

                treeFiles.BeginUpdate();

                foreach (var name in form.ResourceNames)
                {
                    ArchAngel.Interfaces.Template.StaticFile newFile = new ArchAngel.Interfaces.Template.StaticFile()
                    {
                        Id = ArchAngel.Interfaces.SharedData.CurrentProject.TemplateProject.GetNextAvailableStaticFileId(),
                        Name = name,
                        Iterator = ArchAngel.Interfaces.Template.IteratorTypes.None,
                        ParentFolder = parentFolder,
                        ResourceName = name
                    };
                    parentFolder.StaticFiles.Add(newFile);
                    AddStaticFileNode(selectedNode, newFile);
                }
                treeFiles.EndUpdate();
                syntaxEditorFilename.Focus();
            }
        }