private void ApplySelectedItems() { if (!SourceItems.Any(x => x.IsSelected)) { return; } Settings.Current.RailwayIdPriority = SourceItems .Where(x => x.IsSelected) .OrderBy(x => x.Order) .SelectMany(x => x.RailwayIds) .ToArray(); }
private async void Delete() { if (HIOStaticValues.CheckSyncingData()) { return; } if (TMessageBox.Show("Are you sure you want to delete these accounts?", "Confirm", MessageBoxButton.YesNo) == MessageBoxResult.Yes) { Commands cmd = new Backend.Commands(); while (true) { var res = cmd.AmISync(); if (res == SyncronizingStateEnum.Synced) { break; } else { HIOStaticValues.SyncOpration(); } } await UIService.Execute(async() => { DataBase db = new DataBase(); foreach (var item in SourceItems.Where(t => t.IsChecked).ToArray()) { Commands ic = new Commands(); if (ic.Delete(item.UserID)) { App.Current.Dispatcher.BeginInvoke((Action)(() => { SourceItems.Remove(SourceItems.FirstOrDefault(i => i.UserID == item.UserID)); OnPropertyChanged(nameof(Items)); })); } } await LoadData(); }); OnPropertyChanged(nameof(IsAllChecked)); } }
private void ChangeSelectedItems() { int index = 0; foreach (var item in SourceItems) { if ((SelectedIndices != null) && SelectedIndices.Contains(index)) { if (!item.IsSelected) { item.IsSelected = true; } } else { item.IsSelected = false; item.Order = 0; } index++; } var sortedItems = SourceItems .Where(x => x.IsSelected) .OrderBy(x => x.SelectedDate) .ThenBy(x => x.Order) .ToArray(); int order = 0; foreach (var item in sortedItems) { var matchingItem = SourceItems.FirstOrDefault(x => x.RailwayIds[0] == item.RailwayIds[0]); if (matchingItem != null) { matchingItem.Order = ++order; } } RaiseCanExecuteChanged(); }