Пример #1
0
        private async void Update() {
            if (!IsLoaded || !_dirty || _busy) return;
            _busy = true;

            try {
                var carId = CarId;
                var trackAcId = TrackId?.Replace('/', '-');

                var singleEntryMode = carId != null && TrackId != null;
                SetValue(SingleEntryModePropertyKey, singleEntryMode);

                SetValue(LoadingPropertyKey, true);
                await LapTimesManager.Instance.UpdateAsync();
                
                if (singleEntryMode) {
                    var entry = LapTimesManager.Instance.Entries.FirstOrDefault(x => x.CarId == carId && x.TrackAcId == trackAcId);
                    _lapTimes.ReplaceEverythingBy_Direct(entry == null ? new LapTimeWrapped[0] : new[] { new LapTimeWrapped(entry) });
                } else {
                    var enumerable = LapTimesManager.Instance.Entries.Where(x =>
                            (carId == null || x.CarId == carId) && (trackAcId == null || x.TrackAcId == trackAcId));

                    switch (Order) {
                        case BestLapsOrder.MostDrivenFirst:
                            enumerable = enumerable.OrderByDescending(x => PlayerStatsManager.Instance.GetDistanceDrivenAtTrackAcId(x.TrackAcId));
                            break;
                        case BestLapsOrder.FastestFirst:
                            enumerable = enumerable.OrderBy(x => x.LapTime);
                            break;
                        default:
                            throw new ArgumentOutOfRangeException();
                    }

                    _lapTimes.ReplaceEverythingBy_Direct(enumerable.Take(Limit).Select(x => new LapTimeWrapped(x)));
                }
            } catch (Exception e) {
                Logging.Error(e);
            } finally {
                _dirty = false;
                _busy = false;
                ActionExtension.InvokeInMainThread(() => SetValue(LoadingPropertyKey, false));
            }
        }
Пример #2
0
            private BlacklistStorage()
            {
                _filename = Path.Combine(AcRootDirectory.Instance.Value ?? "", "server", "blacklist.txt");
                Items     = new BetterObservableCollection <BlacklistItem>();
                if (File.Exists(_filename))
                {
                    Items.ReplaceEverythingBy_Direct(ReadSafe().Select(x => new BlacklistItem(x)));
                }

                var directory = Path.GetDirectoryName(_filename);

                if (directory != null)
                {
                    var watcher = new DirectoryWatcher(directory, "blacklist.txt");
                    watcher.Update += (sender, args) => {
                        if (_watcherBusy.Is)
                        {
                            return;
                        }
                        Items.ReplaceEverythingBy_Direct(ReadSafe().Select(x => new BlacklistItem(x)));
                    };
                }
            }
Пример #3
0
 private void RecreateEmojis()
 {
     if (_emojiLoader != null && _informationProvider != null)
     {
         Emojis.ReplaceEverythingBy_Direct(_emojiLoader?.GetList()
                                           .Select(x => new Emoji(x, _emojiLoader, _informationProvider))
                                           .Where(x => x.Information != null)
                                           .OrderBy(x => x.Information.Index));
     }
     else
     {
         Emojis.Clear();
     }
 }
Пример #4
0
        private void Update()
        {
            if (!IsLoaded || !_dirty)
            {
                return;
            }

            var saveKey      = SaveKey;
            var items        = saveKey == null ? new string[0] : ValuesStorage.GetStringList(saveKey);
            var defaultItems = DefaultItems;

            if (defaultItems.Count > 0)
            {
                items = items.Union(defaultItems);
            }

            _filtersHistory.ReplaceEverythingBy_Direct(items);

            _dirty = false;
        }