public override void Refresh() { if ((this.TreeView != null) && (this.TreeView.InvokeRequired)) { this.TreeView.Invoke(new EmptyDelegate(this.Refresh)); return; } this.Text = "Packages"; this.Name = "Packages"; this.ImageIndex = ImageHelper.GetImageIndex(TreeIconConstants.Packages); this.SelectedImageIndex = this.ImageIndex; var packageCollection = (PackageCollection)this.Object; //Add new nodes foreach (Package package in packageCollection) { if (this.Nodes.Find(package.Key, false).Length == 0) { var tc = new PackageController(package); tc.Node.Name = package.Key; tc.Node.Text = package.Name; this.Nodes.Add(tc.Node); } } //Rename nodes if name change foreach (TreeNode node in this.Nodes) { var item = packageCollection.FirstOrDefault(x => x.Key == node.Name); if ((item != null) && (node.Text != item.Name)) node.Text = item.Name; } //Remove non-existing nodes for (var ii = this.Nodes.Count - 1; ii >= 0; ii--) { var node = (PackageNode)this.Nodes[ii]; if (!packageCollection.Contains(node.Text)) { this.Nodes.RemoveAt(ii); } } this.Sort(); this.Controller.UIControl.Refresh(); }
//protected ModelObjectTreeNode mRelationCollectionNode = null; #endregion #region Constructor public PackageNode(PackageController controller) : base(controller) { }