public CustomViewColumnNode(CustomViewColumnController controller) : base(controller) { }
public override void Refresh() { try { if ((this.TreeView != null) && (this.TreeView.InvokeRequired)) { this.TreeView.Invoke(new EmptyDelegate(this.Refresh)); return; } this.Text = "Fields"; this.Name = "Fields"; this.ImageIndex = ImageHelper.GetImageIndex(TreeIconConstants.FolderClose); this.SelectedImageIndex = ImageHelper.GetImageIndex(TreeIconConstants.FolderOpen); //Add new nodes var referenceCollection = (ReferenceCollection)this.Object; //Save the selected item var selectedKey = string.Empty; if ((this.TreeView != null) && (this.TreeView.SelectedNode != null) && (this.Nodes.Contains(this.TreeView.SelectedNode))) { var reference = referenceCollection.GetByKey(this.TreeView.SelectedNode.Name); if (reference != null) { selectedKey = ((CustomViewColumn)reference.Object).Key; } } foreach (Reference reference in referenceCollection) { if (this.Nodes.Find(reference.Key, false).Length == 0) { var tc = new CustomViewColumnController(reference.Object); tc.Node.Name = reference.Key; tc.Node.Text = ((CustomViewColumn)reference.Object).Name; this.Nodes.Add(tc.Node); } } //Rename nodes if name change foreach (TreeNode node in this.Nodes) { var item = referenceCollection.FirstOrDefault(x => x.Key == node.Name); if (item != null) { node.Text = ((CustomViewColumn)item.Object).Name; } } //Remove non-existing nodes for (var ii = this.Nodes.Count - 1; ii >= 0; ii--) { var node = (CustomViewColumnNode)this.Nodes[ii]; if (!referenceCollection.Contains(node.Name)) { this.Nodes.RemoveAt(ii); } } //Save the selected item if ((this.TreeView != null) && (!string.IsNullOrEmpty(selectedKey))) { foreach (TreeNode node in this.Nodes) { var reference = referenceCollection.GetByKey(node.Name); if ((reference != null) && (selectedKey == ((CustomViewColumn)reference.Object).Key)) { this.TreeView.SelectedNode = node; } } } this.Sort(); this.Controller.UIControl.Refresh(); } catch (Exception ex) { throw; } }
public override void Refresh() { try { if((this.TreeView != null) && (this.TreeView.InvokeRequired)) { this.TreeView.Invoke(new EmptyDelegate(this.Refresh)); return; } this.Text = "Fields"; this.Name = "Fields"; this.ImageIndex = ImageHelper.GetImageIndex(TreeIconConstants.FolderClose); this.SelectedImageIndex = ImageHelper.GetImageIndex(TreeIconConstants.FolderOpen); //Add new nodes var referenceCollection = (ReferenceCollection)this.Object; //Save the selected item var selectedKey = string.Empty; if((this.TreeView != null) && (this.TreeView.SelectedNode != null) && (this.Nodes.Contains(this.TreeView.SelectedNode))) { var reference = referenceCollection.GetByKey(this.TreeView.SelectedNode.Name); if(reference != null) selectedKey = ((CustomViewColumn)reference.Object).Key; } foreach(Reference reference in referenceCollection) { if(this.Nodes.Find(reference.Key, false).Length == 0) { var tc = new CustomViewColumnController(reference.Object); tc.Node.Name = reference.Key; tc.Node.Text = ((CustomViewColumn)reference.Object).Name; this.Nodes.Add(tc.Node); } } //Rename nodes if name change foreach (TreeNode node in this.Nodes) { var item = referenceCollection.FirstOrDefault(x => x.Key == node.Name); if (item != null) node.Text = ((CustomViewColumn)item.Object).Name; } //Remove non-existing nodes for(var ii = this.Nodes.Count - 1 ; ii >= 0 ; ii--) { var node = (CustomViewColumnNode)this.Nodes[ii]; if(!referenceCollection.Contains(node.Name)) { this.Nodes.RemoveAt(ii); } } //Save the selected item if((this.TreeView != null) && (!string.IsNullOrEmpty(selectedKey))) { foreach(TreeNode node in this.Nodes) { var reference = referenceCollection.GetByKey(node.Name); if((reference != null) && (selectedKey == ((CustomViewColumn)reference.Object).Key)) this.TreeView.SelectedNode = node; } } this.Sort(); this.Controller.UIControl.Refresh(); } catch(Exception ex) { throw; } }