private void OnSelectionChanged(object sender, SelectionChangedEventArgs e) { if (this.suppressSelectionEvent) { return; } this.currentSelection = (ViewService.Page) this.ViewList.SelectedItem; if (this.currentSelection != null && !this.currentSelection.Supports(this.actor)) { return; } this.SelectPage?.Invoke(this.currentSelection); }
private void OnShowPage(ViewService.Page page) { if (page == null) { this.currentView = null; this.ViewArea.Content = null; return; } if (!this.pages.ContainsKey(page)) { Application.Current.Dispatcher.Invoke(() => { this.pages.Add(page, page.Create()); }); } this.currentView = this.pages[page]; this.ViewArea.Content = this.currentView; }
private void OnActorRetargeted(Actor actor = null) { HashSet <ViewService.Page> oldPages = new HashSet <ViewService.Page>(this.Items); List <ViewService.Page> newPages = new List <ViewService.Page>(); foreach (ViewService.Page page in this.viewService.Pages) { if (!page.Supports(this.actor)) { continue; } newPages.Add(page); } bool changed = true; if (oldPages.Count == newPages.Count) { changed = false; foreach (ViewService.Page page in newPages) { if (oldPages.Contains(page)) { continue; } changed = true; break; } } if (!changed) { return; } ViewService.Page oldSelection = this.currentSelection; this.suppressSelectionEvent = true; this.Items.Clear(); foreach (ViewService.Page page in newPages) { this.Items.Add(page); } if (newPages.Contains(oldSelection)) { this.currentSelection = oldSelection; this.ViewList.SelectedItem = this.currentSelection; this.SelectPage?.Invoke(oldSelection); } else { this.SelectPage?.Invoke(this.Items.FirstOrDefault()); } this.suppressSelectionEvent = false; }
private void OnAddPage(ViewService.Page page) { this.Items.Add(page); }
private void OnShowPage(ViewService.Page page) { this.currentView = page.Instance; this.ViewArea.Content = this.currentView; }
private void OnSelectionChanged(object sender, SelectionChangedEventArgs e) { ViewService.Page item = (ViewService.Page) this.ViewList.SelectedItem; this.SelectPage?.Invoke(item); }