Ejemplo n.º 1
0
        void UpdateTree(SolutionBuilder sln, SolutionFileView v, TreeNode _Solution, TreeNode _Project)
        {
            _Solution.Text = "Solution '" + sln.Name + "' (1 project)";
            _Solution.IsExpanded = true;

            _Solution.WithIcon(() => new SolutionTwentyTen());

            _Project.Text = sln.Name;
            _Project.IsExpanded = true;

            // Or my project?

            var PropertiesFolderName = "Properties";
            if (sln.Language == KnownLanguages.VisualBasic)
                PropertiesFolderName = "My Project";

            var _Properties = _Project.Add(PropertiesFolderName);
            _Properties.IsExpanded = true;
            _Properties.WithIcon(() => new SolutionProjectProperties());

            var _References = _Project.Add("References");
            _References.IsExpanded = false;
            _References.WithIcon(() => new References());


            RenderReferences(sln, _References);


            var FolderLookup = new Dictionary<string, TreeNode>();
            var FileLookup = new Dictionary<SolutionFile, TreeNode>();

            FolderLookup[_Properties.Text] = _Properties;




            var files = sln.ToFiles();

            files.WithEach(
                f =>
                {
                    var ProjectInclude = f.Name.SkipUntilIfAny("/").SkipUntilIfAny("/");

                    var Folder = ProjectInclude.TakeUntilLastOrEmpty("/");

                    if (!string.IsNullOrEmpty(Folder))
                    {
                        if (!FolderLookup.ContainsKey(Folder))
                        {
                            var _Folder = _Project.Add(Folder);
                            FolderLookup[Folder] = _Folder;
                            _Folder.IsExpanded = true;
                        }
                    }
                }
            );

            files.WithEach(
                (SolutionFile f) =>
                {
                    var n = default(TreeNode);

                    var Extension = "." + f.Name.SkipUntilLastIfAny(".");

                    if (Extension == ".sln")
                    {
                        n = _Solution;
                    }
                    else if (Extension == sln.Language.ProjectFileExtension)
                    {
                        n = _Project;

                        n.Element.TextArea.style.fontWeight = "bold";
                    }
                    else
                    {
                        var ProjectInclude = f.Name.SkipUntilIfAny("/").SkipUntilIfAny("/");

                        var Folder = ProjectInclude.TakeUntilLastOrEmpty("/");

                        var Parent = _Project;

                        if (!string.IsNullOrEmpty(Folder))
                        {
                            Parent = FolderLookup[Folder];
                        }

                        if (sln.Language.SupportsDependentUpon())
                            if (f.DependentUpon != null)
                            {
                                Parent = FileLookup[f.DependentUpon];
                                Parent.IsExpanded = false;
                            }

                        n = Parent.Add(ProjectInclude.SkipUntilLastIfAny("/"));

                        FileLookup[f] = n;
                    }

                    if (Extension == KnownLanguages.VisualCSharp.CodeFileExtension)
                        n.WithIcon(() => new VisualCSharpCode());
                    else if (Extension == KnownLanguages.VisualCSharp.ProjectFileExtension)
                        n.WithIcon(() => new VisualCSharpProject());
                    else if (Extension == KnownLanguages.VisualBasic.CodeFileExtension)
                        n.WithIcon(() => new VisualBasicCode());
                    else if (Extension == KnownLanguages.VisualBasic.ProjectFileExtension)
                        n.WithIcon(() => new VisualBasicProject());
                    else if (Extension == KnownLanguages.VisualFSharp.CodeFileExtension)
                        n.WithIcon(() => new VisualFSharpCode());
                    else if (Extension == KnownLanguages.VisualFSharp.ProjectFileExtension)
                        n.WithIcon(() => new VisualFSharpProject());
                    else if (Extension == ".htm")
                        n.WithIcon(() => new HTMLDocument());
                    else if (Extension == ".config")
                        n.WithIcon(() => new ScriptCoreLib.Ultra.Components.HTML.Images.FromAssets.HTMLDocument());
                    else if (Extension == ".css")
                        n.WithIcon(() => new StyleSheetFile());

                    if (f.ContextType != null)
                    {
                        if (f.ContextType.BaseType != null)
                        {
                            if (f.ContextType.BaseType is KnownStockTypes.System.Windows.Forms.UserControl)
                                n.WithIcon(() => new SolutionProjectFormsControl());
                            if (f.ContextType.BaseType is KnownStockTypes.System.ComponentModel.Component)
                                n.WithIcon(() => new SolutionProjectComponentImage());
                        }
                    }

                    if (sln.Language.SupportsDependentUpon())
                        if (f.DependentUpon != null)
                        {
                            n.WithIcon(() => new SolutionProjectDependentUpon());
                        }

                    n.IsExpanded = true;


                    n.Click +=
                        delegate
                        {
                            v.File = f;
                        };

                    // somebody refreshed the solution.
                    if (v.File == null)
                    {
                        if (f.Name.SkipUntilLastIfAny("/").TakeUntilLastIfAny(".") == "Application")
                            v.File = f;
                    }
                    else
                    {
                        // we may not care about the file extensions, will we see a glitch? :)
                        if (v.File.Name.SkipUntilLastIfAny("/").TakeUntilLastIfAny(".") == f.Name.SkipUntilLastIfAny("/").TakeUntilLastIfAny("."))
                            v.File = f;
                    }
                }
            );

            if (this.Save != null)
            {
                this.Save.Clear();
                this.Save.FileName = sln.Name + ".sln.zip";
                files.WithEach(f => this.Save.Add(f.Name, f.Content));
            }
        }
Ejemplo n.º 2
0
		private static void UpdateTree(SolutionBuilder sln, SolutionFileView v, TreeNode _Solution, TreeNode _Project)
		{
			_Solution.Text = "Solution '" + sln.Name + "' (1 project)";
			_Solution.IsExpanded = true;

			_Solution.WithIcon(() => new SolutionTwentyTen());

			_Project.Text = sln.Name;
			_Project.IsExpanded = true;

			// Or my project?
			var _Properties = _Project.Add("Properties");
			_Properties.IsExpanded = true;
			_Properties.WithIcon(() => new SolutionProjectProperties());

			var _References = _Project.Add("References");
			_References.IsExpanded = false;
			_References.WithIcon(() => new References());


			foreach (var item in sln.References.ToArray())
			{
				var _Reference = _References.Add(item.Attribute("Include").Value.TakeUntilIfAny(","));
				_Reference.IsExpanded = true;
				_Reference.WithIcon(() => new Assembly());
			}


			var FolderLookup = new Dictionary<string, TreeNode>();
			var FileLookup = new Dictionary<SolutionFile, TreeNode>();

			FolderLookup[_Properties.Text] = _Properties;




			var files = sln.ToFiles();

			files.WithEach(
				f =>
				{
					var ProjectInclude = f.Name.SkipUntilIfAny("/").SkipUntilIfAny("/");

					var Folder = ProjectInclude.TakeUntilLastOrEmpty("/");

					if (!string.IsNullOrEmpty(Folder))
					{
						if (!FolderLookup.ContainsKey(Folder))
							FolderLookup[Folder] = _Project.Add(Folder);
					}
				}
			);

			files.WithEach(
				(SolutionFile f) =>
				{
					var n = default(TreeNode);

					var Extension = "." + f.Name.SkipUntilLastIfAny(".");

					if (Extension == ".sln")
					{
						n = _Solution;
					}
					else if (Extension == sln.Language.ProjectFileExtension)
					{
						n = _Project;

						n.Element.TextArea.style.fontWeight = "bold";
					}
					else
					{
						var ProjectInclude = f.Name.SkipUntilIfAny("/").SkipUntilIfAny("/");

						var Folder = ProjectInclude.TakeUntilLastOrEmpty("/");

						var Parent = _Project;

						if (!string.IsNullOrEmpty(Folder))
						{
							Parent = FolderLookup[Folder];
						}

						if (f.DependentUpon != null)
						{
							Parent = FileLookup[f.DependentUpon];
							Parent.IsExpanded = false;
						}

						n = Parent.Add(ProjectInclude.SkipUntilLastIfAny("/"));

						FileLookup[f] = n;
					}

					if (Extension == ".cs")
						n.WithIcon(() => new VisualCSharpCode());
					else if (Extension == ".csproj")
						n.WithIcon(() => new VisualCSharpProject());
					else if (Extension == ".vb")
						n.WithIcon(() => new VisualBasicCode());
					else if (Extension == ".vbproj")
						n.WithIcon(() => new VisualBasicProject());
					else if (Extension == ".fs")
						n.WithIcon(() => new VisualFSharpCode());
					else if (Extension == ".fsproj")
						n.WithIcon(() => new VisualFSharpProject());
					else if (Extension == ".htm")
						n.WithIcon(() => new HTMLDocument());

					if (f.DependentUpon != null)
					{
						n.WithIcon(() => new SolutionProjectDependentUpon());
					}

					n.IsExpanded = true;

					n.Click +=
						delegate
						{
							v.File = f;
						};

					// somebody refreshed the solution.
					if (v.File == null)
					{
						if (f.Name.SkipUntilLastIfAny("/").TakeUntilLastIfAny(".") == "Application")
							v.File = f;
					}
					else
					{
						// we may not care about the file extensions, will we see a glitch? :)
						if (v.File.Name.SkipUntilLastIfAny("/").TakeUntilLastIfAny(".") == f.Name.SkipUntilLastIfAny("/").TakeUntilLastIfAny("."))
							v.File = f;
					}
				}
			);
		}