/// <summary> /// <para> /// Edits the value specified. /// </para> /// </summary> /// <param name='context'> /// An <see cref='System.ComponentModel.ITypeDescriptorContext'/> that specifies the context of the value to edit. /// </param> /// <param name=' provider'> /// An <see cref='System.IServiceProvider'/> . /// </param> /// <param name=' value'> /// The object to edit. /// </param> /// <returns> /// <para> /// The updated value. /// </para> /// </returns> public override Object EditValue(ITypeDescriptorContext context, IServiceProvider provider, Object value) { IDesignerHost designerHost = (IDesignerHost)context.GetService(typeof(IDesignerHost)); Debug.Assert(designerHost != null, "Did not get DesignerHost service."); Debug.Assert(context.Instance is ObjectList, "Expected objectlist"); ObjectList _objectList = (ObjectList)context.Instance; ObjectListDesigner _designer = (ObjectListDesigner)designerHost.GetDesigner(_objectList); Debug.Assert(_designer != null, "Did not get designer for component"); _designer.InvokePropertyBuilder(ObjectListComponentEditor.IDX_FIELDS); return(value); }
/// <summary> /// <para> /// Edits the value specified. /// </para> /// </summary> /// <param name='context'> /// An <see cref='System.ComponentModel.ITypeDescriptorContext'/> that specifies the context of the value to edit. /// </param> /// <param name=' provider'> /// An <see cref='System.IServiceProvider'/> . /// </param> /// <param name=' value'> /// The object to edit. /// </param> /// <returns> /// <para> /// The updated value. /// </para> /// </returns> public override Object EditValue(ITypeDescriptorContext context, IServiceProvider provider, Object value) { Debug.Assert(context != null); ObjectList objectList = context.Instance as ObjectList; Debug.Assert(objectList != null); ObjectListDesigner designer = GetDesigner(context) as ObjectListDesigner; Debug.Assert(designer != null); designer.InvokePropertyBuilder(ObjectListComponentEditor.IDX_GENERAL); return(objectList.TableFields); }
/// <summary> /// Saves the component loaded into the page. /// </summary> protected override void SaveComponent() { ObjectList objectList = (ObjectList)GetBaseControl(); ObjectListDesigner objectListDesigner = (ObjectListDesigner)GetBaseDesigner(); try { int itemCount = 0; if (_txtItemCount.Text.Length != 0) { itemCount = Int32.Parse(_txtItemCount.Text, CultureInfo.InvariantCulture); } objectList.ItemCount = itemCount; } catch (Exception) { _txtItemCount.Text = objectList.ItemCount.ToString(CultureInfo.InvariantCulture); } try { int itemsPerPage = 0; if (_txtItemsPerPage.Text.Length != 0) { itemsPerPage = Int32.Parse(_txtItemsPerPage.Text, CultureInfo.InvariantCulture); } objectList.ItemsPerPage = itemsPerPage; } catch (Exception) { _txtItemsPerPage.Text = objectList.ItemsPerPage.ToString(CultureInfo.InvariantCulture); } objectList.BackCommandText = _txtBackCommandText.Text; objectList.DetailsCommandText = _txtDetailsCommandText.Text; objectList.MoreText = _txtMoreText.Text; TypeDescriptor.Refresh(objectList); }
private void LoadDataSourceFields() { using (new LoadingModeResource(this)) { PropertyDescriptorCollection props = null; ObjectListDesigner objectListDesigner = (ObjectListDesigner)GetBaseDesigner(); IEnumerable dataSource = ((IDataSourceProvider)objectListDesigner).GetResolvedSelectedDataSource(); if (dataSource != null) { props = DesignTimeData.GetDataFields(dataSource); } if (props != null) { foreach (PropertyDescriptor propDesc in props) { _cmbDataField.Items.Add(propDesc.Name); } } } }
/// <summary> /// Saves the component loaded into the page. /// </summary> protected override void SaveComponent() { ObjectList objectList = (ObjectList)GetBaseControl(); ObjectListDesigner objectListDesigner = (ObjectListDesigner)GetBaseDesigner(); String labelField = String.Empty; if (_cmbLabelField.IsSet()) { labelField = (String)_cmbLabelField.SelectedItem; } objectList.LabelField = labelField; String tableFields = String.Empty; foreach (String field in _xLists.GetSelectedItems()) { tableFields += (field + ";"); } objectList.TableFields = tableFields; if (_dataSourceDirty) { // save the datasource as a binding on the control DataBindingCollection dataBindings = objectListDesigner.DataBindings; if (_currentDataSource == null) { objectListDesigner.DataSource = String.Empty; objectListDesigner.DataMember = String.Empty; } else { objectListDesigner.DataSource = _currentDataSource.ToString(); if (_cmbDataMember.IsSet()) { objectListDesigner.DataMember = (String)_cmbDataMember.SelectedItem; } else { objectListDesigner.DataMember = String.Empty; } } objectListDesigner.OnDataSourceChanged(); } try { int itemCount = 0; if (_txtItemCount.Text.Length != 0) { itemCount = Int32.Parse(_txtItemCount.Text, CultureInfo.InvariantCulture); } objectList.ItemCount = itemCount; } catch (Exception) { _txtItemCount.Text = objectList.ItemCount.ToString(); } try { int itemsPerPage = 0; if (_txtItemsPerPage.Text.Length != 0) { itemsPerPage = Int32.Parse(_txtItemsPerPage.Text, CultureInfo.InvariantCulture); } objectList.ItemsPerPage = itemsPerPage; } catch (Exception) { _txtItemsPerPage.Text = objectList.ItemsPerPage.ToString(); } objectList.BackCommandText = _txtBackCommandText.Text; objectList.DetailsCommandText = _txtDetailsCommandText.Text; objectList.MoreText = _txtMoreText.Text; TypeDescriptor.Refresh(objectList); }
/// <summary> /// Loads the component into the page. /// </summary> protected override void LoadComponent() { InitPage(); ObjectList objectList = (ObjectList)GetBaseControl(); LoadDataSourceItems(); if (_cmbDataSource.Items.Count > 0) { ObjectListDesigner objectListDesigner = (ObjectListDesigner)GetBaseDesigner(); String dataSourceValue = objectListDesigner.DataSource; if (dataSourceValue != null) { int dataSourcesAvailable = _cmbDataSource.Items.Count; // 0 is for 'NotSet' case. for (int j = 1; j < dataSourcesAvailable; j++) { DataSourceItem dataSourceItem = (DataSourceItem)_cmbDataSource.Items[j]; if (String.Compare(dataSourceItem.Name, dataSourceValue, true, CultureInfo.InvariantCulture) == 0) { _cmbDataSource.SelectedIndex = j; _currentDataSource = dataSourceItem; LoadDataMembers(); if (_currentDataSource is ListSourceDataSourceItem) { String dataMember = objectListDesigner.DataMember; _cmbDataMember.SelectedIndex = _cmbDataMember.FindStringExact(dataMember); if (_cmbDataMember.IsSet()) { ((ListSourceDataSourceItem)_currentDataSource).CurrentDataMember = dataMember; } } LoadDataSourceFields(); break; } } } } String _labelField = objectList.LabelField; if (_labelField.Length != 0) { int textFieldIndex = _cmbLabelField.FindStringExact(_labelField); _cmbLabelField.SelectedIndex = textFieldIndex; } _txtItemCount.Text = objectList.ItemCount.ToString(); _txtItemsPerPage.Text = objectList.ItemsPerPage.ToString(); _txtBackCommandText.Text = objectList.BackCommandText; _txtDetailsCommandText.Text = objectList.DetailsCommandText; _txtMoreText.Text = objectList.MoreText; UpdateEnabledVisibleState(); }