Пример #1
0
        /// <summary>
        /// Gets a list of selected Dynamics365Field objects.
        /// </summary>
        /// <param name="context">The context.</param>
        /// <param name="provider">The provider.</param>
        /// <param name="value">The value.</param>
        /// <returns>The selected objects.</returns>
        public override object EditValue(ITypeDescriptorContext context, IServiceProvider provider, object value)
        {
            IDataSourceFieldsProvider    fieldsProvider = (IDataSourceFieldsProvider)context.Instance;
            BindingList <DataTableField> currentValue   = (BindingList <DataTableField>)value;

            checkedListBox.Items.Clear();
            checkedListBox.Items.Add("Select All", false);
            checkedListBox.ItemCheck += CheckedListBox_ItemCheck;

            List <DataTableField> fields = fieldsProvider.GetDataSourceFields();

            fields.ForEach(field => checkedListBox.Items.Add(field, currentValue.Contains((DataTableField)field)));

            IWindowsFormsEditorService service = (IWindowsFormsEditorService)provider.GetService(typeof(IWindowsFormsEditorService));

            service.DropDownControl(checkedListBox);

            BindingList <DataTableField> checkedFields = new BindingList <DataTableField>();

            for (int itemIndex = 0; itemIndex < checkedListBox.CheckedIndices.Count; itemIndex++)
            {
                if (checkedListBox.CheckedIndices[itemIndex] != 0)
                {
                    DataTableField field = (DataTableField)checkedListBox.CheckedItems[itemIndex];
                    checkedFields.Add(field);
                }
            }

            return(checkedFields);
        }
Пример #2
0
        /// <summary>
        /// Converts a DataColumn to a string.
        /// </summary>
        /// <param name="context">The context.</param>
        /// <param name="culture">The culture.</param>
        /// <param name="value">The DataColumn to convert.</param>
        /// <param name="destinationType">The destination type.</param>
        /// <returns>A string representation of the DataColumn.</returns>
        public override object ConvertTo(ITypeDescriptorContext context, CultureInfo culture, object value, Type destinationType)
        {
            if (value != default(object))
            {
                DataTableField field = (DataTableField)value;
                return(string.Format("{0} ({1})", field.DisplayName, field.ColumnName));
            }

            return(null);
        }
Пример #3
0
        public List <DataTableField> GetSecondaryDataSourceFields()
        {
            List <DataTableField> fields = new List <DataTableField>();

            try
            {
                fields.AddRange(DataTableField.GetDataTableFields(ComparisonData?.GetDataColumns()));
            }
            catch { }

            return(fields);
        }
Пример #4
0
        public List <DataTableField> GetDataSourceFields()
        {
            List <DataTableField> fields = new List <DataTableField>();

            try
            {
                fields.AddRange(DataTableField.GetDataTableFields(DataSource?.GetDataColumns()));
            }
            catch { }

            return(fields);
        }
        public override object ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, object value)
        {
            BindingList <DataTableField> fields = new BindingList <DataTableField>();

            if (!string.IsNullOrEmpty((string)value))
            {
                IDataSourceFieldsProvider fieldsProvider = (IDataSourceFieldsProvider)context.Instance;
                List <DataTableField>     sourceFields   = fieldsProvider.GetDataSourceFields();
                string[] fieldStrings = ((string)value).Split(new string[] { FIELD_DELIMITER }, StringSplitOptions.None);

                foreach (string fieldString in fieldStrings)
                {
                    string         columnName = Regex.Match(fieldString, CoreUtility.FieldMatchPattern).Groups[1].Value;
                    DataTableField field      = sourceFields.FirstOrDefault(f => f.ColumnName == columnName); // todo - comparer
                    fields.Add(field);
                }
            }

            return(fields);
        }
Пример #6
0
 public List <DataTableField> GetLookupSourceFields()
 {
     return(DataTableField.GetDataTableFields(DataSource?.GetDataColumns()));
 }