Exemple #1
0
        protected override void LoadChildren()
        {
            if (!this.loadingChildren && this.children != null && this.children.Count == 1 && this.children.ContainsKey(string.Empty))
            {
                string FullJid = this.Concentrator?.FullJid;

                if (!string.IsNullOrEmpty(FullJid))
                {
                    Mouse.OverrideCursor = Cursors.Wait;

                    if (this.hasChildSources)
                    {
                        this.loadingChildren = true;
                        Concentrator.XmppAccountNode.ConcentratorClient.GetChildDataSources(FullJid, this.key, (sender, e) =>
                        {
                            this.loadingChildren = false;
                            MainWindow.MouseDefault();

                            if (e.Ok)
                            {
                                SortedDictionary <string, TreeNode> Children = new SortedDictionary <string, TreeNode>();

                                foreach (DataSourceReference Ref in e.DataSources)
                                {
                                    DataSource DataSource  = new DataSource(this, Ref.SourceID, Ref.SourceID, Ref.HasChildren);
                                    Children[Ref.SourceID] = DataSource;

                                    DataSource.SubscribeToEvents();
                                }

                                this.children = Children;

                                this.OnUpdated();
                                this.Concentrator?.NodesAdded(Children.Values, this);
                            }
                        }, null);
                    }
                    else
                    {
                        this.loadingChildren = true;
                        Concentrator.XmppAccountNode.ConcentratorClient.GetRootNodes(FullJid, this.key, true, true,
                                                                                     "en", string.Empty, string.Empty, string.Empty, (sender, e) =>
                        {
                            this.loadingChildren = false;
                            MainWindow.MouseDefault();

                            if (e.Ok)
                            {
                                SortedDictionary <string, TreeNode> Children = new SortedDictionary <string, TreeNode>();

                                foreach (NodeInformation Ref in e.NodesInformation)
                                {
                                    Children[Ref.NodeId] = new Node(this, Ref);
                                }

                                this.children = Children;

                                this.OnUpdated();
                                this.NodesAdded(Children.Values, this);
                            }
                        }, null);
                    }
                }
            }

            base.LoadChildren();
        }