Exemple #1
0
 private void propertiesTreeView_AfterSelect(object sender, TreeViewEventArgs e)
 {
     if (!this.inLoad)
     {
         BindingTreeNode node = e.Node as BindingTreeNode;
         if (node == null)
         {
             this.dataSourcePicker.Binding = null;
             this.bindingLabel.Enabled     = this.dataSourcePicker.Enabled = false;
             this.updateModeLabel.Enabled  = this.bindingUpdateDropDown.Enabled = false;
             this.formatControl1.Enabled   = false;
         }
         else
         {
             this.bindingLabel.Enabled          = this.dataSourcePicker.Enabled = true;
             this.dataSourcePicker.PropertyName = node.Text;
             this.updateModeLabel.Enabled       = this.bindingUpdateDropDown.Enabled = false;
             this.formatControl1.Enabled        = false;
             if (node.Binding != null)
             {
                 this.formatControl1.Enabled    = true;
                 this.formatControl1.FormatType = node.FormatType;
                 FormatControl.FormatTypeClass formatTypeItem = this.formatControl1.FormatTypeItem;
                 this.dataSourcePicker.Binding = node.Binding;
                 formatTypeItem.PushFormatStringIntoFormatType(node.Binding.FormatString);
                 if (node.Binding.NullValue != null)
                 {
                     this.formatControl1.NullValue = node.Binding.NullValue.ToString();
                 }
                 else
                 {
                     this.formatControl1.NullValue = string.Empty;
                 }
                 this.bindingUpdateDropDown.SelectedItem = node.Binding.DataSourceUpdateMode;
                 this.updateModeLabel.Enabled            = this.bindingUpdateDropDown.Enabled = true;
             }
             else
             {
                 bool dirty = this.dirty;
                 this.dataSourcePicker.Binding           = null;
                 this.formatControl1.FormatType          = node.FormatType;
                 this.bindingUpdateDropDown.SelectedItem = this.bindings.DefaultDataSourceUpdateMode;
                 this.formatControl1.NullValue           = null;
                 this.dirty = dirty;
             }
             this.formatControl1.Dirty   = false;
             this.currentBindingTreeNode = node;
         }
     }
 }
Exemple #2
0
 private void dataSourcePicker_PropertyValueChanged(object sender, EventArgs e)
 {
     if (!this.inLoad)
     {
         BindingTreeNode selectedNode = this.propertiesTreeView.SelectedNode as BindingTreeNode;
         if (this.dataSourcePicker.Binding != selectedNode.Binding)
         {
             Binding binding = this.dataSourcePicker.Binding;
             if (binding != null)
             {
                 binding.FormattingEnabled = true;
                 Binding binding2 = selectedNode.Binding;
                 if (binding2 != null)
                 {
                     binding.FormatString = binding2.FormatString;
                     binding.NullValue    = binding2.NullValue;
                     binding.FormatInfo   = binding2.FormatInfo;
                 }
             }
             selectedNode.Binding = binding;
             if (binding != null)
             {
                 this.formatControl1.Enabled             = true;
                 this.updateModeLabel.Enabled            = true;
                 this.bindingUpdateDropDown.Enabled      = true;
                 this.bindingUpdateDropDown.SelectedItem = binding.DataSourceUpdateMode;
                 if (!string.IsNullOrEmpty(this.formatControl1.FormatType))
                 {
                     this.formatControl1.FormatType = this.formatControl1.FormatType;
                 }
                 else
                 {
                     this.formatControl1.FormatType = System.Design.SR.GetString("BindingFormattingDialogFormatTypeNoFormatting");
                 }
             }
             else
             {
                 this.formatControl1.Enabled             = false;
                 this.updateModeLabel.Enabled            = false;
                 this.bindingUpdateDropDown.Enabled      = false;
                 this.bindingUpdateDropDown.SelectedItem = this.bindings.DefaultDataSourceUpdateMode;
                 this.formatControl1.FormatType          = System.Design.SR.GetString("BindingFormattingDialogFormatTypeNoFormatting");
             }
             this.dirty = true;
         }
     }
 }
Exemple #3
0
 private void PushChanges()
 {
     if (this.Dirty)
     {
         IComponentChangeService service           = this.host.GetService(typeof(IComponentChangeService)) as IComponentChangeService;
         PropertyDescriptor      member            = null;
         IBindableComponent      bindableComponent = this.bindings.BindableComponent;
         if ((service != null) && (bindableComponent != null))
         {
             member = TypeDescriptor.GetProperties(bindableComponent)["DataBindings"];
             if (member != null)
             {
                 service.OnComponentChanging(bindableComponent, member);
             }
         }
         this.bindings.Clear();
         TreeNode node = this.propertiesTreeView.Nodes[0];
         for (int i = 0; i < node.Nodes.Count; i++)
         {
             BindingTreeNode node2 = node.Nodes[i] as BindingTreeNode;
             if (node2.Binding != null)
             {
                 this.bindings.Add(node2.Binding);
             }
         }
         TreeNode node3 = this.propertiesTreeView.Nodes[1];
         for (int j = 0; j < node3.Nodes.Count; j++)
         {
             BindingTreeNode node4 = node3.Nodes[j] as BindingTreeNode;
             if (node4.Binding != null)
             {
                 this.bindings.Add(node4.Binding);
             }
         }
         if (((service != null) && (bindableComponent != null)) && (member != null))
         {
             service.OnComponentChanged(bindableComponent, member, null, null);
         }
     }
 }
Exemple #4
0
 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;
     }
 }
Exemple #5
0
 private void BindingFormattingDialog_Closing(object sender, CancelEventArgs e)
 {
     this.currentBindingTreeNode          = null;
     this.dataSourcePicker.OwnerComponent = null;
     this.formatControl1.ResetFormattingInfo();
 }
 private void propertiesTreeView_AfterSelect(object sender, TreeViewEventArgs e)
 {
     if (!this.inLoad)
     {
         BindingTreeNode node = e.Node as BindingTreeNode;
         if (node == null)
         {
             this.dataSourcePicker.Binding = null;
             this.bindingLabel.Enabled = this.dataSourcePicker.Enabled = false;
             this.updateModeLabel.Enabled = this.bindingUpdateDropDown.Enabled = false;
             this.formatControl1.Enabled = false;
         }
         else
         {
             this.bindingLabel.Enabled = this.dataSourcePicker.Enabled = true;
             this.dataSourcePicker.PropertyName = node.Text;
             this.updateModeLabel.Enabled = this.bindingUpdateDropDown.Enabled = false;
             this.formatControl1.Enabled = false;
             if (node.Binding != null)
             {
                 this.formatControl1.Enabled = true;
                 this.formatControl1.FormatType = node.FormatType;
                 FormatControl.FormatTypeClass formatTypeItem = this.formatControl1.FormatTypeItem;
                 this.dataSourcePicker.Binding = node.Binding;
                 formatTypeItem.PushFormatStringIntoFormatType(node.Binding.FormatString);
                 if (node.Binding.NullValue != null)
                 {
                     this.formatControl1.NullValue = node.Binding.NullValue.ToString();
                 }
                 else
                 {
                     this.formatControl1.NullValue = string.Empty;
                 }
                 this.bindingUpdateDropDown.SelectedItem = node.Binding.DataSourceUpdateMode;
                 this.updateModeLabel.Enabled = this.bindingUpdateDropDown.Enabled = true;
             }
             else
             {
                 bool dirty = this.dirty;
                 this.dataSourcePicker.Binding = null;
                 this.formatControl1.FormatType = node.FormatType;
                 this.bindingUpdateDropDown.SelectedItem = this.bindings.DefaultDataSourceUpdateMode;
                 this.formatControl1.NullValue = null;
                 this.dirty = dirty;
             }
             this.formatControl1.Dirty = false;
             this.currentBindingTreeNode = node;
         }
     }
 }
 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;
     }
 }
 private void BindingFormattingDialog_Closing(object sender, CancelEventArgs e)
 {
     this.currentBindingTreeNode = null;
     this.dataSourcePicker.OwnerComponent = null;
     this.formatControl1.ResetFormattingInfo();
 }