private async void ScrollViewer_OnScrollChanged(object sender, ScrollChangedEventArgs e) { try { ScrollViewer scroll = FindVisualChild <ScrollViewer>(gamesHistoryListView); if (scroll == null) { throw new InvalidOperationException( "The attached AlwaysScrollToEnd property can only be applied to ScrollViewer instances."); } if (e.ExtentHeightChange == 0 && scroll.VerticalOffset == 0) { StatsHistory sh = await RestClient.GetStats(_lastMessageIndex, _lastMessageIndex + 20); if (sh.MatchesPlayedHistory != null && sh.MatchesPlayedHistory.Count > 0) { _lastMessageIndex += 21; (DataContext as ProfileViewModel).AddStatsHistory(sh); scroll.ScrollToVerticalOffset(scroll.ScrollableHeight / 10); } } } catch { // } }
private async void ScrollViewer_OnScrollChanged(object sender, ScrollChangedEventArgs e) { ScrollViewer scroll = sender as ScrollViewer; if (scroll == null) { throw new InvalidOperationException( "The attached AlwaysScrollToEnd property can only be applied to ScrollViewer instances."); } if (e.ExtentHeightChange == 0 && scroll.VerticalOffset == 0) { //TODO: Dont load messages if messageIndex is greater than the array length StatsHistory sh = await RestClient.GetStats(_lastMessageIndex, _lastMessageIndex + 100); _nReturned += 100; if (sh.ConnectionHistory.Count > 0) { _lastMessageIndex += 100; AddStatsHistory(sh); scroll.ScrollToVerticalOffset(scroll.ScrollableHeight / 10); } } }
private void AddStatsHistory(StatsHistory sh) { foreach (ConnectionDisconnection connectionDisconnection in sh.ConnectionHistory) { StatsHistory.ConnectionHistory.AddFirst(connectionDisconnection); } StatsHistory.ConnectionHistory = new LinkedList <ConnectionDisconnection>(StatsHistory.ConnectionHistory); }
public ConnectionHistoryDialog(StatsHistory statsHistory, int lastMessageIndex) { (((MainWindow)Application.Current.MainWindow).MainWindowDialogHost as DialogHost).CloseOnClickAway = true; StatsHistory = statsHistory; _lastMessageIndex = lastMessageIndex; InitializeComponent(); _scrollToBottomTimer = new Timer(800); _scrollToBottomTimer.Elapsed += ScrollToBottom; _scrollToBottomTimer.Start(); _nReturned = 0; }
public void AddStatsHistory(StatsHistory sh) { var tmpMatches = new ObservableCollection <MatchPlayed>(StatsHistory.MatchesPlayedHistory); StatsHistory.MatchesPlayedHistory.Clear(); for (int i = 0; i < sh.MatchesPlayedHistory.Count; i++) { StatsHistory.MatchesPlayedHistory.Add(sh.MatchesPlayedHistory[i]); } for (int i = 0; i < tmpMatches.Count; i++) { StatsHistory.MatchesPlayedHistory.Add(tmpMatches[i]); } NotifyPropertyChanged(nameof(StatsHistory)); }
/// <summary> /// Checks experience to see if the CLVL needs to raise /// </summary> /// <returns>true if character level increased</returns> public bool LevelUp() { bool isLevelUp = false; var req = Math.Pow((Level + 1.0f), 1.2f); //var req = Level * 15; if (Experience > req) { isLevelUp = true; Level += 1; AttributeLevelStrategy(10 * (1 + Level * 0.333f)); SkillExperienceStrategy(10 * (1 + Level * 0.1f)); StatsLevelStrategy(Level); BattleLog?.WriteLine($"{Name} leveled up to level {Level}!"); HP = HitPoints; StatsHistory.Add((Stats)MemberwiseClone()); } return(isLevelUp); }