private void OnBindablePropsTreeAfterSelect(object sender, TreeViewEventArgs e) { BindablePropertyNode selectedNode = (BindablePropertyNode)this._bindablePropsTree.SelectedNode; if (this._currentNode != selectedNode) { this._currentNode = selectedNode; if ((this._currentNode != null) && this._currentNode.IsBound) { ExpressionBinding binding = this._currentNode.Binding; if (!this._currentNode.IsGenerated) { ExpressionEditor editor = (ExpressionEditor)this._expressionEditors[binding.ExpressionPrefix]; if (editor == null) { UIServiceHelper.ShowMessage(base.ServiceProvider, System.Design.SR.GetString("ExpressionBindingsDialog_UndefinedExpressionPrefix", new object[] { binding.ExpressionPrefix }), System.Design.SR.GetString("ExpressionBindingsDialog_Text", new object[] { this.Control.Site.Name }), MessageBoxButtons.OK); editor = new GenericExpressionEditor(); } this._currentEditor = editor; this._currentSheet = this._currentEditor.GetExpressionEditorSheet(binding.Expression, base.ServiceProvider); this._internalChange = true; try { foreach (ExpressionItem item in this._expressionBuilderComboBox.Items) { if (string.Equals(item.ToString(), binding.ExpressionPrefix, StringComparison.OrdinalIgnoreCase)) { this._expressionBuilderComboBox.SelectedItem = item; } } this._currentNode.IsValid = this._currentSheet.IsValid; } finally { this._internalChange = false; } } } else { this._expressionBuilderComboBox.SelectedItem = this.NoneItem; this._currentEditor = null; this._currentSheet = null; } this._expressionBuilderPropertyGrid.SelectedObject = this._currentSheet; this.UpdateUIState(); } }
private void OnBindablePropsTreeAfterSelect(object sender, TreeViewEventArgs e) { BindablePropertyNode selectedNode = (BindablePropertyNode) this._bindablePropsTree.SelectedNode; if (this._currentNode != selectedNode) { this._currentNode = selectedNode; if ((this._currentNode != null) && this._currentNode.IsBound) { ExpressionBinding binding = this._currentNode.Binding; if (!this._currentNode.IsGenerated) { ExpressionEditor editor = (ExpressionEditor) this._expressionEditors[binding.ExpressionPrefix]; if (editor == null) { UIServiceHelper.ShowMessage(base.ServiceProvider, System.Design.SR.GetString("ExpressionBindingsDialog_UndefinedExpressionPrefix", new object[] { binding.ExpressionPrefix }), System.Design.SR.GetString("ExpressionBindingsDialog_Text", new object[] { this.Control.Site.Name }), MessageBoxButtons.OK); editor = new GenericExpressionEditor(); } this._currentEditor = editor; this._currentSheet = this._currentEditor.GetExpressionEditorSheet(binding.Expression, base.ServiceProvider); this._internalChange = true; try { foreach (ExpressionItem item in this._expressionBuilderComboBox.Items) { if (string.Equals(item.ToString(), binding.ExpressionPrefix, StringComparison.OrdinalIgnoreCase)) { this._expressionBuilderComboBox.SelectedItem = item; } } this._currentNode.IsValid = this._currentSheet.IsValid; } finally { this._internalChange = false; } } } else { this._expressionBuilderComboBox.SelectedItem = this.NoneItem; this._currentEditor = null; this._currentSheet = null; } this._expressionBuilderPropertyGrid.SelectedObject = this._currentSheet; this.UpdateUIState(); } }
private void LoadBindableProperties() { PropertyDescriptorCollection properties = TypeDescriptor.GetProperties(this.Control, BindablePropertiesFilter); string name = null; PropertyDescriptor defaultProperty = TypeDescriptor.GetDefaultProperty(this.Control); if (defaultProperty != null) { name = defaultProperty.Name; } TreeNodeCollection nodes = this._bindablePropsTree.Nodes; ExpressionBindingCollection expressions = ((IExpressionsAccessor) this.Control).Expressions; Hashtable hashtable = new Hashtable(StringComparer.OrdinalIgnoreCase); foreach (ExpressionBinding binding in expressions) { hashtable[binding.PropertyName] = binding; } TreeNode node = null; foreach (PropertyDescriptor descriptor2 in properties) { if (string.Compare(descriptor2.Name, "ID", StringComparison.OrdinalIgnoreCase) != 0) { ExpressionBinding binding2 = null; if (hashtable.Contains(descriptor2.Name)) { binding2 = (ExpressionBinding) hashtable[descriptor2.Name]; hashtable.Remove(descriptor2.Name); } TreeNode node2 = new BindablePropertyNode(descriptor2, binding2); if (descriptor2.Name.Equals(name, StringComparison.OrdinalIgnoreCase)) { node = node2; } nodes.Add(node2); } } this._complexBindings = hashtable; if ((node == null) && (nodes.Count != 0)) { int count = nodes.Count; for (int i = 0; i < count; i++) { BindablePropertyNode node3 = (BindablePropertyNode) nodes[i]; if (node3.IsBound) { node = node3; break; } } if (node == null) { node = nodes[0]; } } if (node != null) { this._bindablePropsTree.SelectedNode = node; } }
private void OnBindablePropsTreeAfterSelect(object sender, TreeViewEventArgs e) { if (this._currentDataBindingDirty) { this.SaveCurrentDataBinding(); } this._currentDataBinding = null; this._currentNode = (BindablePropertyNode) this._bindablePropsTree.SelectedNode; if (this._currentNode != null) { this._currentDataBinding = (DesignTimeDataBinding) this._bindings[this._currentNode.PropertyDescriptor.Name]; } this.LoadCurrentDataBinding(); }
private void LoadBindableProperties(bool showAll) { string text = string.Empty; if (this._bindablePropsTree.SelectedNode != null) { text = this._bindablePropsTree.SelectedNode.Text; } this._bindablePropsTree.Nodes.Clear(); PropertyDescriptorCollection properties = TypeDescriptor.GetProperties(this.Control.GetType(), BindablePropertiesFilter); if (showAll) { PropertyDescriptorCollection descriptors2 = TypeDescriptor.GetProperties(this.Control.GetType(), BrowsablePropertiesFilter); if ((descriptors2 != null) && (descriptors2.Count > 0)) { int count = properties.Count; int num2 = descriptors2.Count; PropertyDescriptor[] array = new PropertyDescriptor[count + num2]; properties.CopyTo(array, 0); int length = count; foreach (PropertyDescriptor descriptor in descriptors2) { if (!properties.Contains(descriptor) && !string.Equals(descriptor.Name, "id", StringComparison.OrdinalIgnoreCase)) { array[length++] = descriptor; } } PropertyDescriptor[] destinationArray = new PropertyDescriptor[length]; Array.Copy(array, destinationArray, length); properties = new PropertyDescriptorCollection(destinationArray); } } string name = null; ControlValuePropertyAttribute attribute = TypeDescriptor.GetAttributes(this.Control)[typeof(ControlValuePropertyAttribute)] as ControlValuePropertyAttribute; if (attribute != null) { name = attribute.Name; } else { PropertyDescriptor defaultProperty = TypeDescriptor.GetDefaultProperty(this.Control); if (defaultProperty != null) { name = defaultProperty.Name; } } TreeNodeCollection nodes = this._bindablePropsTree.Nodes; TreeNode node = null; TreeNode node2 = null; this._bindablePropsTree.BeginUpdate(); foreach (PropertyDescriptor descriptor3 in properties) { bool flag = this._bindings[descriptor3.Name] != null; BindingMode notSet = BindingMode.NotSet; if (flag) { if (((DesignTimeDataBinding) this._bindings[descriptor3.Name]).IsTwoWayBound) { notSet = BindingMode.TwoWay; } else { notSet = BindingMode.OneWay; } } TreeNode node3 = new BindablePropertyNode(descriptor3, notSet); if (descriptor3.Name.Equals(name)) { node = node3; } if (descriptor3.Name.Equals(text)) { node2 = node3; } nodes.Add(node3); } this._bindablePropsTree.EndUpdate(); if (((node2 == null) && (node == null)) && (nodes.Count != 0)) { int num4 = nodes.Count; for (int i = 0; i < num4; i++) { BindablePropertyNode node4 = (BindablePropertyNode) nodes[i]; if (node4.IsBound) { node2 = node4; break; } } if (node2 == null) { node2 = nodes[0]; } } if (node2 != null) { this._bindablePropsTree.SelectedNode = node2; } else if (node != null) { this._bindablePropsTree.SelectedNode = node; } this.UpdateUIState(); }
private void LoadBindableProperties() { PropertyDescriptorCollection properties = TypeDescriptor.GetProperties(this.Control, BindablePropertiesFilter); string name = null; PropertyDescriptor defaultProperty = TypeDescriptor.GetDefaultProperty(this.Control); if (defaultProperty != null) { name = defaultProperty.Name; } TreeNodeCollection nodes = this._bindablePropsTree.Nodes; ExpressionBindingCollection expressions = ((IExpressionsAccessor)this.Control).Expressions; Hashtable hashtable = new Hashtable(StringComparer.OrdinalIgnoreCase); foreach (ExpressionBinding binding in expressions) { hashtable[binding.PropertyName] = binding; } TreeNode node = null; foreach (PropertyDescriptor descriptor2 in properties) { if (string.Compare(descriptor2.Name, "ID", StringComparison.OrdinalIgnoreCase) != 0) { ExpressionBinding binding2 = null; if (hashtable.Contains(descriptor2.Name)) { binding2 = (ExpressionBinding)hashtable[descriptor2.Name]; hashtable.Remove(descriptor2.Name); } TreeNode node2 = new BindablePropertyNode(descriptor2, binding2); if (descriptor2.Name.Equals(name, StringComparison.OrdinalIgnoreCase)) { node = node2; } nodes.Add(node2); } } this._complexBindings = hashtable; if ((node == null) && (nodes.Count != 0)) { int count = nodes.Count; for (int i = 0; i < count; i++) { BindablePropertyNode node3 = (BindablePropertyNode)nodes[i]; if (node3.IsBound) { node = node3; break; } } if (node == null) { node = nodes[0]; } } if (node != null) { this._bindablePropsTree.SelectedNode = node; } }