Ejemplo n.º 1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="descriptors"></param>
        /// <param name="name"></param>
        public static int Add(this SortDescriptorCollection descriptors, string name)
        {
            int count = descriptors.Count;

            descriptors.Add(name, ListSortDirection.Ascending);
            return(count);
        }
Ejemplo n.º 2
0
        public void CollectionManagerCollatesSortDescriptorEvents()
        {
            SortDescriptorCollection  collection            = new SortDescriptorCollection();
            SortDescriptionCollection descriptionCollection = new SortDescriptionCollection();
            ExpressionCache           cache      = new ExpressionCache();
            SortDescriptor            descriptor = null;

            this.CollectionManagerCollatesTemplate(
                (validationAction) =>
            {
                return(new SortCollectionManager(collection, descriptionCollection, cache, sd => validationAction()));
            },
                () =>
            {
                collection.Add(new SortDescriptor());
            },
                () =>
            {
                collection[0].PropertyPath = "First";
            },
                () =>
            {
                collection.Add(new SortDescriptor());
            },
                () =>
            {
                collection[1].PropertyPath = "Second";
            },
                () =>
            {
                collection[1] = new SortDescriptor();
            },
                () =>
            {
                descriptor = collection[0];
                collection.Remove(descriptor);
            },
                () =>
            {
                descriptor.PropertyPath = "Removed";
            });
        }
 /// <summary>
 /// Resets the <paramref name="sortDescriptors"/> collection to match the <paramref name="sortDescriptions"/> collection.
 /// </summary>
 /// <param name="sortDescriptions">The collection to match</param>
 /// <param name="sortDescriptors">The collection to reset</param>
 private static void ResetToSortDescriptions(SortDescriptionCollection sortDescriptions, SortDescriptorCollection sortDescriptors)
 {
     sortDescriptors.Clear();
     foreach (SortDescription description in sortDescriptions)
     {
         sortDescriptors.Add(SortCollectionManager.GetDescriptorFromDescription(description));
     }
 }
        public void CollectionManagerCollatesSortDescriptorEvents()
        {
            SortDescriptorCollection collection = new SortDescriptorCollection();
            SortDescriptionCollection descriptionCollection = new SortDescriptionCollection();
            ExpressionCache cache = new ExpressionCache();
            SortDescriptor descriptor = null;

            this.CollectionManagerCollatesTemplate(
                (validationAction) =>
                {
                    return new SortCollectionManager(collection, descriptionCollection, cache, sd => validationAction());
                },
                () =>
                {
                    collection.Add(new SortDescriptor());
                },
                () =>
                {
                    collection[0].PropertyPath = "First";
                },
                () =>
                {
                    collection.Add(new SortDescriptor());
                },
                () =>
                {
                    collection[1].PropertyPath = "Second";
                },
                () =>
                {
                    collection[1] = new SortDescriptor();
                },
                () =>
                {
                    descriptor = collection[0];
                    collection.Remove(descriptor);
                },
                () =>
                {
                    descriptor.PropertyPath = "Removed";
                });
        }
Ejemplo n.º 5
0
        public bool Sort(RadSortOrder sortOrder, bool multiSortMode)
        {
            if (!this.CanSort || this.ownerTemplate == null)
            {
                return(false);
            }
            SortDescriptor           descriptor      = new SortDescriptor(this.Name, GridViewHelper.GetSortDirection(sortOrder));
            SortDescriptorCollection sortDescriptors = this.ownerTemplate.SortDescriptors;
            bool flag = !multiSortMode && sortDescriptors.Count > 1;

            if (flag)
            {
                if (sortOrder == RadSortOrder.None)
                {
                    descriptor = (SortDescriptor)null;
                }
                if (this.RaiseSortingChanging(descriptor))
                {
                    return(false);
                }
                sortDescriptors.BeginUpdate();
                sortDescriptors.Clear();
            }
            int index = sortDescriptors.IndexOf(this.Name);

            if (index >= 0)
            {
                if (sortOrder == RadSortOrder.None)
                {
                    sortDescriptors.RemoveAt(index);
                    return(true);
                }
                if (sortOrder == GridViewHelper.GetSortDirection(sortDescriptors[index].Direction))
                {
                    return(false);
                }
                sortDescriptors[index].Direction = GridViewHelper.GetSortDirection(sortOrder);
                return(true);
            }
            if (sortOrder == RadSortOrder.None)
            {
                if (flag)
                {
                    sortDescriptors.EndUpdate();
                }
                return(false);
            }
            if (!multiSortMode && sortDescriptors.Count == 1)
            {
                sortDescriptors[0] = descriptor;
            }
            else
            {
                sortDescriptors.Add(descriptor);
            }
            if (flag)
            {
                sortDescriptors.EndUpdate();
            }
            return(true);
        }