private void Client_GetDataCompleted(object sender, GetDataCompletedEventArgs e) { collection = new PagedCollectionView((System.Collections.IEnumerable)e.Result); dgCliente.ItemsSource = collection; client.CloseAsync(); }
void mc_srv_select_RDCompleted(object sender, srv_select_RDCompletedEventArgs e) { if (e.Result != null) { if (e.Result.Count > 0) { PagedCollectionView c1 = new PagedCollectionView(e.Result); //c1.GroupDescriptions.Add(new PropertyGroupDescription("")); listRD = new List <RD_ex>(); string name = e.Result[0].Contractor_Name; RD_ex R = new RD_ex(name); foreach (cRD item in c1) { if (name != item.Contractor_Name) { listRD.Add(R); name = item.Contractor_Name; R = new RD_ex(name); } R.addItem(item.MassType, item.Sort_Name, item.Val.ToString()); } dgCol = new PagedCollectionView(GenerateDataB().ToDataSource()); dg_B.ItemsSource = dgCol; //dg_F.ItemsSource = GenerateDataF().ToDataSource(); } } }
public int IndexOf(object dataItem) { IList list = this.List; if (list != null) { return(list.IndexOf(dataItem)); } PagedCollectionView cv = this.DataSource as PagedCollectionView; if (cv != null) { return(cv.IndexOf(dataItem)); } IEnumerable enumerable = this.DataSource; if (enumerable != null && dataItem != null) { int index = 0; foreach (object dataItemTmp in enumerable) { if ((dataItem == null && dataItemTmp == null) || dataItem.Equals(dataItemTmp)) { return(index); } index++; } } return(-1); }
void frm_CallBack1(object sender, Tarification.Helper.CustumEventArgs e) { //Implementer le callback if (e.Bag != null) { var ListFacture = (List <CsLclient>)e.Bag; PagedCollectionView pvc = (PagedCollectionView)dg_facture_Copy.ItemsSource; List <CsLclient> datasource = (List <CsLclient>)pvc.SourceCollection; if (datasource == null) { datasource = new List <CsLclient>(); } foreach (var item in ListFacture) { if (datasource.FirstOrDefault(f => f.CENTRE == item.CENTRE && f.CLIENT == item.CLIENT && f.ORDRE == item.ORDRE && f.NDOC == item.NDOC) == null) { datasource.Add(item); } } //dg_facture_Copy.ItemsSource = datasource; LoadDataPager <CsLclient>(datasource, datapager_Copy, dg_facture_Copy); } }
void obj_GetAllQuestionsCompleted(object sender, AdminService.GetAllQuestionsCompletedEventArgs e) { PagedCollectionView objp = new PagedCollectionView(e.Result); DataPager1.Source = objp; gvQuestions.ItemsSource = objp; }
void loadOperation_Completed(object sender, EventArgs e) { UserList.Clear(); LoadOperation loadOperation = sender as LoadOperation; foreach (ProductManager.Web.Model.user user in loadOperation.Entities) { if (user.user_name == "admin") { continue; } UserEntity userEntity = new UserEntity(); userEntity.User = user; userEntity.Update(); DepartmentEntity departmentEntity; if (DepartmentDictionary.TryGetValue(userEntity.UserDepartmentID, out departmentEntity)) { userEntity.UserDepartment = departmentEntity.DepartmentName; UserList.Add(userEntity); } } PagedCollectionView lPagedCollectionView = new PagedCollectionView(UserList); lPagedCollectionView.GroupDescriptions.Add(new PropertyGroupDescription("UserDepartment")); UserDataView = lPagedCollectionView; UserDataView.Refresh(); UpdateChanged("UserList"); IsBusy = false; finishLoaded(); }
public void ChangePageSizeWithGroupingTest() { List <int> intList = new List <int>() { 1, 2, 3, 4, 5, 1, 2, 3, 4, 5 }; PagedCollectionView pcv = new PagedCollectionView(intList); pcv.GroupDescriptions.Add(new PropertyGroupDescription("")); Assert.AreEqual(10, pcv.Count); // set the initial PageSize pcv.PageSize = 5; Assert.AreEqual(5, pcv.Count); // change the PageSize and check that we update the // groups - which in turn updates the count. pcv.PageSize = 7; Assert.AreEqual(7, pcv.Count); // change the PageSize to a smaller number and // test again pcv.PageSize = 3; Assert.AreEqual(3, pcv.Count); }
private void LoadAllDepartmentCompletedHelper() { try { dispatcher.BeginInvoke (() => { if (Utility.FaultExist(departmentService.Fault)) { return; } if (departmentService.Models != null && departmentService.Models.Count > 0) { ObservableCollection <Department> depts = new ObservableCollection <Department>(); depts = departmentService.Models; depts.Insert(0, new Department() { Id = "", Name = "<< Select Department >>" }); Departments = new PagedCollectionView(depts); Departments.MoveCurrentToFirst(); Departments.CurrentChanged += (s, e) => { Department = Departments.CurrentItem as Department; }; } }); } catch (Exception ex) { Utility.DisplayMessage(ex.Message); } }
public void CannotRefreshTest() { ObservableCollection <TestClass> collection = new ObservableCollection <TestClass>() { new TestClass() }; PagedCollectionView pcv = new PagedCollectionView(collection); // show that we will throw an exception if we try to change the PageSize while adding pcv.AddNew(); PagedCollectionViewTest.AssertExpectedException( new InvalidOperationException(string.Format(CultureInfo.InvariantCulture, PagedCollectionViewResources.OperationNotAllowedDuringAddOrEdit, "Refresh")), delegate { pcv.Refresh(); }); pcv.CancelNew(); // show that we will throw an exception if we try to change the PageSize while editing pcv.EditItem(pcv[0]); PagedCollectionViewTest.AssertExpectedException( new InvalidOperationException(string.Format(CultureInfo.InvariantCulture, PagedCollectionViewResources.OperationNotAllowedDuringAddOrEdit, "Refresh")), delegate { pcv.Refresh(); }); }
public void CannotSortTest() { List <TestClass> intList = new List <TestClass>() { new TestClass() }; PagedCollectionView pcv = new PagedCollectionView(intList); // we are not allowed to sort during an edit operation pcv.EditItem(pcv[0]); PagedCollectionViewTest.AssertExpectedException( new InvalidOperationException(string.Format(CultureInfo.InvariantCulture, PagedCollectionViewResources.OperationNotAllowedDuringAddOrEdit, "Sorting")), delegate { pcv.SortDescriptions.Clear(); }); pcv.CommitEdit(); // we are not allowed to sort during an add new operation pcv.AddNew(); PagedCollectionViewTest.AssertExpectedException( new InvalidOperationException(string.Format(CultureInfo.InvariantCulture, PagedCollectionViewResources.OperationNotAllowedDuringAddOrEdit, "Sorting")), delegate { pcv.SortDescriptions.Clear(); }); }
public void CannotChangePageSize() { ObservableCollection <TestClass> collection = new ObservableCollection <TestClass>() { new TestClass() }; PagedCollectionView pcv = new PagedCollectionView(collection); // show that we will throw an exception if we try to change the PageSize while adding pcv.AddNew(); PagedCollectionViewTest.AssertExpectedException( new InvalidOperationException(PagedCollectionViewResources.ChangingPageSizeNotAllowedDuringAddOrEdit), delegate { pcv.PageSize = 10; }); pcv.CancelNew(); // show that we will throw an exception if we try to change the PageSize while editing pcv.EditItem(pcv[0]); PagedCollectionViewTest.AssertExpectedException( new InvalidOperationException(PagedCollectionViewResources.ChangingPageSizeNotAllowedDuringAddOrEdit), delegate { pcv.PageSize = 10; }); }
private void PopulateYears(int beginYearFrom) { try { //dispatcher.BeginInvoke // (() => // { ObservableCollection <Value> years = Utility.CreateYearListFrom(beginYearFrom); if (years != null && years.Count > 0) { //years.Insert(0, new Value() { Id = 0, Name = "<< Select Year >>" }); Years = new PagedCollectionView(years); Years.MoveCurrentToFirst(); Years.CurrentChanged += (s, e) => { Year = Years.CurrentItem as Value; }; } //}); } catch (Exception ex) { Utility.DisplayMessage(ex.Message); } }
private void LoadAllPeriodTypeCompletedHelper() { try { dispatcher.BeginInvoke (() => { if (Utility.FaultExist(periodTypeService.Fault)) { return; } if (periodTypeService.Models != null && periodTypeService.Models.Count > 0) { periodTypeService.Models.Insert(0, new PeriodType() { Id = 0, Name = "<< Select Type >>" }); Types = new PagedCollectionView(periodTypeService.Models); Types.MoveCurrentToFirst(); Types.CurrentChanged += (s, e) => { Type = Types.CurrentItem as PeriodType; }; } }); } catch (Exception ex) { Utility.DisplayMessage(ex.Message); } }
private void PopulateStaffs() { try { List <Staff> staffs = staffService.Models.Where(s => s.Id == "0").ToList(); if (staffs == null || staffs.Count == 0) { staffService.Models.Insert(0, new Infrastructure.MangoService.Staff() { Id = "0", IsActive = true, FullName = "<< Select Satff >>" }); } Staffs = new PagedCollectionView(staffService.Models); Staffs.MoveCurrentToFirst(); Staffs.CurrentChanged += (s, e) => { Staff = Staffs.CurrentItem as Infrastructure.MangoService.Staff; }; } catch (Exception ex) { Utility.DisplayMessage(ex.Message); } }
public void RefreshWithNonIListSourceTest() { TestEnumerableCollection list = new TestEnumerableCollection(); list.Add(new TestClass { IntProperty = 1, StringProperty = "Test 1" }); list.Add(new TestClass { IntProperty = 2, StringProperty = "Test 2" }); PagedCollectionView pcv = new PagedCollectionView(list); pcv.SortDescriptions.Add(new SortDescription("IntProperty", ListSortDirection.Ascending)); Assert.AreEqual(2, pcv.Count); // add items to list and Refresh list.Add(new TestClass() { IntProperty = 3, StringProperty = "Test 3" }); list.Add(new TestClass() { IntProperty = 4, StringProperty = "Test 4" }); pcv.Refresh(); Assert.AreEqual(4, pcv.Count); // remove items from list and Refresh list.RemoveAt(0); list.RemoveAt(0); pcv.Refresh(); Assert.AreEqual(2, pcv.Count); }
private void Client_GetAMOCubosCompleted(object sender, GetAMOCubosCompletedEventArgs e) { collectionView = new PagedCollectionView(e.Result.ToList()); ListaAMOCubos.ItemsSource = collectionView; ListaAMOCubos.SelectedIndex = 0; }
public void ResetWithListBoxTest() { ObservableCollection <int> oc = new ObservableCollection <int>() { 1, 2, 4, 5 }; PagedCollectionView cv = new PagedCollectionView(oc); ListBox lb = new ListBox(); lb.ItemsSource = cv; this.CreateAsyncTask( lb, delegate { Assert.AreEqual(4, lb.Items.Count); cv.Refresh(); Assert.AreEqual(4, lb.Items.Count); oc.Insert(2, 3); Assert.AreEqual(5, lb.Items.Count); cv.Refresh(); Assert.AreEqual(5, lb.Items.Count); }); EnqueueTestComplete(); }
/// <summary> /// Initializes a DataGridMasterDetailsSample. /// </summary> public DataGridMasterDetailSample() { InitializeComponent(); PagedCollectionView pcv = new PagedCollectionView(Contact.People); DataContext = pcv; }
public void SortAndGroupOnSameNullableProperty() { ObservableCollection <object> collection = new ObservableCollection <object>() { new ClassA() { NullableIntProperty = 4, SomeProperty = "A" }, new ClassA() { NullableIntProperty = 2, SomeProperty = "B" }, new ClassA() { NullableIntProperty = 1, SomeProperty = "C" }, new ClassA() { NullableIntProperty = 3, SomeProperty = "D" }, }; PagedCollectionView pcv = new PagedCollectionView(collection); // add a sort description and a group description on the same nullable property pcv.SortDescriptions.Add(new SortDescription("NullableIntProperty", ListSortDirection.Ascending)); pcv.GroupDescriptions.Add(new PropertyGroupDescription("NullableIntProperty")); // verify that the items appear in the correct order Assert.AreEqual("0 C", pcv[0].ToString()); Assert.AreEqual("0 B", pcv[1].ToString()); Assert.AreEqual("0 D", pcv[2].ToString()); Assert.AreEqual("0 A", pcv[3].ToString()); }
void SysLoginClient_GetSysUserLoginRecordInfosBySearchCompleted(object sender, GetSysUserLoginRecordInfosBySearchCompletedEventArgs e) { PagedCollectionView pcv = null; if (!e.Cancelled) { if (e.Result != null) { List <V_UserLoginRecord> LoginList = e.Result.ToList(); var q = from ent in LoginList select ent; pcv = new PagedCollectionView(q); pcv.PageSize = 25; dataPager.DataContext = pcv; DtGrid.ItemsSource = pcv; //this.DtGrid.ItemsSource = e.Result.ToList(); } else { //ComfirmWindow.ConfirmationBox(Utility.GetResourceStr("CONFIRMINFO"), "没有找到数据", Utility.GetResourceStr("CONFIRMBUTTON")); ComfirmWindow.ConfirmationBoxs(Utility.GetResourceStr("ERROR"), "没有找到数据", Utility.GetResourceStr("CONFIRM"), MessageIcon.Information); } } loadbar.Stop(); }
private void Client_GetProbabilidadeSucessoEtniaCompleted(object sender, GetProbabilidadeSucessoEtniaCompletedEventArgs e) { collection = new PagedCollectionView(e.Result); collection.PageSize = 20; dgProbSucessoTema.ItemsSource = collection; DataContext = collection; }
// Assumes index >= 0, returns null if index >= Count public object GetDataItem(int index) { Debug.Assert(index >= 0); IList list = this.List; if (list != null) { return((index < list.Count) ? list[index] : null); } PagedCollectionView collectionView = this.DataSource as PagedCollectionView; if (collectionView != null) { return((index < collectionView.Count) ? collectionView.GetItemAt(index) : null); } IEnumerable enumerable = this.DataSource; if (enumerable != null) { IEnumerator enumerator = enumerable.GetEnumerator(); int i = -1; while (enumerator.MoveNext() && i < index) { i++; if (i == index) { return(enumerator.Current); } } } return(null); }
private void Client_ADOMDGetCubeEvaConEntradaSaidaCompleted(object sender, ADOMDGetCubeEvaConEntradaSaidaCompletedEventArgs e) { collectionView = new PagedCollectionView(e.Result); collectionView.GroupDescriptions.Add(new PropertyGroupDescription("Campus")); collectionView.GroupDescriptions.Add(new PropertyGroupDescription("Curso")); MyPiv.ItemsSource = collectionView; }
private void Client_RelEvadidosPorCampusAnoCompleted(object sender, RelEvadidosPorCampusAnoCompletedEventArgs e) { view = new PagedCollectionView(e.Result); view.PageSize = 10; dgRelEvasao.ItemsSource = view; this.DataContext = view; }
private void Client_GetEvadidosPorCursoAnoCompleted(object sender, GetEvadidosPorCursoAnoCompletedEventArgs e) { collectionView = new PagedCollectionView(e.Result); collectionView.PageSize = 10; this.DataContext = collectionView; }
public ChatViewModel(IChatService chatService) { this.contacts = new ObservableCollection <Contact>(); this.contactsView = new PagedCollectionView(this.contacts); this.sendMessageRequest = new InteractionRequest <SendMessageViewModel>(); this.showReceivedMessageRequest = new InteractionRequest <ReceivedMessage>(); this.showDetailsCommand = new ShowDetailsCommandImplementation(this); this.contactsView.CurrentChanged += this.OnCurrentContactChanged; this.chatService = chatService; this.chatService.Connected = true; this.chatService.ConnectionStatusChanged += (s, e) => this.RaisePropertyChanged(() => this.ConnectionStatus); this.chatService.MessageReceived += this.OnMessageReceived; this.chatService.GetContacts( result => { if (result.Error == null) { foreach (var item in result.Result) { this.contacts.Add(item); } } }); }
void BindData(IEnumerable <Device> deviceList) { m_pagedList = new PagedCollectionView(deviceList); ListBoxDeviceList.ItemsSource = m_pagedList; DataPagerDevices.Source = m_pagedList; ListBoxDeviceList.SelectedIndex = -1; }
public OrderView() { InitializeComponent(); viewModel = (OrderViewModel)this.Resources["OrderViewModelDataSource"]; // Загрузка Orders при запуске приложения: this.Loaded += (sender, args) => viewModel.SelectCommand.Execute(null); // Обработка событий viewModel, извещающих о завершении асинхронных операций: viewModel.PropertyChanged += (sender, args) => { if (args.PropertyName == "SelectAsyncCompleted") { viewModelPagedCollection = new PagedCollectionView(viewModel.Orders); this.Dispatcher.BeginInvoke(() => { this.C1DataPagerOrder.Source = viewModelPagedCollection; C1DataPagerOrder.Source = viewModelPagedCollection; }); } if (args.PropertyName == "SelectedOrder") { ButtonDeleteOrder.Command = viewModel.DeleteCommand; } }; // Подписка на событие обновления (или добавления, если Id == 0) строки DataGrid - вызов команды viewModel: C1DataGridOrder.CommittedRowEdit += (sender, args) => viewModel.UpdateCommand.Execute(args.Row.DataItem); //ButtonSaveChanges.Click += SaveChanges; }
private void Client_ExecutarMDXQueryCompleted(object sender, ExecutarMDXQueryCompletedEventArgs e) { collectionView = new PagedCollectionView(e.Result); collectionView.PageSize = 15; collectionView.GroupDescriptions.Add(new PropertyGroupDescription("ColunaA")); this.DataContext = collectionView; }
void MDFComboTreeTest_Loaded(object sender, RoutedEventArgs e) { var source = new PagedCollectionView( new List <item>() { new item() { Id = "黄金叶", Name = "产品路线1" }, new item() { Id = "黄金叶", Name = "产品路线2" }, new item() { Id = "硬帝豪", Name = "产品路线1" } }); source.GroupDescriptions.Add(new PropertyGroupDescription("Id")); this.combo.GridItemSource = source; this.combo.SelectedIndex = 0; }
private void GetImagesQueryCallback(LoadOperation<FileModel> result) { if (!result.HasError) { if ((_keywords == null && null == result.UserState) || _keywords.Equals(result.UserState)) { _items = new ObservableCollection<FileModel>(result.Entities); View = new PagedCollectionView(_items); } else { Refresh(); return; } } _refreshCommand.RaiseCanExecuteChanged(); IsBusy = false; }