public override object EditValue( ITypeDescriptorContext context, IServiceProvider provider, object value) { DataSourceProviderService dspService = (DataSourceProviderService)provider.GetService(typeof(DataSourceProviderService)); if (dspService == null || !dspService.SupportsAddNewDataSource) { using (GetTypeDialog dlg = new GetTypeDialog(provider, typeof(object), FilterTypeList)) { IWin32Window dialogOwnerWindow = null; IUIService uiService = (IUIService)provider.GetService(typeof(IUIService)); if (uiService != null) { dialogOwnerWindow = uiService.GetDialogOwnerWindow(); } DialogResult result = dlg.ShowDialog(dialogOwnerWindow); return(result == DialogResult.OK && dlg.ResultType != null? dlg.ResultType: value); } } return(new TypePicker().PickType(provider, value as Type, FilterTypeList)); }
private void OnComponentChanged(object sender, ComponentChangedEventArgs e) { if (((this.bindingUpdatedByUser && (e.Component == base.Component)) && (e.Member != null)) && ((e.Member.Name == "DataSource") || (e.Member.Name == "DataMember"))) { this.bindingUpdatedByUser = false; DataSourceProviderService service = (DataSourceProviderService)this.GetService(typeof(DataSourceProviderService)); if (service != null) { service.NotifyDataSourceComponentAdded(base.Component); } } }
public override UITypeEditorEditStyle GetEditStyle(ITypeDescriptorContext context) { if (context == null) { return(UITypeEditorEditStyle.DropDown); } DataSourceProviderService dspService = (DataSourceProviderService)context.GetService(typeof(DataSourceProviderService)); return(dspService == null || !dspService.SupportsAddNewDataSource? UITypeEditorEditStyle.Modal: UITypeEditorEditStyle.DropDown); }
private void AddTypes() { DataSourceProviderService dspService = GetService <DataSourceProviderService>(); if (dspService == null || !dspService.SupportsAddNewDataSource) { return; } DataSourceGroupCollection dataSources = null; try { dataSources = dspService.GetDataSources(); } catch (Exception ex) { IUIService ui = GetService <IUIService>(); string message = "Cant retrieve Data Source Collection: " + ex.Message + "\nCheck the 'Properties\\DataSources' folder of your project."; if (ui != null) { ui.ShowError(ex, message); } else { MessageBox.Show(message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } } if (dataSources == null) { return; } foreach (DataSourceGroup group in dataSources) { if (group != null) { AddGroup(group); } } }
private void SaveType(Type type) { DataSourceProviderService dspService = GetService <DataSourceProviderService>(); if (dspService == null || !dspService.SupportsAddNewDataSource) { return; } try { const string vs9TypeName = "Microsoft.VSDesigner.VSDesignerPackage.IGenericObjectDataSourcesService, Microsoft.VSDesigner, Version=9.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"; const string vs8TypeName = "Microsoft.VSDesigner.VSDesignerPackage.IGenericObjectDataSourcesService, Microsoft.VSDesigner, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"; Type serviceType = Type.GetType(vs9TypeName) ?? Type.GetType(vs8TypeName); if (serviceType == null) { return; } object service = _serviceProvider.GetService(serviceType); if (service == null) { return; } MethodInfo mi = serviceType.GetMethod("AddGenericObjectDataSource"); mi.Invoke(service, new object[] { _serviceProvider, null, type }); } catch (Exception ex) { IUIService ui = GetService <IUIService>(); if (ui != null) { ui.ShowError(ex); } else { MessageBox.Show(this, ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } } }
public override object EditValue( ITypeDescriptorContext context, IServiceProvider provider, object value) { DataSourceProviderService dspService = (DataSourceProviderService)provider.GetService(typeof(DataSourceProviderService)); if (dspService == null || !dspService.SupportsAddNewDataSource) { GetTypeDialog dlg = new GetTypeDialog(provider, typeof(object), FilterTypeList); DialogResult result = dlg.ShowDialog(); return(result == DialogResult.OK && dlg.ResultType != null? dlg.ResultType: value); } return(new TypePicker().PickType(provider, value as Type, FilterTypeList)); }