示例#1
0
        protected override void ComposeTree(TreeComposer composer)
        {
            composer.Element("library-body", body: () =>
            {
                composer.Element("library-title", body: () =>
                {
                    composer.Element("icon", body: () => Micro.FontAwesome(composer, this.Library.ExplorerIcon));
                    composer.Element("name", body: () => composer.Text(this.Library.Name));
                });

                composer.Element("library-description", body: () => composer.Text(this.Library.Description));

                if (this.Library.Methods.Any())
                {
                    composer.Element("group-title", body: () =>
                    {
                        composer.Element("icon", body: () => Micro.FontAwesome(composer, "cube"));
                        composer.Element("name", body: () => composer.Text(EditorResources.LibraryExplorer_Methods));
                    });

                    foreach (var method in this.Library.Methods.Values)
                    {
                        LibraryMethod.Inject(
                            composer,
                            isSelected: method == this.selectedMethod,
                            library: this.Library,
                            method: method,
                            onHeaderClick: () => this.OnMethodHeaderClick(method));
                    }
                }

                if (this.Library.Properties.Any())
                {
                    composer.Element("group-title", body: () =>
                    {
                        composer.Element("icon", body: () => Micro.FontAwesome(composer, "wrench"));
                        composer.Element("name", body: () => composer.Text(EditorResources.LibraryExplorer_Properties));
                    });

                    foreach (var property in this.Library.Properties.Values)
                    {
                        composer.Element("member", body: () =>
                        {
                            composer.Element(name: "member-header-selected", body: () =>
                            {
                                composer.Element("member-title", body: () =>
                                {
                                    composer.Element("caret");
                                    composer.Element("name", body: () => composer.Text($"{this.Library.Name}.{property.Name}"));
                                });

                                composer.Element("member-description", body: () => composer.Text(property.Description));
                            });
                        });
                    }
                }

                if (this.Library.Events.Any())
                {
                    composer.Element("group-title", body: () =>
                    {
                        composer.Element("icon", body: () => Micro.FontAwesome(composer, "neuter"));
                        composer.Element("name", body: () => composer.Text(EditorResources.LibraryExplorer_Events));
                    });

                    foreach (var @event in this.Library.Events.Values)
                    {
                        composer.Element("member", body: () =>
                        {
                            composer.Element(name: "member-header-selected", body: () =>
                            {
                                composer.Element("member-title", body: () =>
                                {
                                    composer.Element("caret");
                                    composer.Element("name", body: () => composer.Text($"{this.Library.Name}.{@event.Name}"));
                                });

                                composer.Element("member-description", body: () => composer.Text(@event.Description));
                            });
                        });
                    }
                }
            });
        }
示例#2
0
            protected override void ComposeTree(TreeComposer composer)
            {
                composer.Element("member", body: () =>
                {
                    composer.Element(
                        name: this.IsSelected ? "member-header-selected" : "member-header",
                        events: new TreeComposer.Events
                    {
                        OnClick = arg => this.OnHeaderClick()
                    },
                        body: () =>
                    {
                        composer.Element("member-title", body: () =>
                        {
                            composer.Element("caret", body: () =>
                            {
                                Micro.FontAwesome(composer, this.IsSelected ? "caret-down" : "caret-right");
                            });

                            composer.Element("name", body: () => composer.Text($"{this.Library.Name}.{this.Method.Name}()"));
                        });

                        composer.Element("member-description", body: () => composer.Text(this.Method.Description));
                    });

                    if (this.IsSelected)
                    {
                        composer.Element("member-body", body: () =>
                        {
                            composer.Element("example", body: () =>
                            {
                                composer.Text(string.Format(
                                                  CultureInfo.CurrentCulture,
                                                  "{0}{1}.{2}({3})",
                                                  this.Method.ReturnsValue ? "result = " : string.Empty,
                                                  this.Library.Name,
                                                  this.Method.Name,
                                                  this.Method.Parameters.Keys.Join(", ")));
                            });

                            if (this.Method.Parameters.Any())
                            {
                                composer.Element("block", body: () =>
                                {
                                    composer.Element("arguments-area", body: () =>
                                    {
                                        foreach (var parameter in this.Method.Parameters.Values)
                                        {
                                            composer.Element("name", body: () => composer.Text(parameter.Name));
                                            composer.Element("description", body: () => composer.Text(parameter.Description));
                                        }
                                    });
                                });
                            }

                            composer.Element("block", body: () =>
                            {
                                composer.Element("result-area", body: () =>
                                {
                                    if (this.Method.ReturnsValue)
                                    {
                                        composer.Element("name", body: () => composer.Text("result"));
                                        composer.Element("description", body: () => composer.Text(this.Method.ReturnValueDescription));
                                    }
                                    else
                                    {
                                        composer.Element("description", body: () => composer.Text(EditorResources.LibraryExplorer_ReturnsNothing));
                                    }
                                });
                            });
                        });
                    }
                });
            }