public override void OnApplyTemplate() { base.OnApplyTemplate(); ControlGameView = Template.FindName("PART_ControlGameView", this) as Control; if (ControlGameView != null) { BindingTools.SetBinding(ControlGameView, Control.DataContextProperty, mainModel, nameof(DesktopAppViewModel.SelectedGameDetails)); } ListGames = Template.FindName("PART_ListGames", this) as ExtendedListBox; if (ListGames != null) { SetListGamesBinding(); BindingTools.SetBinding(ListGames, ExtendedListBox.SelectedItemProperty, mainModel, nameof(DesktopAppViewModel.SelectedGame), BindingMode.TwoWay); BindingTools.SetBinding(ListGames, ExtendedListBox.SelectedItemsListProperty, mainModel, nameof(DesktopAppViewModel.SelectedGamesBinder), BindingMode.TwoWay); ScrollToSelectedBehavior.SetEnabled(ListGames, true); ListGames.InputBindings.Add(new KeyBinding(mainModel.EditSelectedGamesCommand, mainModel.EditSelectedGamesCommand.Gesture)); ListGames.InputBindings.Add(new KeyBinding(mainModel.RemoveSelectedGamesCommand, mainModel.RemoveSelectedGamesCommand.Gesture)); ListGames.InputBindings.Add(new KeyBinding(mainModel.StartSelectedGameCommand, mainModel.StartSelectedGameCommand.Gesture)); } }
private void SearchPage_OnPreviewKeyDown(object sender, System.Windows.Input.KeyEventArgs e) { _logger.Debug("SearchPage_OnPreviewKeyDown {0}", e.Key); ExtendedListBox x = AlphabetMenu; _searchViewModel.AlphaInputViewModel.UserInput_PreviewKeyDown(sender, e, AlphabetMenu); }
public void Unbind() { if (lb != null) lb.ItemRealized -= lb_ItemRealized; lb = null; }
public void Bind(ExtendedListBox listbox) { list = listbox; list.StretchingBottom += list_StretchingBottom; list.StretchingTop += list_StretchingTop; Bound = true; }
void CheckForFilterUpdate(object sender, RoutedEventArgs e) { ExtendedListBox list = sender as ExtendedListBox; if (list != null && ((DataTransfer.ShouldReloadFilters && DataTransfer.cFilter.Resource == list.Loader.Resource) || DataTransfer.IsGlobalFilter)) { FilterManager.SetupFilter(list); DataTransfer.ShouldReloadFilters = false; } }
public override void OnApplyTemplate() { base.OnApplyTemplate(); ControlGameView = Template.FindName("PART_ControlGameView", this) as Control; if (ControlGameView != null) { BindingTools.SetBinding(ControlGameView, Control.DataContextProperty, mainModel, nameof(DesktopAppViewModel.SelectedGameDetails)); } ListGames = Template.FindName("PART_ListGames", this) as ExtendedListBox; if (ListGames != null) { SetListGamesBinding(); BindingTools.SetBinding(ListGames, ExtendedListBox.SelectedItemProperty, mainModel, nameof(DesktopAppViewModel.SelectedGame), BindingMode.TwoWay); BindingTools.SetBinding(ListGames, ExtendedListBox.SelectedItemsListProperty, mainModel, nameof(DesktopAppViewModel.SelectedGamesBinder), BindingMode.TwoWay); ScrollToSelectedBehavior.SetEnabled(ListGames, true); if (!DesignerProperties.GetIsInDesignMode(this)) { ListGames.InputBindings.Add(new KeyBinding(mainModel.EditSelectedGamesCommand, mainModel.EditSelectedGamesCommand.Gesture)); ListGames.InputBindings.Add(new KeyBinding(mainModel.RemoveSelectedGamesCommand, mainModel.RemoveSelectedGamesCommand.Gesture)); ListGames.InputBindings.Add(new KeyBinding(mainModel.StartSelectedGameCommand, mainModel.StartSelectedGameCommand.Gesture)); } ListGames.SelectionMode = SelectionMode.Extended; VirtualizingPanel.SetCacheLengthUnit(ListGames, VirtualizationCacheLengthUnit.Item); VirtualizingPanel.SetCacheLength(ListGames, new VirtualizationCacheLength(5)); VirtualizingPanel.SetScrollUnit(ListGames, ScrollUnit.Pixel); VirtualizingPanel.SetIsVirtualizingWhenGrouping(ListGames, true); VirtualizingPanel.SetVirtualizationMode(ListGames, VirtualizationMode.Recycling); } ControlTemplateTools.InitializePluginControls( mainModel.Extensions, Template, this, SDK.ApplicationMode.Desktop, mainModel, $"{nameof(DesktopAppViewModel.SelectedGameDetails)}.{nameof(GameDetailsViewModel.Game)}.{nameof(GameDetailsViewModel.Game.Game)}"); }
void ShowResumePositionPrompt(ExtendedListBox list) { currentShowingList = list; if (recoverDialogShown) { return; } SbShowDialog.BeginTime = TimeSpan.FromSeconds(2); SbShowDialog.Begin(); recoverDialogShown = true; }
public static void SetupFilter(ExtendedListBox listbox) { if (listbox == null || listbox.Loader == null) return; TwitterResource resource = listbox.Resource; ColumnFilter filter = Config.Filters.FirstOrDefault(item => item.Resource == resource); if (filter != null) { filter.CleanOldFilters(); listbox.Filter = filter; } else listbox.Filter = new ColumnFilter(); listbox.Filter.Global = Config.GlobalFilter; listbox.Filter = listbox.Filter; // Force update of filter. }
public static void SetupFilter(ExtendedListBox listbox) { if (listbox == null || listbox.Loader == null) { return; } TwitterResource resource = listbox.Resource; ColumnFilter filter = Config.Filters.FirstOrDefault(item => item.Resource == resource); if (filter != null) { filter.CleanOldFilters(); listbox.Filter = filter; } else { listbox.Filter = new ColumnFilter(); } listbox.Filter.Global = Config.GlobalFilter; listbox.Filter = listbox.Filter; // Force update of filter. }
public ExtendedListBoxSelectedItemsProvider(ExtendedListBox source) { Guard.NotNull("source", source); this.source = source; }
public void UserInput_PreviewKeyDown(object sender, System.Windows.Input.KeyEventArgs e, ExtendedListBox alphabetMenu) { if (isHandledKey(e.Key)) { string KeyVal; if (e.Key == Key.Delete) { KeyVal = "back"; } else if (e.Key == Key.Space) { KeyVal = "_"; } else { KeyVal = e.Key.ToString().ToLower(); } // TODO - move hightlight code to AlphabetItemViewList viewmodel var item = AlphabetTabItemList.Find(t => t.DisplayName == KeyVal); var currentItem = IndexOptionsCollectionView.CurrentItem as MediaBrowser.Theater.Presentation.ViewModels.TabItem; var alReadySelected = (item != null) && (currentItem != null) && item.DisplayName == currentItem.DisplayName; var listBoxItem = alphabetMenu.ItemContainerGenerator.ContainerFromItem(item) as ExtendedListBoxItem; if (listBoxItem != null) { if (alReadySelected) { listBoxItem.IsSelected = false; } listBoxItem.IsSelected = true; OnIndexSelectionChange(null); } e.Handled = true; } }
public void Bind(ExtendedListBox listbox) { lb = listbox; lb.ItemRealized += lb_ItemRealized; }
private void ListBox_Loaded(object sender, RoutedEventArgs e) { ExtendedListBox list = sender as ExtendedListBox; if (list == null) { return; } var tag = list.Tag; ThreadPool.QueueUserWorkItem((threadcontext) => { TwitterResource Resource = new TwitterResource(); if (tag is TwitterResource) { Resource = (TwitterResource)tag; list.Resource = Resource; } Dispatcher.BeginInvoke(() => FilterManager.SetupFilter(list)); list.Loader.ActivateLoadMoreButton = true; list.Loader.TweetsToLoadPerRequest = (int)Config.TweetsPerRequest; list.Loader.LoadRetweetsAsMentions = (bool)Config.RetweetAsMentions; list.Loader.PropertyChanged += (sender1, e1) => { if (e1.PropertyName == "IsLoading") { if (list.Loader.IsLoading) { viewModel.LoadingCount++; } else { viewModel.LoadingCount--; } } }; viewModel.ScrollToTop += (sender1, e1) => { if (e1.BroadcastAll || e1.Resource == Resource) { list.ScrollToTop(); } }; viewModel.ReloadLists += (sender1, e1) => { if (e1.BroadcastAll || e1.Resource == Resource) { ThreadPool.QueueUserWorkItem((context) => list.AutoReload()); } }; viewModel.CheckIfCanResumePosition += (sender1, e1) => { if (e1.Resource == list.Loader.Resource && Config.ReloadOptions == ColumnReloadOptions.AskPosition) { list.TryTriggerResumeReading(); } }; list.ReadyToResumePosition += (sender1, e1) => { var selectedPivot = (TwitterResource)viewModel.SelectedPivot; if (list.Loader.Resource == selectedPivot) { Dispatcher.BeginInvoke(() => { long id; if (Config.ReadPositions.TryGetValue(selectedPivot.String, out id) && !list.VisibleItems.Any(x => x.Id == id)) { ShowResumePositionPrompt(list); } }); } }; list.Loader.LoadCacheAsync(); list.AutoReload(); Dispatcher.BeginInvoke(() => { list.Loaded -= ListBox_Loaded; list.Loaded += new RoutedEventHandler(CheckForFilterUpdate); }); GlobalEvents.FiltersChanged += (sender1, e1) => Dispatcher.BeginInvoke(() => FilterManager.SetupFilter(list)); }); }
public ExtendedListBoxSelectedItemsProvider(ExtendedListBox source) { Guard.NotNull("source", source); this.source = source; }