// Constructor public TaskListPage() { InitializeComponent(); // trace data TraceHelper.AddMessage("TaskList: constructor"); // set some data context information ConnectedIconImage.DataContext = App.ViewModel; SpeechProgressBar.DataContext = App.ViewModel; // set some data context information for the speech UI SpeechPopup_SpeakButton.DataContext = this; SpeechPopup_CancelButton.DataContext = this; SpeechLabel.DataContext = this; OrderedSource = new List<CollectionViewSource>(); // add the name viewsource (which is a sorted view of the tasklist by name) var nameViewSource = new CollectionViewSource(); using (nameViewSource.DeferRefresh()) { nameViewSource.SortDescriptions.Add(new SortDescription("Complete", ListSortDirection.Ascending)); nameViewSource.SortDescriptions.Add(new SortDescription("Name", ListSortDirection.Ascending)); OrderedSource.Add(nameViewSource); ByNameListBox.DataContext = this; } // add the due viewsource (which is a sorted view of the tasklist by due date) var dueViewSource = new CollectionViewSource(); using (dueViewSource.DeferRefresh()) { dueViewSource.SortDescriptions.Add(new SortDescription("Complete", ListSortDirection.Ascending)); dueViewSource.SortDescriptions.Add(new SortDescription("DueSort", ListSortDirection.Ascending)); dueViewSource.SortDescriptions.Add(new SortDescription("Name", ListSortDirection.Ascending)); OrderedSource.Add(dueViewSource); ByDueListBox.DataContext = this; } // add the priority viewsource (which is a sorted view of the tasklist by priority) var priViewSource = new CollectionViewSource(); using (priViewSource.DeferRefresh()) { priViewSource.SortDescriptions.Add(new SortDescription("Complete", ListSortDirection.Ascending)); priViewSource.SortDescriptions.Add(new SortDescription("PriorityIDSort", ListSortDirection.Descending)); priViewSource.SortDescriptions.Add(new SortDescription("Name", ListSortDirection.Ascending)); OrderedSource.Add(priViewSource); ByPriListBox.DataContext = this; } ImportTemplateViewSource = new CollectionViewSource(); ImportTemplateViewSource.Filter += new FilterEventHandler(ImportTemplate_Filter); Loaded += new RoutedEventHandler(TaskListPage_Loaded); BackKeyPress += new EventHandler<CancelEventArgs>(TaskListPage_BackKeyPress); // trace data TraceHelper.AddMessage("Exiting TaskList constructor"); }
private void updateDataGrid1Timer_Tick(object sender, EventArgs e) { _Schiphol_ACXS_ScriptDataSetContainerTableAdapter.Fill(_Schiphol_ACXS_ScriptDataSet.Container); System.Windows.Data.CollectionViewSource containerViewSource = ((System.Windows.Data.CollectionViewSource)(this.FindResource("containerViewSource"))); using (containerViewSource.DeferRefresh()) { containerViewSource.View.Refresh(); } DataRow[] datarows = _Schiphol_ACXS_ScriptDataSet.Container.Select(string.Format("ULDNumber = '{0}'", ULDNumberInput.Text.Replace(" ", ""))); if (m_CaseObj.scanInfo != null && m_CaseObj.scanInfo.container != null && m_CaseObj.scanInfo.container.Id != null) { m_CaseObj.scanInfo.container.Id = ULDNumberInput.Text; } if (datarows.Length > 0) { dataGrid1.SelectedValuePath = "ULDNumber"; dataGrid1.SelectedValue = datarows[0]["ULDNumber"]; } }
void UpdateIncrementalSearch(TextBox textBox, CollectionViewSource collectionViewSource, ref FilterEventHandler oldFilter) { var text = textBox.Text.Split(' ', ' '); using (collectionViewSource.DeferRefresh()) { FilterEventHandler newFilter = (sender2, e2) => e2.Accepted = e2.Accepted && (!text.Any() || e2.Item.TypeMatch ( (FollowManagerWindowViewModel.Follow _) => new[] { _.User.Name, _.User.FullName, _.User.Description }, (User _) => new[] { _.Name, _.FullName, _.Description }, _ => Enumerable.Empty<string>() ) .Where(_ => _ != null) .Any(_ => text.All(_.Contains))); collectionViewSource.Filter += newFilter; if (oldFilter != null) collectionViewSource.Filter -= oldFilter; oldFilter = newFilter; } }
public void GroupsAreRecreated () { Func<object, object, bool> nameMatcher = (groupName, itemName) => (string) groupName == (string) itemName; Func<object, int, CultureInfo, object> nameCreator = (item, level, culture) => ((int) item <= 2 ? "Lower" : "Upper") + level.ToString (); var desc = new ConcretePropertyGroupDescription () { GroupNameFromItemFunc = nameCreator, NamesMatchFunc = nameMatcher }; var source = new CollectionViewSource { Source = new [] { 0, 1, 2, 3, 4, 5 } }; source.GroupDescriptions.Add (desc); var groups = source.View.Groups; var lowerGroup = (CollectionViewGroup) source.View.Groups [0]; var upperGroup = (CollectionViewGroup) source.View.Groups [1]; using (source.DeferRefresh ()) using (source.View.DeferRefresh ()) { source.GroupDescriptions.Clear (); source.GroupDescriptions.Add (desc); } Assert.AreSame (groups, source.View.Groups, "#1"); Assert.AreNotSame (lowerGroup, source.View.Groups [0], "#2"); Assert.AreNotSame (upperGroup, source.View.Groups [1], "#3"); }
public DocumentsPageModel() { ModelUrl = "/documents"; ApplicationModel.Current.Server.Value.RawUrl = null; SelectedCollectionSortingMode = new Observable<string> { Value = Settings.Instance.CollectionSortingMode }; collectionSource = new CollectionDocumentsCollectionSource(); collectionDocumentsModel = new DocumentsModel(collectionSource) { DocumentNavigatorFactory = (id, index) => DocumentNavigator.Create(id, index, CollectionsIndex, new IndexQuery { Query = "Tag:" + GetSelectedCollectionName() }) }; collectionDocumentsModel.SetChangesObservable(d => d.IndexChanges .Where(n => n.Name.Equals(CollectionsIndex, StringComparison.InvariantCulture)) .Select(m => Unit.Default)); allDocumentsDocumentsModel = new DocumentsModel(new DocumentsCollectionSource()) { DocumentNavigatorFactory = (id, index) => DocumentNavigator.Create(id, index), Context = "AllDocuments", }; allDocumentsDocumentsModel.SetChangesObservable(d => d.DocumentChanges.Select(s => Unit.Default)); ravenDocumentsDocumentsModel = new DocumentsModel(new CollectionDocumentsCollectionSource()); ravenDocumentsDocumentsModel.SetChangesObservable(d => d.DocumentChanges.Select(s => Unit.Default)); Collections = new BindableCollection<CollectionModel>(model => model.Name) { new AllDocumentsCollectionModel(), new RavenDocumentsCollectionModel() }; SelectedCollection = new Observable<CollectionModel>(); SelectedCollection.PropertyChanged += (sender, args) => { PutCollectionNameInTheUrl(); var selectedCollectionName = GetSelectedCollectionName(); if (selectedCollectionName == "") { DocumentsModel = allDocumentsDocumentsModel; } else if (selectedCollectionName == "Raven Documents") { DocumentsModel = ravenDocumentsDocumentsModel; } else { collectionSource.CollectionName = selectedCollectionName; collectionDocumentsModel.Context = "Collection/" + GetSelectedCollectionName(); DocumentsModel = collectionDocumentsModel; } }; SortedCollectionsList = new CollectionViewSource { Source = Collections, SortDescriptions = { GetSortDescription() } }; SelectedCollectionSortingMode.PropertyChanged += (sender, args) => { using (SortedCollectionsList.DeferRefresh()) { SortedCollectionsList.SortDescriptions.Clear(); SortedCollectionsList.SortDescriptions.Add(GetSortDescription()); } Settings.Instance.CollectionSortingMode = SelectedCollectionSortingMode.Value; }; CollectionsListWidth = DefaultCollectionsListWidth; }