Exemplo n.º 1
0
        public void Add(string dataMember, int imageIndex, string[] propertyNames, string sortProperty, ListSortDirection sortDirection)
        {
            if (string.IsNullOrEmpty(dataMember))
            {
                throw new ArgumentNullException("dataMember");
            }
            if (this.Find(dataMember) != null)
            {
                throw new ArgumentException(Strings.DuplicateDataMember.ToString(), "dataMember");
            }
            DataTreeListViewColumnMapping value = new DataTreeListViewColumnMapping(dataMember, imageIndex, propertyNames, sortProperty, sortDirection);

            base.List.Add(value);
        }
Exemplo n.º 2
0
        public DataTreeListViewColumnMapping Find(string dataMember)
        {
            DataTreeListViewColumnMapping result = null;

            foreach (object obj in this)
            {
                DataTreeListViewColumnMapping dataTreeListViewColumnMapping = (DataTreeListViewColumnMapping)obj;
                if (dataTreeListViewColumnMapping.DataMember == dataMember)
                {
                    result = dataTreeListViewColumnMapping;
                    break;
                }
            }
            return(result);
        }
Exemplo n.º 3
0
        internal bool HasChildDataMember(object row)
        {
            bool result = false;
            PropertyDescriptorCollection properties = TypeDescriptor.GetProperties(row);

            foreach (object obj in this.ChildrenDataMembers)
            {
                DataTreeListViewColumnMapping dataTreeListViewColumnMapping = (DataTreeListViewColumnMapping)obj;
                if (properties[dataTreeListViewColumnMapping.DataMember] != null)
                {
                    result = true;
                    break;
                }
            }
            return(result);
        }
 private void BindToChildDataSources()
 {
     if (this.ListView != null && this.DataSource != null)
     {
         this.ClearChildrenDataSources();
         PropertyDescriptorCollection properties = TypeDescriptor.GetProperties(this.DataSource);
         foreach (object obj in this.ListView.ChildrenDataMembers)
         {
             DataTreeListViewColumnMapping dataTreeListViewColumnMapping = (DataTreeListViewColumnMapping)obj;
             if (properties[dataTreeListViewColumnMapping.DataMember] != null)
             {
                 BindingSource bindingSource = new BindingSource(this.DataSource, dataTreeListViewColumnMapping.DataMember);
                 this.childDataSources.Add(bindingSource);
                 bindingSource.ListChanged += this.ChildList_ListChanged;
                 this.dataSource2ColumnMapping[bindingSource] = dataTreeListViewColumnMapping;
                 this.ColumnMapping = dataTreeListViewColumnMapping;
             }
         }
     }
 }
Exemplo n.º 5
0
        protected override void OnInsert(int index, object value)
        {
            DataTreeListViewColumnMapping dataTreeListViewColumnMapping = value as DataTreeListViewColumnMapping;

            if (dataTreeListViewColumnMapping == null)
            {
                throw new InvalidOperationException();
            }
            if (string.IsNullOrEmpty(dataTreeListViewColumnMapping.DataMember))
            {
                throw new ArgumentNullException("DataMember");
            }
            for (int i = 0; i < base.Count; i++)
            {
                if ((base.List[i] as DataTreeListViewColumnMapping).DataMember == dataTreeListViewColumnMapping.DataMember && i != index)
                {
                    throw new ArgumentException(Strings.DuplicateDataMember.ToString(), "DataMember");
                }
            }
        }
        private void ApplySort()
        {
            int num = -1;

            if (!string.IsNullOrEmpty(this.ListView.SortProperty))
            {
                foreach (object obj in this.ListView.Columns)
                {
                    ColumnHeader columnHeader = (ColumnHeader)obj;
                    if (this.ListView.SortProperty == columnHeader.Name)
                    {
                        num = columnHeader.Index;
                        break;
                    }
                }
            }
            foreach (object obj2 in this.childDataSources)
            {
                BindingSource bindingSource = (BindingSource)obj2;
                if (bindingSource.SupportsSorting && bindingSource.Count > 1)
                {
                    string                        text          = this.ListView.SortProperty;
                    ListSortDirection             sortDirection = this.ListView.SortDirection;
                    DataTreeListViewColumnMapping dataTreeListViewColumnMapping = (DataTreeListViewColumnMapping)this.dataSource2ColumnMapping[bindingSource];
                    if (num >= 0 && dataTreeListViewColumnMapping.PropertyNames.Count > num && !string.IsNullOrEmpty(dataTreeListViewColumnMapping.PropertyNames[num]))
                    {
                        text = dataTreeListViewColumnMapping.PropertyNames[num];
                    }
                    PropertyDescriptorCollection properties = TypeDescriptor.GetProperties(bindingSource[0]);
                    if (string.IsNullOrEmpty(text) || properties[text] == null)
                    {
                        text          = dataTreeListViewColumnMapping.SortProperty;
                        sortDirection = dataTreeListViewColumnMapping.SortDirection;
                    }
                    if (!string.IsNullOrEmpty(text) && properties[text] != null && (!bindingSource.IsSorted || bindingSource.SortProperty.Name != text || bindingSource.SortDirection != sortDirection))
                    {
                        bindingSource.ApplySort(properties[text], sortDirection);
                    }
                }
            }
        }
        private void UpdateItem()
        {
            if (this.ListView != null)
            {
                this.ListView.InternalUpdateItem(this);
            }
            DataTreeListViewColumnMapping dataTreeListViewColumnMapping = this.ColumnMapping;

            if (dataTreeListViewColumnMapping != null)
            {
                PropertyDescriptorCollection properties = TypeDescriptor.GetProperties(this.DataSource);
                for (int i = 0; i < dataTreeListViewColumnMapping.PropertyNames.Count; i++)
                {
                    PropertyDescriptor propertyDescriptor;
                    if (!string.IsNullOrEmpty(dataTreeListViewColumnMapping.PropertyNames[i]) && (propertyDescriptor = properties[dataTreeListViewColumnMapping.PropertyNames[i]]) != null && i < base.SubItems.Count)
                    {
                        base.SubItems[i].Text = this.ListView.FormatRawValueByColumn(DataListView.GetPropertyValue(this.DataSource, propertyDescriptor), this.ListView.Columns[i]);
                    }
                }
            }
        }