private void Sort(string sortBy, ListSortDirection direction) { try { ICollectionView dataView = CollectionViewSource.GetDefaultView(listView_log.DataContext); dataView.SortDescriptions.Clear(); SortDescription sd = new SortDescription(sortBy, direction); dataView.SortDescriptions.Add(sd); if (_lastHeaderClicked2 != null) { if (String.Compare(sortBy, _lastHeaderClicked2) != 0) { SortDescription sd2 = new SortDescription(_lastHeaderClicked2, _lastDirection2); dataView.SortDescriptions.Add(sd2); } } dataView.Refresh(); Settings.Instance.ResColumnHead = sortBy; Settings.Instance.ResSortDirection = direction; } catch (Exception ex) { MessageBox.Show(ex.Message + "\r\n" + ex.StackTrace); } }
public static void Sort(ItemsControl listView, string sortBy, ListSortDirection direction) { listView.Items.SortDescriptions.Clear(); var sd = new SortDescription(sortBy, direction); listView.Items.SortDescriptions.Add(sd); listView.Items.Refresh(); }
internal Key(DataTable table,DataColumn[] columns,ListSortDirection[] sort, DataViewRowState rowState, IExpression filter) { _table = table; _filter = filter; if (_filter != null) _tmpRow = _table.NewNotInitializedRow(); _columns = columns; if (sort != null && sort.Length == columns.Length) { _sortDirection = sort; } else { _sortDirection = new ListSortDirection[columns.Length]; for(int i=0; i < _sortDirection.Length; i++) { _sortDirection[i] = ListSortDirection.Ascending; } } if (rowState != DataViewRowState.None) { _rowStateFilter = rowState; } else { // FIXME : what is the correct value ? _rowStateFilter = DataViewRowState.CurrentRows; } }
public FileListPaneSettings(string directory, string sortByField, ListSortDirection sortDirection, ColumnMode columnMode) { Directory = directory; SortByField = sortByField; SortDirection = sortDirection; DisplayColumnMode = columnMode; }
public void AddSort(string sortColumn, ListSortDirection dir) { if (sortColumns.ContainsKey(sortColumn)) sortColumns.Remove(sortColumn); sortColumns.Add(sortColumn, dir); }
private void InternalSortColumn(int column, ListSortDirection? direction) { HDF hdf; if (this.ReadColumnFormat(column, out hdf)) { hdf &= ~(HDF.HDF_SORTUP | HDF.HDF_SORTDOWN); if (direction.HasValue) { hdf |= (((ListSortDirection) direction.Value) == ListSortDirection.Descending) ? 0x200 : 0x400; } HDITEM hditem = new HDITEM { mask = HDI.HDI_FORMAT, fmt = hdf }; GCHandle handle = GCHandle.Alloc(hditem, GCHandleType.Pinned); try { this.HeaderItemPtr = handle.AddrOfPinnedObject(); Windows.SendMessage(base.Handle, 0x120c, (IntPtr) column, this.HeaderItemPtr); } finally { handle.Free(); this.HeaderItemPtr = IntPtr.Zero; } } }
public SortAdorner(UIElement element, ListSortDirection sortDirection) : base(element) { SortDirection = sortDirection; // We want to let the things we're adorning handle events IsHitTestVisible = false; }
private void _SetSortOrder( IEnumerable itemsSource, string propertyName, ListSortDirection direction ) { var view = CollectionViewSource.GetDefaultView( itemsSource ); view.SortDescriptions.Clear( ); view.SortDescriptions.Add( new SortDescription( propertyName, direction ) ); view.Refresh( ); }
public VarietiesViewModel(IProjectService projectService, IDialogService dialogService, IAnalysisService analysisService, VarietiesVarietyViewModel.Factory varietyFactory) : base("Varieties") { _projectService = projectService; _dialogService = dialogService; _analysisService = analysisService; _varietyFactory = varietyFactory; _projectService.ProjectOpened += _projectService_ProjectOpened; _sortPropertyName = "Meaning.Gloss"; _sortDirection = ListSortDirection.Ascending; Messenger.Default.Register<SwitchViewMessage>(this, HandleSwitchView); _findCommand = new RelayCommand(Find); TaskAreas.Add(new TaskAreaItemsViewModel("Common tasks", new TaskAreaCommandViewModel("Add a new variety", new RelayCommand(AddNewVariety)), new TaskAreaCommandViewModel("Rename variety", new RelayCommand(RenameSelectedVariety, CanRenameSelectedVariety)), new TaskAreaCommandViewModel("Remove variety", new RelayCommand(RemoveSelectedVariety, CanRemoveSelectedVariety)), new TaskAreaCommandViewModel("Find words", _findCommand), new TaskAreaItemsViewModel("Sort words by", new TaskAreaCommandGroupViewModel( new TaskAreaCommandViewModel("Gloss", new RelayCommand(() => SortWordsBy("Meaning.Gloss", ListSortDirection.Ascending))), new TaskAreaCommandViewModel("Form", new RelayCommand(() => SortWordsBy("StrRep", ListSortDirection.Ascending))))))); TaskAreas.Add(new TaskAreaItemsViewModel("Other tasks", new TaskAreaCommandViewModel("Remove affixes from words", new RelayCommand(RunStemmer, CanRunStemmer)))); }
public SortExpression(string propertyName) { PropertyName = propertyName; SortDirection = ListSortDirection.Ascending; PropertyDescriptor = null; _propertyValueCache = new Hashtable(); }
public SortExpression(string propertyName, ListSortDirection sortDirection) { PropertyName = propertyName; SortDirection = sortDirection; PropertyDescriptor = null; _propertyValueCache = new Hashtable(); }
/// <summary> /// A header was clicked. Sort the associated column. /// </summary> private void OnHeaderClicked(object sender, RoutedEventArgs e) { // Make sure the column is really being sorted. GridViewColumnHeader header = e.OriginalSource as GridViewColumnHeader; if (header == null || header.Role == GridViewColumnHeaderRole.Padding) return; SortListViewColumn column = header.Column as SortListViewColumn; if (column == null) return; // See if a new column was clicked, or the same column was clicked. if (sortColumn != column) { // A new column was clicked. previousSortColumn = sortColumn; sortColumn = column; sortDirection = ListSortDirection.Ascending; } else { // The same column was clicked, change the sort order. previousSortColumn = null; sortDirection = (sortDirection == ListSortDirection.Ascending) ? ListSortDirection.Descending : ListSortDirection.Ascending; } // Sort the data. SortList(column.SortProperty); // Update the column header based on the sort column and order. UpdateHeaderTemplate(); }
public ColumnOrderSet(ColumnDefinition column, ListSortDirection order) : this() { column.ThrowIfNull("column"); this.Column = column; this.Direction = order; }
public void refreshOutgoing() { this.BeginInvoke((ThreadStart)delegate { int scrollPosition = dg_outgoing.FirstDisplayedScrollingRowIndex; DataGridViewColumn sortedColumn = dg_outgoing.SortedColumn; ListSortDirection sorder = new ListSortDirection(); bool doSort = true; if (dg_outgoing.SortOrder == SortOrder.Ascending) sorder = ListSortDirection.Ascending; else if (dg_outgoing.SortOrder == SortOrder.Descending) sorder = ListSortDirection.Descending; else doSort = false; Point pp = Point.Empty; if (dg_outgoing.SelectedCells.Count > 0) pp = dg_outgoing.CurrentCellAddress; dg_outgoing.Rows.Clear(); foreach (DictionaryEntry de in mtOut.getMessages()) { canMessage cm = (canMessage)de.Key; dg_outgoing.Rows.Add(cm.getDataGridViewRow(dg_outgoing,mtOut)); } if (doSort) dg_outgoing.Sort(sortedColumn,(ListSortDirection) sorder); if (scrollPosition > 0) dg_outgoing.FirstDisplayedScrollingRowIndex = scrollPosition; if (dg_outgoing.Rows.Count > 0 && pp.Y < dg_outgoing.Rows.Count) dg_outgoing.CurrentCell = dg_outgoing.Rows[pp.Y].Cells[pp.X]; }); }
/// <summary> /// Initializes a new instance of the <see cref="SortGlyphAdorner"/> class. /// </summary> /// <param name="columnHeader">The column header</param> /// <param name="direction">The direction</param> /// <param name="sortGlyph">The image glyph</param> public SortGlyphAdorner(GridViewColumnHeader columnHeader, ListSortDirection direction, ImageSource sortGlyph) : base(columnHeader) { this.columnHeader = columnHeader; this.direction = direction; this.sortGlyph = sortGlyph; }
//Deserialization constructor. public SortInfo(SerializationInfo info, StreamingContext ctxt) { //Get the values from info and assign them to the appropriate properties _columnIndex = (int)info.GetValue("ColumnIndex", typeof(int)); _propertyName = (String)info.GetValue("PropertyName", typeof(string)); _direction = (ListSortDirection)info.GetValue("Direction", typeof(ListSortDirection)); }
public CaseListSort(ListSortDirection direction, DataGridColumn column) { int dir = (direction == ListSortDirection.Ascending) ? 1: -1; string path = BindingOperations.GetBindingExpression(column, DataGridColumn.HeaderProperty).ParentBinding.Path.Path; switch (path) { case "CaseId": myComparer = (a, b) => { return a.CaseId.CompareTo(b.CaseId) * dir; }; break; case "AnalystComment": myComparer = (a, b) => { return a.AnalystComment.CompareTo(b.AnalystComment) * dir;}; break; case "ObjectId": myComparer = (a, b) => { return a.ObjectId.CompareTo(b.ObjectId) * dir;}; break; case "FlightNumber": myComparer = (a, b) => { return a.FlightNumber.CompareTo(b.FlightNumber) * dir; }; break; case "Analyst": myComparer = (a, b) => { return a.Analyst.CompareTo(b.Analyst) * dir; }; break; case "CaseDirectory": myComparer = (a, b) => { return a.CaseDirectory.CompareTo(b.CaseDirectory) * dir; }; break; case "ReferenceImage": myComparer = (a, b) => { return a.ReferenceImage.CompareTo(b.ReferenceImage) * dir; }; break; case "Result": myComparer = (a, b) => { return a.Result.CompareTo(b.Result) * dir; }; break; case "UpdateTime": myComparer = (a, b) => { return a.UpdateTime.CompareTo(b.UpdateTime) * dir; }; break; case "CreateTime": myComparer = (a, b) => { return a.CreateTime.CompareTo(b.CreateTime) * dir; }; break; case "Archived": myComparer = (a, b) => { return a.Archived.CompareTo(b.Archived) * dir; }; break; case "AnalysisTime": myComparer = (a, b) => { return a.AnalysisTime.CompareTo(b.AnalysisTime) * dir; }; break; default: myComparer = (a, b) => { return 0; }; break; } }
public SortDescriptionInfo( DataGridItemPropertyBase property, ListSortDirection direction ) { m_property = property; m_direction = direction; }
public GroupColumn(string columnName,int groupLevel, ListSortDirection sortDirection):base(columnName,sortDirection) { this.groupLevel = groupLevel; if (groupLevel < 0) { throw new GroupLevelException(); } }
public SortAdorner(UIElement element, ListSortDirection sortDirection) : base(element) { this.SortDirection = sortDirection; this.PaintBrush = ((element as GridViewColumnHeader).Column as DsxColumn).DataGrid.SortAdornerIndicatorBrush; }
private void dataGrid1_Sorting(object sender, DataGridSortingEventArgs e) { sortMemberPath = e.Column.SortMemberPath; sortDirection = e.Column.SortDirection != ListSortDirection.Ascending ? ListSortDirection.Ascending : ListSortDirection.Descending; }
public ExtendedSortDescription(string property, ListSortDirection? sortDirection, bool clearPreviousSorting) : this() { this.Property = property; this.SortDirection = sortDirection; this.ClearPreviousSorting = clearPreviousSorting; }
private void OrderByLastName(ListSortDirection dir) { ICollectionView dataView = CollectionViewSource.GetDefaultView(testListView.ItemsSource); dataView.SortDescriptions.Clear(); SortDescription sd = new SortDescription("LastName", dir); dataView.SortDescriptions.Add(sd); dataView.Refresh(); }
public GroupColumn(string columnName,int groupLevel, ListSortDirection sortDirection):base(columnName,sortDirection) { if (GroupLevel < 0) { throw new ArgumentException("groupLevel"); } this.GroupLevel = groupLevel; }
public GridSortableHeaderCellBuilder(IDictionary<string, object> htmlAttributes, string url, ListSortDirection? sortDirection, string sortedAscText, string sortedDescText, Action<IHtmlNode> appendContent) : base(htmlAttributes, appendContent) { this.sortDirection = sortDirection; this.sortedAscText = sortedAscText; this.sortedDescText = sortedDescText; this.url = url; }
private void applySortDirection(DataGrid grid, DataGridColumn col, ListSortDirection listSortDirection) { foreach (DataGridColumn c in grid.Columns) { c.SortDirection = null; } col.SortDirection = listSortDirection; }
private void A_FrmRTStationHead_Load(object sender, EventArgs e) { listSort = new ListSortDirection(); isClickSort = false; LoadTree(1); tvc_Dept.ExpandAll(); strWhere = StrWhere_Emp(); }
public AlertWidgetDialog(IList<DataSource> dataSources, string caption, string dataSourceId, string trackIdFieldName, string groupByFieldName, string sortByFieldName1, string sortByFieldName2, ListSortDirection sortByFieldOrder1, ListSortDirection sortByFieldOrder2, Dictionary<string, string> vmProperties) { this.Resources.MergedDictionaries.Add(AddInsShare.Resources.SharedDictionaryManager.SharedStyleDictionary); InitializeComponent(); // When re-configuring, initialize the widget config dialog from the existing settings. _vmProperties = vmProperties; // Caption CaptionTextBox.Text = caption; // data source selector if (!string.IsNullOrEmpty(dataSourceId)) { DataSource dataSource = OperationsDashboard.Instance.DataSources.FirstOrDefault(ds => ds.Id == dataSourceId); if (dataSource != null) { DataSourceSelector.SelectedDataSource = dataSource; if (!string.IsNullOrEmpty(trackIdFieldName)) { // Track Id Field Combo Box client.Field field = dataSource.Fields.FirstOrDefault(fld => fld.FieldName == trackIdFieldName); TrackIdFieldComboBox.SelectedItem = field; // Group By Field Combo Box field = dataSource.Fields.FirstOrDefault(fld => fld.FieldName == groupByFieldName); GroupByFieldComboBox.SelectedItem = field; // Group By Field Combo Box field = dataSource.Fields.FirstOrDefault(fld => fld.FieldName == groupByFieldName); GroupByFieldComboBox.SelectedItem = field; // Sort By Field 1 Combo Box field = dataSource.Fields.FirstOrDefault(fld => fld.FieldName == sortByFieldName1); SortByField1ComboBox.SelectedItem = field; // Sort By Field 2 Combo Box field = dataSource.Fields.FirstOrDefault(fld => fld.FieldName == sortByFieldName2); SortByField2ComboBox.SelectedItem = field; } } } // Sort By Field Order Combo Boxes SortByFieldOrder1ComboBox.SelectedIndex = (sortByFieldOrder1 == ListSortDirection.Ascending ? 0 : 1); SortByFieldOrder2ComboBox.SelectedIndex = (sortByFieldOrder2 == ListSortDirection.Ascending ? 0 : 1); // Properties GepHostNameTextBox.Text = vmProperties["GepHostName"]; GepHttpPortTextBox.Text = vmProperties["GepHttpPort"]; GepHttpsPortTextBox.Text = vmProperties["GepHttpsPort"]; }
/// <summary> /// Initializes a new instance of the <see cref="SortDescription"/> class. /// </summary> /// <param name="property">The property to sort on.</param> /// <param name="direction">The sort direction.</param> public SortDescription(PropertyDescriptor property, ListSortDirection direction) { if (property == null) throw new ArgumentNullException("property"); this.property = property; this.name = property.Name; this.dir = direction; }
private void Sort(string sortBy, ListSortDirection direction) { ICollectionView dataView = CollectionViewSource.GetDefaultView(TrackList.ItemsSource); dataView.SortDescriptions.Clear(); SortDescription sd = new SortDescription(sortBy, direction); dataView.SortDescriptions.Add(sd); dataView.Refresh(); }
public ResultData <SearchListResult> List(string taskId, int offset = 0, int limit = 0, FileSortType sortBy = FileSortType.Name, ListSortDirection sortDirection = ListSortDirection.Ascending, string pattern = null, FileType fileType = FileType.All, FileDetailsType?additional = null) { var additionalParams = new[] { new QueryStringParameter("additional", additional), new QueryStringParameter("taskid", taskId), new QueryStringParameter("pattern", pattern), new QueryStringParameter("offset", offset), new QueryStringParameter("filetype", fileType), new QueryStringParameter("limit", limit), new QueryStringParameter("sort_by", sortBy), new QueryStringParameter("sort_direction", sortDirection) }; return(GetData <SearchListResult>(new SynologyRequestParameters { Additional = additionalParams })); }
private static void AddSortGlyph(GridViewColumnHeader columnHeader, ListSortDirection direction, ImageSource sortGlyph) { AdornerLayer.GetAdornerLayer(columnHeader).Add(new SortGlyphAdorner(columnHeader, direction, sortGlyph)); }
public OutlookGridRowComparer(int columnIndex, ListSortDirection direction) { this.columnIndex = columnIndex; this.direction = direction; }
/// <summary> /// 构造一个排序字段名称和排序方式的排序条件 /// </summary> /// <param name="sortField">字段名称</param> /// <param name="listSortDirection">排序方式</param> public SortCondition(string sortField, ListSortDirection listSortDirection) { SortField = sortField; ListSortDirection = listSortDirection; }
/// <summary> /// Constructs a new grid view binding for the given GridView web control. /// Sets up grid listeners to handle the data binding. /// </summary> /// <param name="grid">The GridView control to be bound to the data list object.</param> protected GridViewBinding(GridView grid) : base(grid) { grid.RowDataBound += delegate(object sender, GridViewRowEventArgs e) { DataRow dataRow = e.Row.DataItem as DataRow; if (dataRow == null) { return; } dataRow.List.CurrentRow = e.Row.DataItemIndex; if (dataRow.Selected) { e.Row.ApplyStyle(grid.SelectedRowStyle); } BindToObject(e.Row, dataRow.List, true); }; grid.PageIndexChanging += delegate(object sender, GridViewPageEventArgs e) { if (e.Cancel) { return; } grid.PageIndex = e.NewPageIndex; grid.DataBind(); }; grid.Sorting += delegate(object s, GridViewSortEventArgs e) { if (e.Cancel) { return; } if (list.SortCriteria != null && list.SortCriteria.Count == 1 && list.SortCriteria[0].PropertyName == e.SortExpression) { list.SortCriteria[0].SortDirection = ListSortDirection.Toggle(list.SortCriteria[0].SortDirection); } else { list.SortCriteria = new ListSortCriteria(); ListSortField sortFld = new ListSortField(); sortFld.PropertyName = e.SortExpression; sortFld.SortDirection = e.SortDirection == SortDirection.Ascending ? ListSortDirection.Ascending : ListSortDirection.Descending; list.SortCriteria.Add(sortFld); } list.Sort(); }; grid.RowEditing += delegate(object sender, GridViewEditEventArgs e) { if (e.Cancel || list == null) { return; } grid.EditIndex = e.NewEditIndex; int idx = grid.PageSize * grid.PageIndex + e.NewEditIndex; list.EditRow = new DataRow(list); list.EditRow.CopyFrom(list.GetData()[idx]); grid.DataBind(); }; grid.RowUpdating += delegate(object sender, GridViewUpdateEventArgs e) { if (e.Cancel || list == null) { return; } int idx = grid.PageSize * grid.PageIndex + e.RowIndex; grid.EditIndex = -1; list.EditRow = null; grid.DataBind(); }; grid.RowCancelingEdit += delegate(object sender, GridViewCancelEditEventArgs e) { if (e.Cancel || list == null) { return; } grid.EditIndex = -1; int idx = grid.PageSize * grid.PageIndex + e.RowIndex; if (list.EditRow != null) { list.GetData()[idx].CopyFrom(list.EditRow); list.EditRow = null; grid.DataBind(); // stop editing existing object } else { list.RemoveAt(idx); // delete new object on cancel } }; grid.RowDeleting += delegate(object sender, GridViewDeleteEventArgs e) { if (e.Cancel) { return; } int idx = grid.PageSize * grid.PageIndex + e.RowIndex; if (list != null) { list.RemoveAt(idx); } }; grid.RowCommand += delegate(object sender, GridViewCommandEventArgs e) { if (list == null || e.CommandName != "New") { return; } DataRow newRow = new DataRow(list); int index = 0; if (Int32.TryParse("" + e.CommandArgument, out index)) { index++; } grid.EditIndex = index; list.Insert(grid.PageSize * grid.PageIndex + index, newRow); }; grid.SelectedIndexChanging += delegate(object sender, GridViewSelectEventArgs e) { if (e.Cancel || list == null) { return; } int idx = grid.PageSize * grid.PageIndex + e.NewSelectedIndex; if (list.SelectRow(idx)) { list.FireCollectionChanged(); } // cancel, since we don't really want the grid to set SelectedIndex, which doesn't work for with paging e.Cancel = true; }; // Defer data binding to the Load method after the view state is loaded. // Otherwise the view state will get corrupted. grid.Load += delegate { grid.DataBind(); }; grid.Unload += delegate { BindTo(null); }; }
/// <summary> /// Devuelve una lista ordenada de todos los elementos y sus hijos /// </summary> /// <param name="sortProperty">Campo de ordenación</param> /// <param name="sortDirection">Sentido de ordenación</param> /// <param name="childs">Traer hijos</param> /// <returns>Lista ordenada de elementos</returns> public static SortedBindingList <RegistroDisponibilidadInfo> GetSortedList(DateTime fecha_inicio, string sortProperty, ListSortDirection sortDirection, bool childs) { SortedBindingList <RegistroDisponibilidadInfo> sortedList = new SortedBindingList <RegistroDisponibilidadInfo>(GetList(fecha_inicio, childs)); sortedList.ApplySort(sortProperty, sortDirection); return(sortedList); }
/// <summary> /// Removes any sort applied with ApplySortCore if sorting is implemented /// </summary> protected override void RemoveSortCore() { _sortDirection = ListSortDirection.Ascending; _sortProperty = null; }
public FSPropertyComparer(PropertyDescriptor property, ListSortDirection direction) { m_Property = property; m_Direction = direction; }
/// <summary> /// It is called at selection elements from the storage. /// </summary> /// <param name="startIndex">First element index.</param> /// <param name="count">The number of elements.</param> /// <param name="orderBy">The sorting condition.</param> /// <param name="direction">The sorting direction.</param> /// <returns>The set of elements.</returns> protected override IEnumerable <T> OnGetGroup(long startIndex, long count, Field orderBy, ListSortDirection direction) { lock (SyncRoot) return(base.OnGetGroup(startIndex, count, orderBy, direction)); }
/// <summary> /// Devuelve una lista ordenada de todos los elementos /// </summary> /// <param name="sortProperty">Campo de ordenación</param> /// <param name="sortDirection">Sentido de ordenación</param> /// <returns>Lista ordenada de elementos</returns> public static SortedBindingList <InputInvoiceLineInfo> GetSortedList(string sortProperty, ListSortDirection sortDirection) { SortedBindingList <InputInvoiceLineInfo> sortedList = new SortedBindingList <InputInvoiceLineInfo>(GetList()); sortedList.ApplySort(sortProperty, sortDirection); return(sortedList); }
public virtual void Order(ListSortDirection direction) { Descriptor.SortDirection = direction; }
/// <inheritdoc/> public void ApplySort(PropertyDescriptor property, ListSortDirection direction) { throw new NotSupportedException(); }
public static void SetComparisonParameters(OrderSortType sortBy, ListSortDirection sortDir, bool uniqueSort) { s_comparer = new OrderComparer(sortBy, sortDir, uniqueSort); }
public UpgradeDataGridViewVersionSorter(ListSortDirection direction) : base(direction) { }
/// <summary> /// Removes any sort applied with ApplySortCore if sorting is implemented /// </summary> protected override void RemoveSortCore() { _sortDirection = ListSortDirection.Ascending; _sortProperty = null; _isSorted = false; //thanks Luca }
void GridViewColumnHeaderClickedHandler(object sender, RoutedEventArgs e) { GridViewColumnHeader headerClicked = e.OriginalSource as GridViewColumnHeader; ListSortDirection direction; if (headerClicked != null) { if (headerClicked.Role != GridViewColumnHeaderRole.Padding) { if (headerClicked != _lastHeaderClicked) { direction = ListSortDirection.Ascending; } else { if (_lastDirection == ListSortDirection.Ascending) { direction = ListSortDirection.Descending; } else { direction = ListSortDirection.Ascending; } } if (headerClicked.Column.Header.ToString() == "Linked") { Sort("ParentPolicy.WMIFilters.Count", direction); } else { Binding binding = (Binding)(headerClicked.Column.DisplayMemberBinding); Sort(binding.Path.Path, direction); } if (direction == ListSortDirection.Ascending) { headerClicked.Column.HeaderTemplate = Resources["HeaderTemplateArrowUp"] as DataTemplate; } else { headerClicked.Column.HeaderTemplate = Resources["HeaderTemplateArrowDown"] as DataTemplate; } // Remove arrow from previously sorted header if (_lastHeaderClicked != null && _lastHeaderClicked != headerClicked) { _lastHeaderClicked.Column.HeaderTemplate = null; } _lastHeaderClicked = headerClicked; _lastDirection = direction; } } }
public void TestMangaComparer( [Values(nameof(ILibraryFilterableItem.Name), nameof(ILibraryFilterableItem.Created), nameof(ILibraryFilterableItem.DownloadedAt))] string property, [Values] ListSortDirection direction, [Values] bool isManga) { var comparer = new LibraryFilter(); comparer.SortDescription = new SortDescription(property, direction); (int compareDifferent, int compareEquals) CompareManga() { IManga manga1 = new Readmanga() { Name = "A-Name", Created = DateTime.UtcNow, DownloadedAt = DateTime.UtcNow }; IManga manga2 = new Readmanga() { Name = "b-name", Created = DateTime.UtcNow.AddMinutes(1), DownloadedAt = DateTime.UtcNow.AddMinutes(1) }; IManga manga3 = new Readmanga() { Name = "a-name", Created = DateTime.UtcNow, DownloadedAt = DateTime.UtcNow }; var i = comparer.Compare(manga1, manga2); var compareEquals1 = comparer.Compare(manga1, manga3); return(i, compareEquals1); } (int compareDifferent, int compareEquals) CompareProxy() { ILibraryFilterableItem manga1 = new MangaProxy(new Readmanga() { Name = "A-Name", Created = DateTime.UtcNow, DownloadedAt = DateTime.UtcNow }); ILibraryFilterableItem manga2 = new MangaProxy(new Readmanga() { Name = "b-name", Created = DateTime.UtcNow.AddMinutes(1), DownloadedAt = DateTime.UtcNow.AddMinutes(1) }); ILibraryFilterableItem manga3 = new MangaProxy(new Readmanga() { Name = "a-name", Created = DateTime.UtcNow, DownloadedAt = DateTime.UtcNow }); var i = comparer.Compare(manga1, manga2); var compareEquals1 = comparer.Compare(manga1, manga3); return(i, compareEquals1); } var(compareDifferent, compareEquals) = isManga ? CompareManga() : CompareProxy(); if (direction == ListSortDirection.Descending) { Assert.Greater(compareDifferent, 0); } else { Assert.Less(compareDifferent, 0); } Assert.AreEqual(0, compareEquals); }
/// <summary> /// Sorts the list based on a <see cref="T:System.ComponentModel.PropertyDescriptor" /> and a /// <see cref="T:System.ComponentModel.ListSortDirection" />. /// </summary> /// <param name="property">The <see cref="T:System.ComponentModel.PropertyDescriptor" /> to sort by. </param> /// <param name="direction">One of the <see cref="T:System.ComponentModel.ListSortDirection" /> values. </param> /// <exception cref="T:System.NotSupportedException"> /// <see cref="P:System.ComponentModel.IBindingList.SupportsSorting" /> is /// false. /// </exception> public virtual void ApplySort(PropertyDescriptor property, ListSortDirection direction) { CheckForAndThrowIfDisposed(); (InnerList as IBindingList)?.ApplySort(property, direction); }
public SizeComparer(ListSortDirection listSortDirection) : base(listSortDirection) { }
public SortGlyphAdorner(GridViewColumnHeader columnHeader, ListSortDirection direction, ImageSource sortGlyph) : base(columnHeader) { this._columnHeader = columnHeader; this._direction = direction; this._sortGlyph = sortGlyph; }
private void GridViewHeader_Click(object sender, RoutedEventArgs e) { //TODO: Fix event wiring? if (!(e.OriginalSource is GridViewColumnHeader)) { return; } GridViewColumnHeader headerClicked = e.OriginalSource as GridViewColumnHeader; ListSortDirection direction; if (headerClicked != null) { if (headerClicked.Role != GridViewColumnHeaderRole.Padding) { if (headerClicked != _lastHeaderClicked) { direction = ListSortDirection.Ascending; } else { if (_lastDirection == ListSortDirection.Ascending) { direction = ListSortDirection.Descending; } else { direction = ListSortDirection.Ascending; } } //string header = headerClicked.Column.Header as string; System.Windows.Controls.GridViewColumn colum = headerClicked.Column; string header = ((System.Windows.Data.Binding)(colum.DisplayMemberBinding)).Path.Path; Sort(header, direction); if (direction == ListSortDirection.Ascending) { headerClicked.Column.HeaderTemplate = Resources["HeaderTemplateArrowUp"] as DataTemplate; } else { headerClicked.Column.HeaderTemplate = Resources["HeaderTemplateArrowDown"] as DataTemplate; } // Remove arrow from previously sorted header if (_lastHeaderClicked != null && _lastHeaderClicked != headerClicked) { _lastHeaderClicked.Column.HeaderTemplate = null; } _lastHeaderClicked = headerClicked; _lastDirection = direction; } } }
IEnumerable <TEntity> IStorage.GetGroup <TEntity>(long startIndex, long count, Field orderBy, ListSortDirection direction) { throw new NotSupportedException(); }
public SortAdorner(UIElement element, ListSortDirection dir) : base(element) { Direction = dir; }
private void LoadVMs() { Program.AssertOnEventThread(); if (!Visible) { return; } try { dataGridViewVms.SuspendLayout(); var previousSelection = GetSelectedVMs(); UnregisterEventHandlers(); dataGridViewVms.SortCompare += dataGridViewVms_SortCompare; dataGridViewVms.Rows.Clear(); enableSelectionManager.BindTo(enableButton, Program.MainWindow); disableSelectionManager.BindTo(disableButton, Program.MainWindow); //clear selection enableSelectionManager.SetSelection(new SelectedItemCollection()); disableSelectionManager.SetSelection(new SelectedItemCollection()); foreach (var vm in Connection.Cache.VMs.Where(vm => vm.is_a_real_vm && vm.Show(Properties.Settings.Default.ShowHiddenVMs))) { dataGridViewVms.Rows.Add(NewVmRow(vm)); } if (dataGridViewVms.SortedColumn == null) { dataGridViewVms.Sort(vmDefaultSort); } else { var order = dataGridViewVms.SortOrder; ListSortDirection sortDirection = ListSortDirection.Ascending; if (order.Equals(SortOrder.Descending)) { sortDirection = ListSortDirection.Descending; } dataGridViewVms.Sort(dataGridViewVms.SortedColumn, sortDirection); } if (dataGridViewVms.Rows.Count > 0) { dataGridViewVms.SelectionChanged += VmSelectionChanged; UnselectAllVMs(); // Component defaults the first row to selected if (previousSelection.Any()) { foreach (var row in dataGridViewVms.Rows.Cast <DataGridViewRow>()) { if (previousSelection.Contains((VM)row.Tag)) { row.Selected = true; } } } else { dataGridViewVms.Rows[0].Selected = true; } } } finally { dataGridViewVms.ResumeLayout(); } }
public void ApplySort(PropertyDescriptor property, ListSortDirection direction) { this.ApplySortCore(property, direction); }
public OrderComparer(OrderSortType sortBy, ListSortDirection sortDir, bool uniqueSort) { this.sortBy = sortBy; this.sortDir = sortDir; this.uniqueSort = uniqueSort; }
/// <summary> /// Sort item list by specific direction. /// </summary> /// <param name="direction"></param> private void Sort(ListSortDirection direction) { //it doesn't work, so i use buble sorting //this.mediaListView.Items.SortDescriptions.Clear(); //SortDescription sd = new SortDescription("Name", direction); //this.mediaListView.Items.SortDescriptions.Add(sd); //this.mediaListView.Items.Refresh(); this.SetHeaderArrow(direction); ItemCollection items = this.mediaListView.Items; Object temp; Object selectedItem = this.mediaListView.SelectedItem; //for (int i = 0; i < items.Count; ++i) // for (int j = items.Count - 1; j > i; --j) // { // if (CompareObject(items[j - 1], items[j], direction)) // { // temp = items[j - 1]; // this.mediaListView.Items.Remove(temp); // this.mediaListView.Items.Insert(j, temp); // } // } List <SortedItem> sortedItems = new List <SortedItem>(); for (int i = 0; i < items.Count; ++i) { sortedItems.Add(new SortedItem { Value = ((ItemContent)((ListViewItem)items[i]).Content).Name, Item = items[i] }); } sortedItems.Sort((SortedItem item1, SortedItem item2) => { if (direction == ListSortDirection.Ascending) { return(item1.Value.CompareTo(item2.Value)); } else { return(item2.Value.CompareTo(item1.Value)); } }); for (int i = 0; i < sortedItems.Count; ++i) { if (items[i] != sortedItems[i].Item) { this.mediaListView.Items.Remove(sortedItems[i].Item); this.mediaListView.Items.Insert(i, sortedItems[i].Item); } } if (selectedItem != null) { this.mediaListView.SelectedItem = selectedItem; } _lastDirection = direction; }
public ColumnSortInfo(int index, ListSortDirection direction) { this.Index = index; this.Direction = ColumnSortInfo.Convert(direction); }
private void GridViewColumnHeaderClickedHandler(object sender, RoutedEventArgs e) { var headerClicked = e.OriginalSource as GridViewColumnHeader; // May be triggered by clicking on vertical scrollbar. if (headerClicked != null) { var listView = headerClicked.FindVisualParent <ListView>(); if (headerClicked.Role != GridViewColumnHeaderRole.Padding) { ListSortDirection direction; if (headerClicked != _lastHeaderClicked) { direction = ListSortDirection.Ascending; } else { if (_lastDirection == ListSortDirection.Ascending) { direction = ListSortDirection.Descending; } else { direction = ListSortDirection.Ascending; } } var header = new List <string>(); if (headerClicked.Column is SortableGridViewColumn && ((SortableGridViewColumn)headerClicked.Column).SortBinding is Binding) { var binding = (Binding)((SortableGridViewColumn)headerClicked.Column).SortBinding; header.Add(binding.Path.Path); } else if (headerClicked.Column is SortableGridViewColumn && ((SortableGridViewColumn)headerClicked.Column).SortBinding is MultiBinding) { var multiBinding = (MultiBinding)((SortableGridViewColumn)headerClicked.Column).SortBinding; header.AddRange(multiBinding.Bindings.OfType <Binding>().Select(binding => binding.Path.Path)); } else if (headerClicked.Column.DisplayMemberBinding is Binding) { var binding = headerClicked.Column.DisplayMemberBinding as Binding; header.Add(binding.Path.Path); } else { header.Add(headerClicked.Column.Header as string); } if (header.Count == 0) { return; } Sort(listView, header, direction); if (direction == ListSortDirection.Ascending) { if (ColumnHeaderArrowUpTemplate != null) { headerClicked.Column.HeaderTemplate = ColumnHeaderArrowUpTemplate; } } else { if (ColumnHeaderArrowDownTemplate != null) { headerClicked.Column.HeaderTemplate = ColumnHeaderArrowDownTemplate; } } // Remove arrow from previously sorted header if (_lastHeaderClicked != null && _lastHeaderClicked != headerClicked) { _lastHeaderClicked.Column.HeaderTemplate = null; } _lastHeaderClicked = headerClicked; _lastDirection = direction; } } }
/// <summary> /// 按指定的属性名称对<see cref="IOrderedQueryable{T}"/>序列进行排序 /// </summary> /// <param name="source">IOrderedQueryable{T}序列</param> /// <param name="propertyName">属性名称</param> /// <param name="sortDirection">排序方向</param> /// <returns></returns> public static IOrderedQueryable <T> ThenBy(IOrderedQueryable <T> source, string propertyName, ListSortDirection sortDirection) { dynamic keySelector = GetKeySelector(propertyName); return(sortDirection == ListSortDirection.Ascending ? Queryable.ThenBy(source, keySelector) : Queryable.ThenByDescending(source, keySelector)); }