Ejemplo n.º 1
0
 void IBindingList <T> .ApplySort(
     SCM.PropertyDescriptor property,
     SCM.ListSortDirection direction
     )
 {
     AsBindingList.ApplySort(property, direction);
 }
 public void ApplySort(PropertyDescriptor property, System.ComponentModel.ListSortDirection direction)
 {
     _sort      = (CsvPropertyDescriptor)property;
     _direction = direction;
     _csv.ReadToEnd();
     _csv._records.Sort(new CsvRecordComparer(_sort.Index, _direction));
 }
Ejemplo n.º 3
0
        public void Sort(string propName, System.ComponentModel.ListSortDirection direction)
        {
            _sortProperty  = propName;
            _sortDirection = direction;
            OnPropertyChanged("SortProperty");
            OnPropertyChanged("SortDirection");

            EnsureValueCache();
            _wrapper.Sort(propName, direction, new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Reset));
            OnPropertyChanged("ValueProxies");
        }
Ejemplo n.º 4
0
 private void ResortDataGridView()
 {
     if (DataGridView1.SortOrder != SortOrder.None && DataGridView1.SortedColumn != null)
     {
         System.ComponentModel.ListSortDirection Direction = System.ComponentModel.ListSortDirection.Ascending;
         if (DataGridView1.SortOrder == SortOrder.Descending)
         {
             Direction = System.ComponentModel.ListSortDirection.Descending;
         }
         DataGridView1.Sort(DataGridView1.SortedColumn, Direction);
     }
 }
Ejemplo n.º 5
0
        /// <summary>
        /// Sorts the list by the given property.
        /// </summary>
        /// <param name="property"></param>
        /// <param name="direction"></param>
        public void ApplySort(PropertyDescriptor property, System.ComponentModel.ListSortDirection direction)
        {
            // are we trying to sort?
            if (property == null)
            {
                // set...
                _sortDirection = SortDirection.Ascending;
                _sortProperty  = null;
                return;
            }

            // data...
            SortDirection useDirection = SortDirection.Ascending;

            if (direction == ListSortDirection.Descending)
            {
                useDirection = SortDirection.Descending;
            }

            // get a comparer...
            IComparer comparer = this.GetComparer(property);

            if (comparer == null)
            {
                throw new ArgumentNullException("comparer");
            }

            // mbr - 2010-04-05 - changed reversal method...
            //// set...
            //if(comparer is IComparerDirection)
            //    ((IComparerDirection)comparer).Direction = useDirection;
            IComparer toUse = comparer;

            if (useDirection == SortDirection.Descending)
            {
                toUse = new ComparerReverser(comparer);
            }

            // sort by the given property...
            this.InnerList.Sort(toUse);

            // set...
            _sortProperty = property;
            if (direction == ListSortDirection.Ascending)
            {
                _sortDirection = SortDirection.Ascending;
            }
            else
            {
                _sortDirection = SortDirection.Descending;
            }
        }
 /// <summary>
 /// Sorts the list based on a PropertyDescriptor and a ListSortDirection.
 /// </summary>
 /// <param name="property">The PropertyDescriptor to sort by. </param>
 /// <param name="direction">One of the ListSortDirection values. </param>
 internal void ApplySort(System.ComponentModel.PropertyDescriptor property,
                         System.ComponentModel.ListSortDirection direction)
 {
     m_SortProperty  = property;
     m_SortDirection = direction;
     if ((m_OriginalList == null))
     {
         SaveList();
     }
     DoSort();
     if (null != ListChanged)
     {
         ListChanged(this, new ListChangedEventArgs(ListChangedType.Reset, 0));
     }
 }
Ejemplo n.º 7
0
        private void parseSort(XmlNode node)
        {
            if (this.context.SupportsSorting)
            {
                string propertyName  = null;
                string directionName = null;
                CoreTools.Xml.ParseNodeAttributes(node, (attrName, attrValue) =>
                {
                    switch (attrName.ToLower())
                    {
                    case "property":
                        propertyName = attrValue;
                        break;

                    case "direction":
                        directionName = attrValue;
                        break;
                    }
                });

                if (!string.IsNullOrEmpty(propertyName))
                {
                    System.ComponentModel.ListSortDirection direction = System.ComponentModel.ListSortDirection.Ascending;
                    if (!string.IsNullOrEmpty(directionName))
                    {
                        Enum.TryParse <System.ComponentModel.ListSortDirection>(directionName, out direction);
                    }

                    var pd = TypeDescriptor.GetProperties(this.context.GetDataType())[propertyName];
                    if (pd != null)
                    {
                        this.context.ApplySort(pd, direction);
                    }

                    /*
                     * if (!string.IsNullOrEmpty(propertyName))
                     *  this.context.ApplySort(propertyName, direction);
                     */
                }
            }
        }
 void System.ComponentModel.IBindingList.ApplySort(System.ComponentModel.PropertyDescriptor property, System.ComponentModel.ListSortDirection direction)
 {
     throw new NotSupportedException();
 }
Ejemplo n.º 9
0
 private void dggame_ColumnHeaderMouseClick(object sender, DataGridViewCellMouseEventArgs e)
 {
     if (e.ColumnIndex > -1)
     {
         DataGridViewColumn dgvc = dggame.Columns[e.ColumnIndex];
         dgvc.SortMode = DataGridViewColumnSortMode.Programmatic;
         // modify direction if last sorted column was the same
         if (dgvc.Name == lastsortedcolumn)
             if (direction == System.ComponentModel.ListSortDirection.Ascending)
             {
                 direction = System.ComponentModel.ListSortDirection.Descending;
                 dggame.Columns[lastsortedcolumn].HeaderCell.SortGlyphDirection = SortOrder.Descending;
             }
             else
             {
                 direction = System.ComponentModel.ListSortDirection.Ascending;
                 dggame.Columns[lastsortedcolumn].HeaderCell.SortGlyphDirection = SortOrder.Ascending;
             }
         else
             direction = System.ComponentModel.ListSortDirection.Ascending;
         lastsortedcolumn = dgvc.Name;
         DataSourceSet();
     }
 }
Ejemplo n.º 10
0
        public static void Sort <T, TKey>(this ObservableCollection <T> Items, Func <T, TKey> keySelector, System.ComponentModel.ListSortDirection direction) //where T : IComparable
        {
            List <T> sortedItemsList = direction == ListSortDirection.Ascending ? Items.OrderBy(keySelector).ToList() : Items.OrderByDescending(keySelector).ToList();

            Items.Clear();
            foreach (var item in sortedItemsList)
            {
                //Items.Move(Items.IndexOf(item), sortedItemsList.IndexOf(item));
                Items.Add(item);
            }
        }
Ejemplo n.º 11
0
 public void ApplySort(PropertyDescriptor property, System.ComponentModel.ListSortDirection direction)
 {
     throw new NotSupportedException();
 }
 public MovieTitleComparer(ListSortDirection sortDirection)
 {
     SortDirection = sortDirection;
 }
Ejemplo n.º 13
0
 public override void Sort(System.Windows.Forms.DataGridViewColumn dataGridViewColumn, System.ComponentModel.ListSortDirection direction)
 {
     base.Sort(dataGridViewColumn, direction);
 }