public TreeNodeCollectionForm(CollectionEditor editor) : base(editor) { this.editor = (TreeNodeCollectionEditor)editor; this.InitializeComponent(); this.HookEvents(); this.intialNextNode = this.NextNode; this.SetButtonsState(); DesignerUtils.ApplyTreeViewThemeStyles(this.treeView1); }
private void BindingFormattingDialog_Load(object sender, EventArgs e) { this.inLoad = true; try { BindingTreeNode node6; this.dirty = false; Font defaultFont = Control.DefaultFont; IUIService service = null; if (this.bindings.BindableComponent.Site != null) { service = (IUIService)this.bindings.BindableComponent.Site.GetService(typeof(IUIService)); } if (service != null) { defaultFont = (Font)service.Styles["DialogFont"]; } this.Font = defaultFont; DesignerUtils.ApplyTreeViewThemeStyles(this.propertiesTreeView); if (this.propertiesTreeView.ImageList == null) { ImageList list = new ImageList(); list.Images.Add(BoundBitmap); list.Images.Add(UnboundBitmap); this.propertiesTreeView.ImageList = list; } BindingTreeNode node = null; BindingTreeNode node2 = null; string name = null; string str2 = null; foreach (Attribute attribute in TypeDescriptor.GetAttributes(this.bindings.BindableComponent)) { if (attribute is DefaultBindingPropertyAttribute) { name = ((DefaultBindingPropertyAttribute)attribute).Name; break; } if (attribute is DefaultPropertyAttribute) { str2 = ((DefaultPropertyAttribute)attribute).Name; } } this.propertiesTreeView.Nodes.Clear(); TreeNode node3 = new TreeNode(System.Design.SR.GetString("BindingFormattingDialogCommonTreeNode")); TreeNode node4 = new TreeNode(System.Design.SR.GetString("BindingFormattingDialogAllTreeNode")); this.propertiesTreeView.Nodes.Add(node3); this.propertiesTreeView.Nodes.Add(node4); PropertyDescriptorCollection properties = TypeDescriptor.GetProperties(this.bindings.BindableComponent); for (int i = 0; i < properties.Count; i++) { if (!properties[i].IsReadOnly) { BindableAttribute attribute2 = (BindableAttribute)properties[i].Attributes[typeof(BindableAttribute)]; BrowsableAttribute attribute3 = (BrowsableAttribute)properties[i].Attributes[typeof(BrowsableAttribute)]; if (((attribute3 == null) || attribute3.Browsable) || ((attribute2 != null) && attribute2.Bindable)) { BindingTreeNode node5 = new BindingTreeNode(properties[i].Name) { Binding = this.FindBinding(properties[i].Name) }; if (node5.Binding != null) { node5.FormatType = FormatControl.FormatTypeStringFromFormatString(node5.Binding.FormatString); } else { node5.FormatType = System.Design.SR.GetString("BindingFormattingDialogFormatTypeNoFormatting"); } if ((attribute2 != null) && attribute2.Bindable) { node3.Nodes.Add(node5); } else { node4.Nodes.Add(node5); } if (((node == null) && !string.IsNullOrEmpty(name)) && (string.Compare(properties[i].Name, name, false, CultureInfo.CurrentCulture) == 0)) { node = node5; } else if (((node2 == null) && !string.IsNullOrEmpty(str2)) && (string.Compare(properties[i].Name, str2, false, CultureInfo.CurrentCulture) == 0)) { node2 = node5; } } } } node3.Expand(); node4.Expand(); this.propertiesTreeView.Sort(); if (node != null) { node6 = node; } else if (node2 != null) { node6 = node2; } else if (node3.Nodes.Count > 0) { node6 = FirstNodeInAlphabeticalOrder(node3.Nodes) as BindingTreeNode; } else if (node4.Nodes.Count > 0) { node6 = FirstNodeInAlphabeticalOrder(node4.Nodes) as BindingTreeNode; } else { node6 = null; } this.propertiesTreeView.SelectedNode = node6; if (node6 != null) { node6.EnsureVisible(); } this.dataSourcePicker.PropertyName = node6.Text; this.dataSourcePicker.Binding = (node6 != null) ? node6.Binding : null; this.dataSourcePicker.Enabled = true; this.dataSourcePicker.OwnerComponent = this.bindings.BindableComponent; this.dataSourcePicker.DefaultDataSourceUpdateMode = this.bindings.DefaultDataSourceUpdateMode; if ((node6 != null) && (node6.Binding != null)) { this.bindingUpdateDropDown.Enabled = true; this.bindingUpdateDropDown.SelectedItem = node6.Binding.DataSourceUpdateMode; this.updateModeLabel.Enabled = true; this.formatControl1.Enabled = true; this.formatControl1.FormatType = node6.FormatType; this.formatControl1.FormatTypeItem.PushFormatStringIntoFormatType(node6.Binding.FormatString); if (node6.Binding.NullValue != null) { this.formatControl1.NullValue = node6.Binding.NullValue.ToString(); } else { this.formatControl1.NullValue = string.Empty; } } else { this.bindingUpdateDropDown.Enabled = false; this.bindingUpdateDropDown.SelectedItem = this.bindings.DefaultDataSourceUpdateMode; this.updateModeLabel.Enabled = false; this.formatControl1.Enabled = false; this.formatControl1.FormatType = string.Empty; } this.formatControl1.Dirty = false; this.currentBindingTreeNode = this.propertiesTreeView.SelectedNode as BindingTreeNode; } finally { this.inLoad = false; } }