public MainPageViewModel() { this.Examples = ExampleLibrary.Examples.GetList(); var groups = this.Examples.GroupBy(example => example.Category).OrderBy(g => g.Key); var ex = new CollectionViewSource { Source = groups, IsSourceGrouped = true }; this.ExamplesView = ex.View; }
private async void Initialize() { ContractsViewModel vm = null; await Task.Delay(30); var t = Task.Run(async () => { vm = SimpleIoc.Default.GetInstanceWithoutCaching<ContractsViewModel>(); countries = await vm.GetCountries().ConfigureAwait(false); }); await Task.WhenAll(t, loadedTsc.Task); DataContext = vm; contractCollectionViewSource = new CollectionViewSource { IsSourceGrouped = true, Source = countries, ItemsPath = new PropertyPath("Contracts") }; ContractListView.ItemsSource = contractCollectionViewSource.View; ContractsListViewZoomOut.ItemsSource = contractCollectionViewSource.View.CollectionGroups; foreach (var country in countries) { if (country.ImageByteArray != null) { var bitmap = await ByteArrayToImageAsync(country.ImageByteArray as byte[]); bitmap.DecodePixelWidth = 60; country.ImageSource = bitmap; } await Task.Delay(1); } }
protected override void OnNavigatedTo(NavigationEventArgs e) { TravelList t = e.Parameter as TravelList; Cat = new ObservableCollection<Category>(); CompareItems = new List<Item>(); t_id = t.Id; if (t.Categories != null && t.Categories.Count != 0) { foreach (Category c in t.Categories) { if(c.Items.Count==0) { ObservableCollection<Item> items = new ObservableCollection<Item>(); c.Items = items; } Cat.Add(c); } } CompareItems = CopyItems(Cat); // Cat = Dummycon.Categories; CollectionViewSource listViewSource = new CollectionViewSource(); listViewSource.IsSourceGrouped = true; listViewSource.Source = Cat; listViewSource.ItemsPath = new PropertyPath("Items"); Cats.ItemsSource = listViewSource.View; Cats.SelectedItem = null; listViewSummary.ItemsSource = listViewSource.View.CollectionGroups; CategorieBox.ItemsSource = Cat; if(t.Categories.Count!=0) CategorieBox.SelectedIndex = 0; }
public CameraClientViewModel() { FramesProcessed += async f => { await Task.Yield(); }; Cameras = new CollectionViewSource(); Resolutions = new CollectionViewSource(); Dispatcher = Cameras.Dispatcher; CurrentImage = this.NewProperty(x => x.CurrentImage); SelectedCamera = this.NewProperty(x => x.SelectedCamera); SelectedResolution = this.NewProperty(x => x.SelectedResolution); Countdown = this.NewProperty(x => x.Countdown); CountdownVisible = this.NewProperty(x => x.CountdownVisible); RecordingVisibility = this.NewProperty(x => x.RecordingVisibility); CountdownVisible.Value = Visibility.Collapsed; RecordingVisibility.Value = Visibility.Collapsed; _controller = new ClientController(); _controller.PrepareForRecording += PrepareForRecording; _controller.RecordingStarted += RecordingStarted; _controller.RecordingCompleted += RecordingCompleted; Record = new ActionCommand(RecordVideo); SelectedCamera.Changed += SelectedCameraChanged; SelectedResolution.Changed += SelectedResolutionChanged; _remote = new CameraClientRemoteControl(this, _controller); }
async private void WordBookInit() { StorageFolder localFolder = ApplicationData.Current.LocalFolder; StorageFile file = await localFolder.GetFileAsync(App.WordBookFileName); String fileText = await FileIO.ReadTextAsync(file); xBook = XDocument.Parse(fileText); XElement xWord = xBook.Root; IEnumerable<XElement> items = xWord.Elements(XName.Get("item")); ObservableCollection<WordItem> myWordList = new ObservableCollection<WordItem>(); foreach(XElement item in items) { WordItem words = new WordItem(); words.Key = item.Element(XName.Get("key")).Value; words.Ps = item.Element(XName.Get("ps")).Value; words.Acception = item.Element(XName.Get("acceptation")).Value; words.Time = item.Element(XName.Get("time")).Value; myWordList.Add(words); } List<WordGroup> Items = (from item in myWordList group item by item.Time into newitems select new WordGroup { TimeTitle = newitems.Key, WordItemContent = new ObservableCollection<WordItem>(newitems) }).ToList(); newItems = new ObservableCollection<WordGroup>(Items); CollectionViewSource ListWordSource = new CollectionViewSource(); ListWordSource.IsSourceGrouped = true; ListWordSource.Source = newItems; ListWordSource.ItemsPath = new PropertyPath("WordItemContent"); outView.ItemsSource = ListWordSource.View.CollectionGroups; inView.ItemsSource = ListWordSource.View; }
public BluetoothAdvertismentViewerViewModel() { _table = new ConcurrentDictionary<string, BluetoothLEAdvertismentViewModel>(); _devices = new ObservableCollection<BluetoothLEAdvertismentViewModel>(); Advertisements = new CollectionViewSource(); Advertisements.Source = _devices; _dispatcher = Advertisements.Dispatcher; _watcher = new BluetoothLEAdvertisementWatcher(); // Finally set the data payload within the manufacturer-specific section // Here, use a 16-bit UUID: 0x1234 -> {0x34, 0x12} (little-endian) //var writer = new DataWriter(); //writer.WriteUInt16(0x1234); //manufacturerData.Data = writer.DetachBuffer(); //watcher.AdvertisementFilter.Advertisement.ManufacturerData.Add(manufacturerData); _watcher.SignalStrengthFilter.InRangeThresholdInDBm = -70; _watcher.SignalStrengthFilter.OutOfRangeThresholdInDBm = -75; _watcher.SignalStrengthFilter.OutOfRangeTimeout = TimeSpan.FromMilliseconds(2000); _watcher.Received += OnAdvertisementReceived; _watcher.Stopped += OnAdvertisementWatcherStopped; RunCommand = new SimpleCommand(StartWatcher); StopCommand = new SimpleCommand(StopWatcher, false); }
public GraphsViewModel(GraphRepository repository, INavigationService navigationService) { _repository = repository; _navigationService = navigationService; Graphs = new BindableCollection<object>(); CollectionViewSource source = new CollectionViewSource(); }
public MapCameraViewModel(RemoteCameraModel model) { var i = index++%colors.Count; Background = new SolidColorBrush(colors[i]); Name = model.IPAddress.ToString(); Frames = new CollectionViewSource(); FramesVisible = Visibility.Collapsed; }
public MapViewModel(IEnumerable<MapCameraViewModel> cameras, int frameCount) { var cameraList = cameras.ToList(); Cameras = new CollectionViewSource(); Cameras.Source = cameraList; CameraCount = cameraList.Count; FrameCount = frameCount; }
private async Task LoadContacts() { var contacts = await _contactService.GetContactCollection(); Contacts = new CollectionViewSource { Source = contacts.Where(c => !string.IsNullOrEmpty(c.FullName)).ToAlphaGroups(c => c.FullName), IsSourceGrouped = true }; }
/// <summary> /// Invoked when this page is about to be displayed in a Frame. /// </summary> /// <param name="e">Event data that describes how this page was reached. The Parameter /// property is typically used to configure the page.</param> protected override void OnNavigatedTo(NavigationEventArgs e) { CollectionViewSource source = new CollectionViewSource(); source.Source = _droneClient.ConfigurationSectionsViewModel; source.IsSourceGrouped = true; source.ItemsPath = new PropertyPath("ConfigItems"); configItems.SetBinding(GridView.ItemsSourceProperty, new Binding() { Source = source }); int altitudeMax = _droneClient.Configuration.Control.altitude_max.Value; AltitudeMax.Maximum = 100; AltitudeMax.Value = altitudeMax / 1000; AltitudeMax.StepFrequency = Math.Round(AltitudeMax.Maximum / 100, 1); }
protected override void OnNavigatedTo(NavigationEventArgs e) { var groups = SampleDataSource.GetGroups("AllGroups"); var source = new CollectionViewSource(); source.Source = groups; source.IsSourceGrouped = true; source.ItemsPath = new PropertyPath("TopItems"); this.GridView1.DataContext = source; this.ListView1.DataContext = groups.First().TopItems; this.ListView2.DataContext = groups.First().TopItems; }
public ProjectViewModel(IProjectRepository projectRepository) { Activities = projectRepository.GetActivities(); ActivitiesCVS = new CollectionViewSource(); var groups = Activities .OrderBy(i => i.Project) .GroupBy(i => i.Project) .Select(g => new { GroupName = g.Key, Items = g }); ActivitiesCVS.Source = groups; ActivitiesCVS.IsSourceGrouped = true; ActivitiesCVS.ItemsPath = new PropertyPath("Items"); ActivitiesCollectionView = ActivitiesCVS.View; }
public MapViewModel() { Cameras = new CollectionViewSource(); IEnumerable<MapCameraViewModel> query = null; if (CurrentCameras != null) { query = CurrentCameras.Select(x => new MapCameraViewModel(x)); } var y = query.ToList(); Cameras.Source = y; CameraCount = y.Count; FrameCount = 30; }
public ServerViewModel() { Cameras = new CollectionViewSource(); Resolutions = new CollectionViewSource(); _dispatcher = Resolutions.Dispatcher; _controller = new ServerController(); _controller.CamerasChanged += CamerasUpdated; _controller.CameraHeartbeat += OnHearbeat; Register = new ActionCommand(_controller.RequestReport); Record = new ActionCommand(_controller.TriggerRecord); SelectedResolution = this.NewProperty(x => x.SelectedResolution); SelectedResolution.Changed += UpdateResolution; }
public FriendsViewModel(CollectionViewSource friends, CollectionViewSource pending, CollectionViewSource blocked) { ChangeDisplayNameCommand = new RelayCommand<Friend>(ChangeDisplayName); BlockFriendCommand = new RelayCommand<Friend>(BlockFriend); UnBlockFriendCommand = new RelayCommand<Friend>(UnblockFriend); RemoveFriendCommand = new RelayCommand<Friend>(RemoveFriend); GetFriendsCommand = new RelayCommand(GetFriends); GoToFriendCommand = new RelayCommand<Friend>(GoToFriend); // Set up Collection View Sources FriendsViewSource = friends; PendingFriendsViewSource = pending; BlockedFriendsViewSource = blocked; }
internal void Update() { HeaderEvents = new CollectionViewSource() { Source = new List<Event>(conference.Events.Where(item => item.IsSelected).OrderBy(item => item.Start)), IsSourceGrouped = false }; if(PropertyChanged != null) PropertyChanged(this, new PropertyChangedEventArgs("HeaderEvents")); List<Event> firstDayEvents = new List<Event>(conference.Events.Where(item => isVisibleEvent(item, 1))); FirstDayEvents = new CollectionViewSource() { Source = firstDayEvents.ToGroups(x => x.Start, x => x.Track.Name), IsSourceGrouped = true }; if (PropertyChanged != null) PropertyChanged(this, new PropertyChangedEventArgs("FirstDayEvents")); List<Event> secondDayEvents = new List<Event>(conference.Events.Where(item => isVisibleEvent(item, 2))); SecondDayEvents = new CollectionViewSource() { Source = secondDayEvents.ToGroups(x => x.Start, x => x.Track.Name), IsSourceGrouped = true }; if (PropertyChanged != null) PropertyChanged(this, new PropertyChangedEventArgs("SecondDayEvents")); }
private async void GetData() { // Simulate pulling data from api string response; StorageFile file = await StorageFile.GetFileFromApplicationUriAsync(new Uri(@"ms-appx:///DesignData/GetLive.json")); using (StreamReader sRead = new StreamReader(await file.OpenStreamForReadAsync())) response = await sRead.ReadToEndAsync(); // Deserialize data to class LiveStreamModel liveGames = JsonConvert.DeserializeObject<LiveStreamModel>(response); //Schedules = liveGames.schedule; // Group data by event var groupData = liveGames.schedule.GroupBy(a => a.@event); // Set cvs source to grouped data ScheduleSource = new CollectionViewSource() { IsSourceGrouped = true, Source = groupData }; }
/// <summary> /// Case-insensitively filters the groups based on the given filter string and updates the <see cref="ICollectionView"/> containing the examples. /// </summary> protected void UpdateFilter() { var result = new List<IGrouping<string, ExampleInfo>>(); foreach (var group in this.ExampleGroups) { result.AddRange( group.Where(item => item.Title.IndexOf(this.FilterString, StringComparison.OrdinalIgnoreCase) >= 0) .ToLookup(item => group.Key)); } var source = new CollectionViewSource { Source = result, IsSourceGrouped = true }; this.ExamplesView = source.View; }
public void ChangeSort(TrackSort sort) { _settingsUtility.Write(ApplicationSettingsConstants.SongSort, sort, SettingsStrategy.Roam); ViewSource = new CollectionViewSource { IsSourceGrouped = sort != TrackSort.DateAdded }; switch (sort) { case TrackSort.AtoZ: ViewSource.Source = _libraryCollectionService.TracksByTitle; break; case TrackSort.DateAdded: ViewSource.Source = _libraryCollectionService.TracksByDateAdded; break; case TrackSort.Artist: ViewSource.Source = _libraryCollectionService.TracksByArtist; break; case TrackSort.Album: ViewSource.Source = _libraryCollectionService.TracksByAlbum; break; default: throw new ArgumentOutOfRangeException(nameof(sort), sort, null); } }
public async void GetEventList() { long startTime = Helper.Utils.ConvertDateTimeToTimeSpan(DateTime.Today); long endTime = Helper.Utils.ConvertDateTimeToTimeSpan(DateTime.Today.AddMonths(1)); StartProgress(); ObservableCollection<Event> EventList = await Helper.WorktileClient.GetProjectEventList(Project.Pid, startTime, endTime); EndProgress(); IEnumerable<EventGroup> pList1 = EventList.OrderBy(x=>x.StartTime).GroupBy(x => x.StartTime.Date).Select(x => new EventGroup() { StartDate = (DateTime)x.Key, EventList = new ObservableCollection<Event>(x.ToList()) }); CollectionViewSource groupData = new CollectionViewSource(); groupData.IsSourceGrouped = true; groupData.Source = pList1; groupData.ItemsPath = new PropertyPath("EventList"); this.EventList = groupData.View; // item,即详细视图 EventGroup = groupData.View.CollectionGroups; }
protected override void OnNavigatedTo(NavigationEventArgs e) { MainType[] MainTypes = { new MainType{ProID=1,Name="News"}, new MainType{ProID=2,Name="Movie"}, new MainType{ProID=3,Name="Sports"}, new MainType{ProID=4,Name="Games"} }; SecondaryType[] SecondaryTypes = { new SecondaryType{TypeID=11,ProID=1,TypeName="News 1"}, new SecondaryType{TypeID=12,ProID=1,TypeName="News 2"}, new SecondaryType{TypeID=13,ProID=1,TypeName="News 3"}, new SecondaryType{TypeID=21,ProID=2,TypeName="Batman"}, new SecondaryType{TypeID=22,ProID=2,TypeName="SpiderMan"}, new SecondaryType{TypeID=31,ProID=3,TypeName="Basketball"}, new SecondaryType{TypeID=32,ProID=3,TypeName="Swimming"}, new SecondaryType{TypeID=33,ProID=3,TypeName="Football"}, new SecondaryType{TypeID=34,ProID=3,TypeName="Fencing"}, new SecondaryType{TypeID=35,ProID=3,TypeName="Weightlifting"}, new SecondaryType{TypeID=41,ProID=4,TypeName="WOW"}, new SecondaryType{TypeID=42,ProID=4,TypeName="StarCraft"} }; var res = (from p in MainTypes join c in SecondaryTypes on p.ProID equals c.ProID into g select new { p.Name, TypeList = g.ToList() }).ToList<dynamic>(); CollectionViewSource cvs = new CollectionViewSource(); cvs.IsSourceGrouped = true; cvs.ItemsPath = new PropertyPath("TypeList"); cvs.Source = res; gvList.ItemsSource = cvs.View.CollectionGroups; lvlist.ItemsSource = cvs.View; }
public LoggedInUserViewModel() { UserListGrouped = new CollectionViewSource(); UserListGrouped.IsSourceGrouped = true; }
public LibraryManager() { // Check is the instance doesnt already exist. if (Current != null) { //if there is an instance in the app already present then simply throw an error. throw new Exception("Only one library manager can exist in a App."); } // Setting the instance to the static instance field. Current = this; library = new Collection<Collection<Collection<object>>>("Library"); library.Items.Add(new Collection<Collection<object>>("Favoriten", "Library")); // Index 0 library.Items.Add(new Collection<Collection<object>>("Routes", "Directions")); library.Items.Add(new Collection<Collection<object>>("Recent Searches", "Find")); library.Items.Add(new Collection<Collection<object>>("Recent Locations", "MapPin")); // FILTERED LIBRARY filteredLibrary = new Collection<Collection<Collection<object>>>("Library"); filteredLibrary.Items.Add(new Collection<Collection<object>>("Favoriten", "Library")); // Index 0 filteredLibrary.Items.Add(new Collection<Collection<object>>("Routes", "Directions")); filteredLibrary.Items.Add(new Collection<Collection<object>>("Recent Searches", "Find")); filteredLibrary.Items.Add(new Collection<Collection<object>>("Recent Locations", "MapPin")); filteredLibraryViewSource = new CollectionViewSource(); filteredLibraryViewSource.Source = filteredLibrary.Items; filteredLibraryViewSource.IsSourceGrouped = true; filteredLibraryViewSource.ItemsPath = new Windows.UI.Xaml.PropertyPath("Items"); Reload(ReloadParameter.All); }
public async Task RemovingFromFilteredCollectionDoesNotThrow() { await ExecuteOnUIThread(() => { var originalCollection = new ObservableCollection<ItemMetadata>(); originalCollection.Add(new ItemMetadata("a")); originalCollection.Add(new ItemMetadata("b")); originalCollection.Add(new ItemMetadata("c")); IViewsCollection viewsCollection = new ViewsCollection(originalCollection, (i) => true); CollectionViewSource cvs = new CollectionViewSource { Source = viewsCollection }; var view = cvs.View; try { originalCollection.RemoveAt(1); } catch (Exception ex) { Assert.Fail(ex.Message); } }); }
public void ChangeSort(ArtistSort sort) { ViewSource = new CollectionViewSource { IsSourceGrouped = true }; switch (sort) { case ArtistSort.AtoZ: ViewSource.Source = _libraryCollectionService.ArtistsByName; break; default: throw new ArgumentOutOfRangeException(nameof(sort), sort, null); } }
public object Convert(object value, Type targetType, object parameter, string language) { CollectionViewSource _RenderSource = new CollectionViewSource(); BindingOperations.SetBinding(_RenderSource, CollectionViewSource.SourceProperty, new Binding() { Source = value, Path = new PropertyPath("RenderModels"), Mode = BindingMode.OneWay }); return _RenderSource.View; }
private async void GetProjectList() { this.StartProgress(); ObservableCollection<ProjectInfo> AllProjectList = await Helper.WorktileClient.GetUserProjectList(); this.EndProgress(); Helper.Declares.ProjectList = AllProjectList; IEnumerable<ProjectGroup> pList1 = AllProjectList.GroupBy(x => x.Visibility).Select(x => new ProjectGroup() { ProjectType = (int)x.Key, ProjectList = new ObservableCollection<ProjectInfo>(x.ToList()) }); IEnumerable<ProjectGroup> pList2 = AllProjectList.Where(x => x.IsStar == ProjectInfo.ProjectIsStar.Yes).GroupBy(x => x.IsStar).Select(x => new ProjectGroup() { ProjectType = 0, ProjectList = new ObservableCollection<ProjectInfo>(x.ToList()) }); ObservableCollection<ProjectGroup> myProjectList = new ObservableCollection<ProjectGroup>(pList1.Union(pList2).OrderBy(x => x.ProjectType).ToList()); CollectionViewSource groupData = new CollectionViewSource(); groupData.IsSourceGrouped = true; groupData.Source = myProjectList; groupData.ItemsPath = new PropertyPath("ProjectList"); ProjectList = groupData.View; // item,即详细视图 ProjectGroup = groupData.View.CollectionGroups; }
/// <summary> /// Affecte les résultats à la liste /// </summary> private void SetItemsSourceToListView(List<object> items) { if (items != null && items.Any()) { var itemsGrouped = new ObservableCollection<ItemsGroup>(); var itemsOrdered = items.GroupBy(o => o.GetType().GetProperty(FilterMemberPath).GetValue(o).ToString().Substring(0, 1)); foreach (var @group in itemsOrdered.OrderBy(o => o.Key)) { itemsGrouped.Add(new ItemsGroup(group)); } var collection = new CollectionViewSource { IsSourceGrouped = true, ItemsPath = new PropertyPath("Items"), Source = itemsGrouped }; _setItemsSource = true; _listItems.ItemsSource = collection.View; _listItems.SelectedIndex = -1; _setItemsSource = false; ((ListViewBase)_semanticZoom.ZoomedOutView).ItemsSource = collection.View.CollectionGroups; } }
/// <summary> /// 准备分组数据 /// </summary> /// <returns></returns> private CollectionViewSource PrepareGroupedData() { var returnCollectionViewSource = new CollectionViewSource() { IsSourceGrouped = true, ItemsPath = new PropertyPath("Courses") }; var courses = new CourseService().GetCoursesByCourseCategory(this.KnowledgeSystemDiagramEntity.Title); var retunrGroupedCourses = (from course in courses group course by course.CourseGroupEntity.GroupName into groupedCourses //orderby groupedCourses.Key.GroupIndex ascending select new CourseGroupEntity() { GroupName = groupedCourses.Key, //Description = course.CourseGroupEntity.Description, //GroupIndex = groupedCourses.Key.GroupIndex, Courses = (from course in groupedCourses select course).ToList<CourseEntity>() }).ToList<CourseGroupEntity>(); returnCollectionViewSource.Source = retunrGroupedCourses; return returnCollectionViewSource; }