public void Close(Project[] projs)
        {
            ServiceHost.Error.ClearErrors(null);

            foreach (Project proj in projs)
            {
                projects.Remove(proj.ProjectName);

                proj.Close();
                Remove(proj);

                if (proj.Startup && startupproject == null)
                {
                    startupproject = null;
                }

                if (Closed != null)
                {
                    Closed(proj, EventArgs.Empty);
                }

                try
                {
                    outlineview.Nodes.Remove(proj.RootNode);
                }
                catch (ObjectDisposedException)
                {
                    //silly docking thing...
                }
            }
        }
        internal void AddNewProject()
        {
            Wizard wiz = new Wizard();

            ArrayList keys = new ArrayList(projtypes.Keys);

            keys.Sort(TypeComparer.Default);

            foreach (Type prj in keys)
            {
                wiz.prjtype.Items.Add(prj);
            }

            if (wiz.ShowDialog(ServiceHost.Window.MainForm) == DialogResult.OK)
            {
                Project prj = wiz.Tag as Project;

                Add(prj);
                prj.ProjectCreated();
                prj.OnOpened();

                if (Opened != null)
                {
                    Opened(prj, EventArgs.Empty);
                }
            }
        }
        //BuildProject solution;

        public Project Create(Type prjtype, string name, string rootdir)
        {
            Project proj = new Project();

            proj.RootDirectory = rootdir;
            proj.Location      = rootdir + Path.DirectorySeparatorChar + name + ".proj";
            proj.ProjectName   = name;

            proj.ProjectCreated();

            return(proj);
        }
 void ProjectManagerEvent(object sender, EventArgs e)
 {
     if (projects.Count == 0)
     {
         current            = null;
         startupproject     = null;
         ServiceHost.State &= ~ApplicationState.Project;
     }
     else
     {
         ServiceHost.State |= ApplicationState.Project;
     }
 }
        public Project AddProject(Type prjtype, string name, string rootdir)
        {
            Project proj = Activator.CreateInstance(prjtype) as Project;

            proj.RootDirectory = rootdir;
            proj.Location      = rootdir + Path.DirectorySeparatorChar + name + ".proj";
            proj.ProjectName   = name;

            proj.ProjectCreated();

            Add(proj);

            return(proj);
        }
Exemple #6
0
        void RemoveFile(object sender, EventArgs e)
        {
            BuildItem file = (SelectedNode.Tag) as BuildItem;

            if (file != null)
            {
                if (DialogResult.OK == MessageBox.Show(this, "Remove '" + file + "' from project?",
                                                       "Confirmation", MessageBoxButtons.OKCancel))
                {
                    Project proj = ServiceHost.Project.Current;
                    SelectedNode.Remove();
                    proj.RemoveFile(file.Include);
                }
            }
        }
 public void Add(Project prj)
 {
     if (ProjectNameExists(prj.ProjectName))
     {
         prj.ProjectName += "_new";
     }
     projects.Add(prj);
     if (current != null)
     {
         prj.Location = current.Location;
     }
     else
     {
         current = prj;
     }
 }
Exemple #8
0
        void ChangeAction(object sender, EventArgs e)
        {
            BuildItem file   = SelectedNode.Tag as BuildItem;
            string    action = (sender as ToolStripMenuItem).Text as string;

            Project proj = ServiceHost.Project.Current;

            proj.RemoveFile(file.Include);

            if (SelectedNode.Nodes.Count == 0)
            {
                SelectedNode.Remove();
            }

            proj.AddFile(file.Include, action, true);
        }
        public void Remove(Project prj)
        {
            projects.Remove(prj);

            BuildProject sol = (ServiceHost.Build as BuildService).solution;

            if (sol != null && prj.SolBuildItem != null)
            {
                sol.RemoveItem(prj.SolBuildItem);
            }
            if (prj == current)
            {
                current = projects.Count > 0 ? projects[0] as Project : null;
            }
            if (prj == startupproject)
            {
                startupproject = null;
            }
        }
        internal void Create()
        {
            //show wizard thingy
            Wizard wiz = new Wizard();

            ArrayList keys = new ArrayList(projtypes.Keys);

            keys.Sort(TypeComparer.Default);

            foreach (Type prj in keys)
            {
                wiz.prjtype.Items.Add(prj);
            }

            if (wiz.ShowDialog(ServiceHost.Window.MainForm) == DialogResult.OK)
            {
                Project p = wiz.Tag as Project;
                p.Startup = true;
                Add(p);
                CloseAll();

                Open(p.Location);
            }
        }
        public Project[] Open(string prjfile)
        {
            prjfile = Path.GetFullPath(prjfile);

            if (!File.Exists(prjfile))
            {
                return(null);
            }

            Environment.CurrentDirectory = Path.GetDirectoryName(prjfile);

            foreach (MRUFile mru in recentfiles)
            {
                if (string.Compare(mru.filename, prjfile, true) == 0)
                {
                    mru.Update();
                    goto DONE;
                }
            }
            recentfiles.Add(new MRUFile(prjfile));

DONE:

            string ext = Path.GetExtension(prjfile);

            if (ext == ".xaccproj")
            {
                BuildService bm = ServiceHost.Build as BuildService;
                bm.solution = new Microsoft.Build.BuildEngine.Project();
                bm.solution.Load(prjfile);

                bm.solution.GlobalProperties["SolutionDir"] = new BuildProperty("SolutionDir", Path.GetDirectoryName(prjfile) + Path.DirectorySeparatorChar);


                ArrayList projects = new ArrayList();

                foreach (BuildItem prj in bm.solution.GetEvaluatedItemsByName("BuildProject"))
                {
                    Environment.CurrentDirectory = Path.GetDirectoryName(prjfile);

                    Project bp = new Project();

                    bp.SolBuildItem = prj;

                    bp.Load(prj.Include);

                    //bp.SolutionDir = Path.GetDirectoryName(prjfile) + Path.DirectorySeparatorChar;
                    bp.ProjectCreated();
                    Add(bp);
                    bp.OnOpened();

                    projects.Add(bp);

                    if (Opened != null)
                    {
                        Opened(bp, EventArgs.Empty);
                    }
                }

                if (File.Exists(Path.ChangeExtension(prjfile, ".xaccdata")))
                {
                    ServiceHost.Window.Document.Load(Path.ChangeExtension(prjfile, ".xaccdata"));
                }
                else
                {
                    ProjectTab.Show();
                }
                return(projects.ToArray(typeof(Project)) as Project[]);
            }
            else if (ext.EndsWith("proj"))
            {
                Project bp = new Project();

                bp.Load(prjfile);

                bp.MSBuildProject.GlobalProperties["SolutionDir"] = new BuildProperty("SolutionDir", Path.GetDirectoryName(prjfile) + Path.DirectorySeparatorChar);

                bp.ProjectCreated();
                Add(bp);
                bp.OnOpened();

                if (Opened != null)
                {
                    Opened(bp, EventArgs.Empty);
                }
                ProjectTab.Show();

                return(new Project[] { bp });
            }
            else if (ext == ".sln")
            {
                BuildService bm = ServiceHost.Build as BuildService;
                bm.solution = new Microsoft.Build.BuildEngine.Project();

                bm.solution.GlobalProperties["SolutionDir"] = new BuildProperty("SolutionDir", Path.GetDirectoryName(prjfile) + Path.DirectorySeparatorChar);

                using (TextReader r = new StreamReader(prjfile, Encoding.Default, true))
                {
                    string all = r.ReadToEnd();

                    foreach (Match m in SLNPARSE.Matches(all))
                    {
                        string name = m.Groups["name"].Value;
                        if (name == "Solution Items")
                        {
                            continue;
                        }
                        string location = m.Groups["location"].Value;

                        if (File.Exists(Path.Combine(Path.GetDirectoryName(prjfile), location)))
                        {
                            bm.solution.AddNewItem("BuildProject", location);
                        }
                    }
                }

                bm.solution.AddNewImport(Path.Combine(Application.StartupPath, "xacc.imports"), "");

                bm.solution.Save(Path.ChangeExtension(prjfile, ".xaccproj"));

                ArrayList projects = new ArrayList();

                foreach (BuildItem prj in bm.solution.GetEvaluatedItemsByName("BuildProject"))
                {
                    Environment.CurrentDirectory = Path.GetDirectoryName(prjfile);

                    Project bp = new Project();

                    bp.Load(prj.Include);
                    bp.SolBuildItem = prj;
                    bp.ProjectCreated();

                    //bp.SolutionDir = Path.GetDirectoryName(prjfile) + Path.DirectorySeparatorChar;

                    Add(bp);
                    bp.OnOpened();

                    projects.Add(bp);

                    if (Opened != null)
                    {
                        Opened(bp, EventArgs.Empty);
                    }
                }
                ServiceHost.State |= ApplicationState.Project;
                ProjectTab.Show();

                return(projects.ToArray(typeof(Project)) as Project[]);
            }
            else
            {
                return(null);
            }
        }
 public void RemoveProject(Project proj)
 {
     Remove(proj);
 }
Exemple #13
0
        protected override void OnMouseUp(MouseEventArgs e)
        {
            if (e.Button == MouseButtons.Right)
            {
                if (SelectedNode == null)
                {
                    return;
                }

                ContextMenuStrip cm = new ContextMenuStrip();

                object tag = SelectedNode.Tag;

                if (tag is Project)
                {
                    Project p = tag as Project;

                    IMenuService ms = ServiceHost.Menu;

                    ToolStripMenuItem pm = ms["Project"];

                    foreach (ToolStripItem mi in pm.DropDownItems)
                    {
                        if (mi is ToolStripSeparator)
                        {
                            cm.Items.Add(new ToolStripSeparator());
                        }
                        else
                        {
                            cm.Items.Add(((ToolStripMenuItem)mi).Clone());
                        }
                    }
                }
                else if (tag is BuildItem)
                {
                    ToolStripMenuItem pmi = new ToolStripMenuItem("Remove", null,
                                                                  new EventHandler(RemoveFile));


                    IImageListProviderService ims = ServiceHost.ImageListProvider;

                    cm.ImageList = ims.ImageList;

                    _RemoveFile rf = new _RemoveFile();
                    rf.value       = tag;
                    pmi.ImageIndex = ims[rf];
                    cm.Items.Add(pmi);

                    cm.Items.Add(new ToolStripSeparator());

                    pmi = new ToolStripMenuItem("Action");
                    cm.Items.Add(pmi);

                    Project proj = ServiceHost.Project.Current;

                    foreach (string action in proj.Actions)
                    {
                        ToolStripMenuItem am = new ToolStripMenuItem(action, null, new EventHandler(ChangeAction));
                        pmi.DropDownItems.Add(am);

                        string dd = (tag as BuildItem).Name;
                        if (dd == action)
                        {
                            am.Checked = true;
                        }
                    }
                }

                cm.Show(this, new Point(e.X, e.Y));
            }
            base.OnMouseUp(e);
        }