Ejemplo n.º 1
0
 public async Task EnsureExpanded(ILibraryItem libraryItem, ContainerTreeNode treeNode)
 {
     if (!treeNode.ContainerAcquired)
     {
         await GetExpansionItems(libraryItem, treeNode).ConfigureAwait(false);
     }
 }
Ejemplo n.º 2
0
        private TreeNode CreateTreeNode(ILibraryItem containerItem, ILibraryContainer parentContainer)
        {
            var treeNode = new ContainerTreeNode(theme, parentContainer)
            {
                Text             = containerItem.Name,
                Tag              = containerItem,
                AlwaysExpandable = true
            };

            ApplicationController.Instance.Library.LoadItemThumbnail(
                (icon) =>
            {
                treeNode.Image = icon.SetPreMultiply();
            },
                null,
                containerItem,
                null,
                20,
                20,
                theme).ConfigureAwait(false);

            treeNode.ExpandedChanged += (s, e) =>
            {
                this.EnsureExpanded(containerItem, treeNode).ConfigureAwait(false);
            };

            return(treeNode);
        }
Ejemplo n.º 3
0
        private async Task GetExpansionItems(ILibraryItem containerItem, ContainerTreeNode treeNode)
        {
            if (containerItem is ILibraryContainerLink containerLink)
            {
                // Prevent invalid assignment of container.Parent due to overlapping load attempts that
                // would otherwise result in containers with self referencing parent properties
                //if (loadingContainerLink != containerLink)
                //{
                //	loadingContainerLink = containerLink;

                try
                {
                    // Container items
                    var container = await containerLink.GetContainer(null);

                    if (container != null)
                    {
                        await Task.Run(() =>
                        {
                            container.Load();
                        });

                        if (treeNode.NodeParent is ContainerTreeNode parentNode)
                        {
                            container.Parent = parentNode.Container;
                        }

                        foreach (var childContainer in container.ChildContainers)
                        {
                            treeNode.Nodes.Add(CreateTreeNode(childContainer));
                        }

                        treeNode.Container = container;

                        treeNode.AlwaysExpandable = treeNode.Nodes.Count > 0;
                        treeNode.Expandable       = treeNode.Nodes.Count > 0;
                        treeNode.Expanded         = treeNode.Nodes.Count > 0;

                        treeNode.Invalidate();

                        //	container.Parent = ActiveContainer;
                        // SetActiveContainer(container);
                    }
                }
                catch { }
                finally
                {
                    // Clear the loading guard and any completed load attempt
                    // loadingContainerLink = null;
                }
            }
        }
Ejemplo n.º 4
0
        private async Task GetExpansionItems(ILibraryItem containerItem, ContainerTreeNode treeNode)
        {
            if (containerItem is ILibraryContainerLink containerLink)
            {
                try
                {
                    // Container items
                    var container = await containerLink.GetContainer(null);

                    if (container != null)
                    {
                        await Task.Run(() =>
                        {
                            container.Load();
                        });

                        if (treeNode is ContainerTreeNode containerNode)
                        {
                            container.Parent = containerNode.ParentContainer;
                        }

                        foreach (var childContainer in container.ChildContainers)
                        {
                            treeNode.Nodes.Add(CreateTreeNode(childContainer, container));
                        }

                        treeNode.Container = container;

                        treeNode.AlwaysExpandable = treeNode.Nodes.Count > 0;
                        treeNode.Expandable       = treeNode.Nodes.Count > 0;
                        treeNode.Expanded         = treeNode.Nodes.Count > 0;

                        treeNode.Invalidate();
                    }
                }
                catch { }
            }
        }