コード例 #1
0
        private void SelectPreviousOrDefaultSkin()
        {
            var selectedSkinId = LimitedStorage.Get(LimitedSpace.SelectedSkin, Id);

            _selectedSkin = (selectedSkinId == null ? null : SkinsManager.GetById(selectedSkinId)) ?? SkinsManager.GetDefault();
            OnPropertyChanged(nameof(SelectedSkin));
            OnPropertyChanged(nameof(SelectedSkinLazy));
        }
コード例 #2
0
        public void LoadSelectedCar()
        {
            if (Cars == null)
            {
                return;
            }

            var selected = LimitedStorage.Get(LimitedSpace.OnlineSelectedCar, Id);

            SetSelectedCarEntry(selected == null ? null : Cars.GetByIdOrDefault(selected));
        }
コード例 #3
0
        public void Initialize()
        {
            InitializeComponent();

            var savedSortPath = LimitedStorage.Get(LimitedSpace.LapTimesSortingColumn, _filter);
            var sortDirection = LimitedStorage.Get(LimitedSpace.LapTimesSortingDescending, _filter) == @"1"
                    ? ListSortDirection.Descending : ListSortDirection.Ascending;
            var sortedColumn = Grid.Columns.FirstOrDefault(x => x.SortMemberPath == savedSortPath) ?? DefaultColumn;

            sortedColumn.SortDirection = sortDirection;

            DataContext = new ViewModel(string.IsNullOrEmpty(_filter) ? null : Filter.Create(LapTimeTester.Instance, _filter),
                                        sortedColumn.SortMemberPath, sortDirection);
        }
コード例 #4
0
            private void LoadQuickFilter()
            {
                var loaded = LimitedStorage.Get(LimitedSpace.OnlineQuickFilter, Key);

                if (loaded == null)
                {
                    return;
                }
                FilterEmpty       = loaded.Contains(@"drivers");
                FilterFull        = loaded.Contains(@"full");
                FilterPassword    = loaded.Contains(@"password");
                FilterMissing     = loaded.Contains(@"haserrors");
                FilterBooking     = loaded.Contains(@"booking");
                FilterFriendsOnly = loaded.Contains(@"friends");
            }
コード例 #5
0
            private void LoadCurrent()
            {
                if (_currentLoaded)
                {
                    if (_loadCurrentFailed != null)
                    {
                        var selected = Manager.GetById(_loadCurrentFailed);
                        if (selected != null)
                        {
                            MainList.MoveCurrentTo(selected);
                            _loadCurrentFailed = null;
                        }
                    }
                    return;
                }

                _currentLoaded           = true;
                MainList.CurrentChanged -= OnCurrentChanged;

                var current = LimitedStorage.Get(LimitedSpace.OnlineSelected, Key);

                if (current != null)
                {
                    var selected = Manager.GetById(current);
                    if (selected != null)
                    {
                        MainList.MoveCurrentTo(selected);
                        _loadCurrentFailed = null;
                    }
                    else
                    {
                        MainList.MoveCurrentToFirst();
                        _loadCurrentFailed = current;
                    }
                }
                else
                {
                    MainList.MoveCurrentToFirst();
                }

                CurrentChanged(false);
                MainList.CurrentChanged += OnCurrentChanged;
            }
コード例 #6
0
            public OnlineViewModel([CanBeNull] string filterParam, Action <ServerEntry> showDetails)
            {
                _showDetails = showDetails;

                string[] sources = null;
                string   filter  = null;

                if (filterParam != null)
                {
                    var splitIndex = filterParam.LastIndexOf('@');
                    if (splitIndex != -1)
                    {
                        sources = filterParam.Substring(splitIndex + 1).Split(',').Select(x => x.Trim().ToLowerInvariant())
                                  .Distinct().ToArray();
                        filter = splitIndex == 0 ? null : filterParam.Substring(0, splitIndex);
                    }
                    else
                    {
                        filter = filterParam;
                    }
                }

                Pack         = OnlineManager.Instance.GetSourcesPack(sources);
                UserListMode = Pack.SourceWrappers.Count == 1 && FileBasedOnlineSources.Instance.GetUserSources()
                               .Select(x => x.Id)
                               .Append(FileBasedOnlineSources.FavouritesKey)
                               .Contains(Pack.SourceWrappers[0].Id);

                ListFilter = GetFilter(filter, sources);
                Key        = GetKey(filterParam);

                Manager  = OnlineManager.Instance;
                MainList = new BetterListCollectionView(Manager.List);

                SortingModes = sources?.Length == 1 && sources[0] == FileBasedOnlineSources.RecentKey
                        ? DefaultSortingModes.Prepend(new SettingEntry(null, "Default")).ToArray() : DefaultSortingModes;

                LoadQuickFilter();
                SortingMode       = SortingModes.GetByIdOrDefault(LimitedStorage.Get(LimitedSpace.OnlineSorting, Key)) ?? SortingModes[0];
                ListFilter.Second = CreateQuickFilter();
            }
コード例 #7
0
 protected override string LoadCurrentId()
 {
     return(LimitedStorage.Get(LimitedSpace.SelectedEntry, Key));
 }
コード例 #8
0
ファイル: Online.QuickFilters.cs プロジェクト: tankyx/actools
            private void LoadState()
            {
                _loading = true;

                try {
                    var saved = LimitedStorage.Get(LimitedSpace.OnlineQuickFilter, _saveKey) ?? DefaultQuickFilters.Value ?? "";
                    foreach (var filter in this)
                    {
                        filter.IsEnabled = false;
                    }

                    var previousIndex = 0;
                    var brackets      = 0;
                    for (var i = 0; i < saved.Length; i++)
                    {
                        var c = saved[i];
                        switch (c)
                        {
                        case '\\':
                            i++;
                            break;

                        case '&' when brackets == 0:
                            SetFilter(saved.Substring(previousIndex, i - previousIndex));
                            previousIndex = i + 1;
                            break;

                        case '&':
                            break;

                        case '(':
                            brackets++;
                            break;

                        case ')':
                            brackets--;
                            break;
                        }
                    }

                    SetFilter(saved.Substring(previousIndex));

                    void SetFilter(string piece)
                    {
                        if (piece.Length > 2 && piece[0] == '(' && piece[piece.Length - 1] == ')')
                        {
                            piece = piece.Substring(1, piece.Length - 2);
                        }

                        var filter = this.GetByIdOrDefault(piece);

                        if (filter != null)
                        {
                            filter.IsEnabled = true;
                        }
                        else
                        {
                            Logging.Warning("Filter not found: " + piece);
                        }
                    }
                } catch (Exception e) {
                    Logging.Error(e);
                } finally {
                    _loading = false;
                }
            }
コード例 #9
0
        private void SelectPreviousOrDefaultSkin()
        {
            var selectedSkinId = LimitedStorage.Get(LimitedSpace.SelectedSkin, Id);

            SelectedSkin = (selectedSkinId == null ? null : SkinsManager.GetById(selectedSkinId)) ?? SkinsManager.GetDefault();
        }