public override void Refresh() { if ((this.TreeView != null) && (this.TreeView.InvokeRequired)) { this.TreeView.Invoke(new EmptyDelegate(this.Refresh)); return; } this.Text = "Custom Aggregate"; this.Name = "Custom Aggregates"; this.ImageIndex = ImageHelper.GetImageIndex(TreeIconConstants.CustomView); this.SelectedImageIndex = this.ImageIndex; var customAggregateCollection = (CustomAggregateCollection)this.Object; //Add new nodes foreach (CustomAggregate customAggregate in customAggregateCollection) { if (this.Nodes.Find(customAggregate.Key, false).Length == 0) { var tc = new CustomAggregateController(customAggregate); tc.Node.Name = customAggregate.Key; tc.Node.Text = customAggregate.Name; this.Nodes.Add(tc.Node); } } //Rename nodes if name change foreach (TreeNode node in this.Nodes) { var item = customAggregateCollection.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 = (CustomAggregateNode)this.Nodes[ii]; if (!customAggregateCollection.Contains(node.Text)) { this.Nodes.RemoveAt(ii); } } this.Sort(); this.Controller.UIControl.Refresh(); }
public override void Refresh() { if((this.TreeView != null) && (this.TreeView.InvokeRequired)) { this.TreeView.Invoke(new EmptyDelegate(this.Refresh)); return; } this.Text = "Custom Aggregate"; this.Name = "Custom Aggregates"; this.ImageIndex = ImageHelper.GetImageIndex(TreeIconConstants.CustomView); this.SelectedImageIndex = this.ImageIndex; var customAggregateCollection = (CustomAggregateCollection)this.Object; //Add new nodes foreach(CustomAggregate customAggregate in customAggregateCollection) { if(this.Nodes.Find(customAggregate.Key, false).Length == 0) { var tc = new CustomAggregateController(customAggregate); tc.Node.Name = customAggregate.Key; tc.Node.Text = customAggregate.Name; this.Nodes.Add(tc.Node); } } //Rename nodes if name change foreach (TreeNode node in this.Nodes) { var item = customAggregateCollection.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 = (CustomAggregateNode)this.Nodes[ii]; if(!customAggregateCollection.Contains(node.Text)) { this.Nodes.RemoveAt(ii); } } this.Sort(); this.Controller.UIControl.Refresh(); }
//protected ModelObjectTreeNode mRelationCollectionNode = null; #endregion #region Constructor public CustomAggregateNode(CustomAggregateController controller) : base(controller) { }