public static void AddProject(ISolutionFolderNode solutionFolderNode, IProject newProject)
 {
     if (newProject != null)
     {
         newProject.Location = FileUtility.GetRelativePath(solutionFolderNode.Solution.Directory, newProject.FileName);
         ProjectService.AddProject(solutionFolderNode, newProject);
         NodeBuilders.AddProjectNode((TreeNode)solutionFolderNode, newProject).EnsureVisible();
         solutionFolderNode.Solution.ApplySolutionConfigurationAndPlatformToProjects();
     }
 }
Example #2
0
        /// <summary>
        /// Open the given file.
        /// </summary>
        internal void Open(string path)
        {
            if (source != null)
            {
                source.Dispose();
            }
            source       = null;
            originalPath = path;
            try
            {
                treeView.BeginUpdate();
                treeView.Nodes.Clear();
                mainContainer.Panel2.Controls.Clear();

                source = SourceFile.Open(path, this);
                foreach (var fileName in source.FileNames.OrderBy(x => x))
                {
                    var parent = treeView.Nodes.GetParentForFile(Path.GetDirectoryName(fileName), 1, new[] { '/', '\\' });
                    parent.Add(NodeBuilders.Create(source, fileName));
                }

                foreach (Node node in treeView.Nodes)
                {
                    node.EnsureChildNodesCreated();
                }

                //treeView.Sort();
                Text = string.Format("{0} - [{1}]", Application.ProductName, path);

                // Add to MRU
                SettingsPersitor.Add(path);

                // Try to re-open last known tree path
                TreePath = SettingsPersitor.LastTreePath;
            }
            catch (Exception ex)
            {
                var msg = string.Format("Open file {0} failed: {1}", path, ex.Message);
                MessageBox.Show(msg, Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Error);
                ErrorLog.DumpError(ex);
            }
            finally
            {
                treeView.EndUpdate();
            }
        }