Пример #1
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;
                }
            }
        }
Пример #2
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 { }
            }
        }