public override object EditValue(ITypeDescriptorContext context, IServiceProvider provider, object value)
 {
     if (((provider != null) && (context != null)) && (context.Instance != null))
     {
         DataGridColumnStyle instance = (DataGridColumnStyle) context.Instance;
         if ((instance.DataGridTableStyle == null) || (instance.DataGridTableStyle.DataGrid == null))
         {
             return value;
         }
         PropertyDescriptor descriptor = TypeDescriptor.GetProperties(instance.DataGridTableStyle.DataGrid)["DataSource"];
         if (descriptor == null)
         {
             return value;
         }
         object rootDataSource = descriptor.GetValue(instance.DataGridTableStyle.DataGrid);
         if (this.designBindingPicker == null)
         {
             this.designBindingPicker = new DesignBindingPicker();
         }
         DesignBinding initialSelectedItem = new DesignBinding(null, (string) value);
         DesignBinding binding2 = this.designBindingPicker.Pick(context, provider, false, true, false, rootDataSource, string.Empty, initialSelectedItem);
         if ((rootDataSource == null) || (binding2 == null))
         {
             return value;
         }
         if (string.IsNullOrEmpty(binding2.DataMember) || (binding2.DataMember == null))
         {
             value = "";
             return value;
         }
         value = binding2.DataField;
     }
     return value;
 }
 public override object EditValue(ITypeDescriptorContext context, IServiceProvider provider, object value)
 {
     if (((provider != null) && (context != null)) && (context.Instance != null))
     {
         PropertyDescriptor descriptor = TypeDescriptor.GetProperties(context.Instance)["LinkedDataSource"];
         if (descriptor == null)
         {
             return value;
         }
         object rootDataSource = descriptor.GetValue(context.Instance);
         if (rootDataSource == null)
         {
             return value;
         }
         if (this.designBindingPicker == null)
         {
             this.designBindingPicker = new DesignBindingPicker();
         }
         DesignBinding initialSelectedItem = new DesignBinding(null, (string) value);
         DesignBinding binding2 = this.designBindingPicker.Pick(context, provider, false, true, false, rootDataSource, string.Empty, initialSelectedItem);
         if (binding2 != null)
         {
             value = binding2.DataMember;
         }
     }
     return value;
 }
 private static void SetBinding(ControlBindingsCollection bindings, PropertyDescriptor property, DesignBinding designBinding)
 {
     if (designBinding != null)
     {
         Binding binding = bindings[property.Name];
         if (binding != null)
         {
             bindings.Remove(binding);
         }
         if (!designBinding.IsNull)
         {
             bindings.Add(property.Name, designBinding.DataSource, designBinding.DataMember);
         }
     }
 }
 public override object EditValue(ITypeDescriptorContext context, IServiceProvider provider, object value)
 {
     if (((provider != null) && (context != null)) && (context.Instance != null))
     {
         DataGridView dataGridView;
         DataGridViewColumnCollectionDialog.ListBoxItem instance = context.Instance as DataGridViewColumnCollectionDialog.ListBoxItem;
         if (instance != null)
         {
             dataGridView = instance.DataGridViewColumn.DataGridView;
         }
         else
         {
             DataGridViewColumn column = context.Instance as DataGridViewColumn;
             if (column != null)
             {
                 dataGridView = column.DataGridView;
             }
             else
             {
                 dataGridView = null;
             }
         }
         if (dataGridView == null)
         {
             return value;
         }
         object dataSource = dataGridView.DataSource;
         string dataMember = dataGridView.DataMember;
         string str2 = (string) value;
         string str3 = dataMember + "." + str2;
         if (dataSource == null)
         {
             dataMember = string.Empty;
             str3 = str2;
         }
         if (this.designBindingPicker == null)
         {
             this.designBindingPicker = new DesignBindingPicker();
         }
         DesignBinding initialSelectedItem = new DesignBinding(dataSource, str3);
         DesignBinding binding2 = this.designBindingPicker.Pick(context, provider, false, true, false, dataSource, dataMember, initialSelectedItem);
         if ((dataSource != null) && (binding2 != null))
         {
             value = binding2.DataField;
         }
     }
     return value;
 }
 public override object EditValue(ITypeDescriptorContext context, IServiceProvider provider, object value)
 {
     if ((provider != null) && (context.Instance != null))
     {
         if (this.designBindingPicker == null)
         {
             this.designBindingPicker = new DesignBindingPicker();
         }
         DesignBinding initialSelectedItem = new DesignBinding(value, "");
         DesignBinding binding2 = this.designBindingPicker.Pick(context, provider, true, false, false, null, string.Empty, initialSelectedItem);
         if (binding2 != null)
         {
             value = binding2.DataSource;
         }
     }
     return value;
 }
 public DesignBinding Pick(ITypeDescriptorContext context, IServiceProvider provider, bool showDataSources, bool showDataMembers, bool selectListMembers, object rootDataSource, string rootDataMember, DesignBinding initialSelectedItem)
 {
     this.serviceProvider = provider;
     this.edSvc = (IWindowsFormsEditorService) this.serviceProvider.GetService(typeof(IWindowsFormsEditorService));
     this.dspSvc = (DataSourceProviderService) this.serviceProvider.GetService(typeof(DataSourceProviderService));
     this.typeSvc = (ITypeResolutionService) this.serviceProvider.GetService(typeof(ITypeResolutionService));
     this.hostSvc = (IDesignerHost) this.serviceProvider.GetService(typeof(IDesignerHost));
     if (this.edSvc == null)
     {
         return null;
     }
     this.context = context;
     this.showDataSources = showDataSources;
     this.showDataMembers = showDataMembers;
     this.selectListMembers = showDataMembers ? selectListMembers : true;
     this.rootDataSource = rootDataSource;
     this.rootDataMember = rootDataMember;
     IUIService service = this.serviceProvider.GetService(typeof(IUIService)) as IUIService;
     if (service != null)
     {
         if (service.Styles["VsColorPanelHyperLink"] is Color)
         {
             this.addNewCtrl.LinkColor = (Color) service.Styles["VsColorPanelHyperLink"];
         }
         if (service.Styles["VsColorPanelHyperLinkPressed"] is Color)
         {
             this.addNewCtrl.ActiveLinkColor = (Color) service.Styles["VsColorPanelHyperLinkPressed"];
         }
     }
     this.FillTree(initialSelectedItem);
     this.addNewPanel.Visible = (showDataSources && (this.dspSvc != null)) && this.dspSvc.SupportsAddNewDataSource;
     this.helpTextPanel.Visible = showDataSources;
     this.UpdateHelpText(null);
     this.edSvc.DropDownControl(this);
     DesignBinding selectedItem = this.selectedItem;
     this.selectedItem = null;
     this.EmptyTree();
     this.serviceProvider = null;
     this.edSvc = null;
     this.dspSvc = null;
     this.hostSvc = null;
     context = null;
     return selectedItem;
 }
 private void FillTree(DesignBinding initialSelectedItem)
 {
     this.selectedItem = initialSelectedItem;
     this.EmptyTree();
     this.noneNode = new NoneNode();
     this.otherNode = new OtherNode();
     this.projectNode = new ProjectNode(this);
     if (((this.hostSvc != null) && (this.hostSvc.RootComponent != null)) && (this.hostSvc.RootComponent.Site != null))
     {
         this.instancesNode = new InstancesNode(this.hostSvc.RootComponent.Site.Name);
     }
     else
     {
         this.instancesNode = new InstancesNode(string.Empty);
     }
     this.treeViewCtrl.Nodes.Add(this.noneNode);
     if (this.showDataSources)
     {
         this.AddFormDataSources();
         this.AddProjectDataSources();
         if (this.projectNode.Nodes.Count > 0)
         {
             this.otherNode.Nodes.Add(this.projectNode);
         }
         if (this.instancesNode.Nodes.Count > 0)
         {
             this.otherNode.Nodes.Add(this.instancesNode);
         }
         if (this.otherNode.Nodes.Count > 0)
         {
             this.treeViewCtrl.Nodes.Add(this.otherNode);
         }
     }
     else
     {
         this.AddDataSourceContents(this.treeViewCtrl.Nodes, this.rootDataSource, this.rootDataMember, null);
     }
     if (this.selectedNode == null)
     {
         this.selectedNode = this.noneNode;
     }
     this.selectedItem = null;
     base.Width = Math.Max(base.Width, this.treeViewCtrl.PreferredWidth + (SystemInformation.VerticalScrollBarWidth * 2));
 }
 private void DropDownPicker()
 {
     if (this.designBindingPicker == null)
     {
         this.designBindingPicker = new DesignBindingPicker();
         this.designBindingPicker.Width = base.Width;
     }
     DesignBinding initialSelectedItem = null;
     if (this.binding != null)
     {
         initialSelectedItem = new DesignBinding(this.binding.DataSource, this.binding.BindingMemberInfo.BindingMember);
     }
     DesignBinding binding2 = this.designBindingPicker.Pick(this, this, true, true, false, null, string.Empty, initialSelectedItem);
     if (binding2 != null)
     {
         System.Windows.Forms.Binding binding = this.binding;
         System.Windows.Forms.Binding binding4 = null;
         string formatString = (binding != null) ? binding.FormatString : string.Empty;
         IFormatProvider formatInfo = (binding != null) ? binding.FormatInfo : null;
         object nullValue = (binding != null) ? binding.NullValue : null;
         DataSourceUpdateMode dataSourceUpdateMode = (binding != null) ? binding.DataSourceUpdateMode : this.defaultDataSourceUpdateMode;
         if ((binding2.DataSource != null) && !string.IsNullOrEmpty(binding2.DataMember))
         {
             binding4 = new System.Windows.Forms.Binding(this.propertyName, binding2.DataSource, binding2.DataMember, true, dataSourceUpdateMode, nullValue, formatString, formatInfo);
         }
         this.Binding = binding4;
         if ((((binding4 == null) || (binding != null)) || ((binding4 != null) && (binding == null))) || (((binding4 != null) && (binding != null)) && ((binding4.DataSource != binding.DataSource) || !binding4.BindingMemberInfo.Equals(binding.BindingMemberInfo))))
         {
             this.OnPropertyValueChanged(EventArgs.Empty);
         }
     }
 }