public Scheduler(ref MyObservableCollection <T> collection, Func <T, T, bool> equalityComparer, Func <T, long> GetIdFromItem, PixivAccount.WorkMode workmode, SynchronizationContext context = null) { StatusTree = new SortedDictionary <long, bool?>(); this.collection = collection; this.equilityComparer = equalityComparer; this.AssociatedWorkMode = workmode; this.GetIdFromItem = GetIdFromItem; if (context == null) { UIContext = SynchronizationContext.Current; } else { UIContext = context; } JobQueue = new Queue <Tuple <T, Action> >(); PriorityJobQueue = new Queue <Tuple <T, Action> >(); timer = new DispatcherTimer(DispatcherPriority.Loaded); timer.Interval = TimeSpan.FromMilliseconds(60); timer.Tick += Timer_Tick; timer.Start(); }
void ToggleButtons(PixivAccount.WorkMode mode) { btnRankings.IsEnabled = mode != PixivAccount.WorkMode.Ranking; btnBookmarks.IsEnabled = mode != PixivAccount.WorkMode.BookmarksPublic; btnBookmarksPrivate.IsEnabled = mode != PixivAccount.WorkMode.BookmarksPrivate; btnFollowing.IsEnabled = mode != PixivAccount.WorkMode.Following; btnResults.IsEnabled = mode != PixivAccount.WorkMode.Search && MainModel.LastSearchQuery != null; btnRecommended.IsEnabled = mode != PixivAccount.WorkMode.Recommended; }
void ToggleLists(PixivAccount.WorkMode mode) { mainListSorted.Visibility = (mode == PixivAccount.WorkMode.Search) ? Visibility.Visible : Visibility.Hidden; mainListRecommended.Visibility = (mode == PixivAccount.WorkMode.Recommended) ? Visibility.Visible : Visibility.Hidden; mainListRanking.Visibility = (mode == PixivAccount.WorkMode.Ranking) ? Visibility.Visible : Visibility.Hidden; mainListFollowing.Visibility = (mode == PixivAccount.WorkMode.Following) ? Visibility.Visible : Visibility.Hidden; mainListBookmarks.Visibility = (mode == PixivAccount.WorkMode.BookmarksPublic) ? Visibility.Visible : Visibility.Hidden; mainListBookmarksPrivate.Visibility = (mode == PixivAccount.WorkMode.BookmarksPrivate) ? Visibility.Visible : Visibility.Hidden; mainListUser.Visibility = (mode == PixivAccount.WorkMode.User) ? Visibility.Visible : Visibility.Hidden; if (mode != PixivAccount.WorkMode.User) { followUserPopup.Hide(PopUp.TransitionType.ZoomIn); } else { userNameText.Text = currentUser.Name; Task.Run(async() => { // Follow pop up settings if (currentUser.Id == null) { return; } var user = await Account.GetUser(currentUser.Id.Value); // get more user info currentUser = user; UIContext.Post(a => { UpdateFollowButton(); followUserPopup.Show(PopUp.TransitionType.ZoomIn); }, null); }); } }
void SwitchWorkMode(PixivAccount.WorkMode toMode) { ToggleButtons(toMode); ToggleLists(toMode); }