Ejemplo n.º 1
0
        public void AddLanguage(CultureInfo cultureInfo)
        {
            if (Languages.Contains(cultureInfo))
            {
                return;
            }

            changeHandler?.BeginChange();
            Languages.Add(cultureInfo);
            changeHandler?.EndChange();
        }
Ejemplo n.º 2
0
        private void load(VerifyScreen verify)
        {
            hiddenIssueTypes = verify.HiddenIssueTypes.GetBoundCopy();

            foreach (IssueType issueType in configurableIssueTypes)
            {
                var checkbox = new SettingsCheckbox
                {
                    Anchor    = Anchor.CentreLeft,
                    Origin    = Anchor.CentreLeft,
                    LabelText = issueType.ToString(),
                    Current   = { Default = !hiddenIssueTypes.Contains(issueType) }
                };

                checkbox.Current.SetDefault();
                checkbox.Current.BindValueChanged(state =>
                {
                    if (!state.NewValue)
                    {
                        hiddenIssueTypes.Add(issueType);
                    }
                    else
                    {
                        hiddenIssueTypes.Remove(issueType);
                    }
                });

                Flow.Add(checkbox);
            }
        }
Ejemplo n.º 3
0
 private void handleBeatmapAdded(BeatmapSetInfo set) => Schedule(() =>
 {
     if (!beatmapSets.Contains(set))
     {
         beatmapSets.Add(set);
     }
 });
Ejemplo n.º 4
0
        Task ISpectatorClient.UserBeganPlaying(int userId, SpectatorState state)
        {
            if (!playingUsers.Contains(userId))
            {
                playingUsers.Add(userId);
            }

            return(Task.CompletedTask);
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Handle a blueprint becoming selected.
        /// </summary>
        /// <param name="blueprint">The blueprint.</param>
        internal virtual void HandleSelected(SelectionBlueprint <T> blueprint)
        {
            // there are potentially multiple SelectionHandlers active, but we only want to add items to the selected list once.
            if (!SelectedItems.Contains(blueprint.Item))
            {
                SelectedItems.Add(blueprint.Item);
            }

            selectedBlueprints.Add(blueprint);
        }
Ejemplo n.º 6
0
        internal bool FindNext(FindField field, string str)
        {
            if (_words.Count == 0)
            {
                ResetSearch();
                return(false);
            }
            if (_selectedWords.Count == 0)
            {
                _startWord = _wordsView.Cast <WordViewModel>().Last();
            }
            else if (_startWord == null)
            {
                _startWord = _selectedWords[0];
            }
            else if (_selectedWords.Contains(_startWord))
            {
                ResetSearch();
                return(false);
            }

            List <WordViewModel> words   = _wordsView.Cast <WordViewModel>().ToList();
            WordViewModel        curWord = _selectedWords.Count == 0 ? _startWord : _selectedWords[0];
            int wordIndex = words.IndexOf(curWord);

            do
            {
                wordIndex = (wordIndex + 1) % words.Count;
                curWord   = words[wordIndex];
                bool match = false;
                switch (field)
                {
                case FindField.Form:
                    match = curWord.StrRep.Contains(str);
                    break;

                case FindField.Gloss:
                    match = curWord.Meaning.Gloss.Contains(str);
                    break;
                }
                if (match)
                {
                    using (_selectedWordsMonitor.Enter())
                    {
                        _selectedWords.Clear();
                        _selectedWords.Add(curWord);
                    }
                    return(true);
                }
            }while (_startWord != curWord);
            ResetSearch();
            return(false);
        }
            private void collectionChanged()
            {
                Debug.Assert(collectionBeatmaps != null);

                beatmapInCollection = collectionBeatmaps.Contains(beatmap.Value.BeatmapInfo);

                addOrRemoveButton.Enabled.Value = !beatmap.IsDefault;
                addOrRemoveButton.Icon = beatmapInCollection ? FontAwesome.Solid.MinusSquare : FontAwesome.Solid.PlusSquare;
                addOrRemoveButton.TooltipText = beatmapInCollection ? "Remove selected beatmap" : "Add selected beatmap";

                updateButtonVisibility();
            }
Ejemplo n.º 8
0
                private void load(LyricEditorColourProvider colourProvider, ILyricEditorState state)
                {
                    hoveredBackground.Colour = colourHover = colourProvider.Background1(LyricEditorMode.CreateTimeTag);
                    colourSelected           = colourProvider.Colour3(LyricEditorMode.CreateTimeTag);

                    // update selected state by bindable.
                    selectedTimeTags = state.SelectedTimeTags.GetBoundCopy();
                    selectedTimeTags.BindCollectionChanged((a, b) =>
                    {
                        selected = selectedTimeTags.Contains(timeTag);
                        updateState();
                    });

                    Action = () =>
                    {
                        // navigate to current lyric.
                        switch (state.Mode)
                        {
                        case LyricEditorMode.CreateTimeTag:
                            state.BindableCaretPosition.Value = new TimeTagIndexCaretPosition(lyric, timeTag?.Index ?? new TextIndex());
                            break;

                        case LyricEditorMode.RecordTimeTag:
                            state.BindableCaretPosition.Value = new TimeTagCaretPosition(lyric, timeTag);
                            break;

                        case LyricEditorMode.AdjustTimeTag:
                            state.BindableCaretPosition.Value = new NavigateCaretPosition(lyric);
                            break;

                        default:
                            throw new IndexOutOfRangeException(nameof(state.Mode));
                        }

                        // set current time-tag as selected.
                        selectedTimeTags.Clear();
                        if (timeTag == null)
                        {
                            return;
                        }

                        // select time-tag is not null.
                        selectedTimeTags.Add(timeTag);
                        if (timeTag.Time == null)
                        {
                            return;
                        }

                        // seek to target time-tag time if time-tag has time.
                        clock.Seek(timeTag.Time.Value);
                    };
                }
Ejemplo n.º 9
0
 private void beatmapAdded(ValueChangedEvent <WeakReference <BeatmapSetInfo> > weakSet)
 {
     if (weakSet.NewValue.TryGetTarget(out var set))
     {
         Schedule(() =>
         {
             if (!beatmapSets.Contains(set))
             {
                 beatmapSets.Add(set);
             }
         });
     }
 }
Ejemplo n.º 10
0
        Task ISpectatorClient.UserBeganPlaying(int userId, SpectatorState state)
        {
            lock (userLock)
            {
                if (!playingUsers.Contains(userId))
                {
                    playingUsers.Add(userId);
                }

                playingUserStates[userId] = state;
            }

            OnUserBeganPlaying?.Invoke(userId, state);

            return(Task.CompletedTask);
        }
Ejemplo n.º 11
0
        private void updateUserPlayingState(int userId, MultiplayerUserState state)
        {
            bool wasPlaying = PlayingUserIds.Contains(userId);
            bool isPlaying  = state >= MultiplayerUserState.WaitingForLoad && state <= MultiplayerUserState.FinishedPlay;

            if (isPlaying == wasPlaying)
            {
                return;
            }

            if (isPlaying)
            {
                PlayingUserIds.Add(userId);
            }
            else
            {
                PlayingUserIds.Remove(userId);
            }
        }
Ejemplo n.º 12
0
        Task ISpectatorClient.UserBeganPlaying(int userId, SpectatorState state)
        {
            Schedule(() =>
            {
                if (!playingUsers.Contains(userId))
                {
                    playingUsers.Add(userId);
                }

                if (watchedUsers.Contains(userId))
                {
                    watchedUserStates[userId] = state;
                }

                OnUserBeganPlaying?.Invoke(userId, state);
            });

            return(Task.CompletedTask);
        }
Ejemplo n.º 13
0
        Task ISpectatorClient.UserBeganPlaying(int userId, SpectatorState state)
        {
            Schedule(() =>
            {
                if (!playingUsers.Contains(userId))
                {
                    playingUsers.Add(userId);
                }

                // UserBeganPlaying() is called by the server regardless of whether the local user is watching the remote user, and is called a further time when the remote user is watched.
                // This may be a temporary thing (see: https://github.com/ppy/osu-server-spectator/blob/2273778e02cfdb4a9c6a934f2a46a8459cb5d29c/osu.Server.Spectator/Hubs/SpectatorHub.cs#L28-L29).
                // We don't want the user states to update unless the player is being watched, otherwise calling BindUserBeganPlaying() can lead to double invocations.
                if (watchingUsers.Contains(userId))
                {
                    playingUserStates[userId] = state;
                }

                OnUserBeganPlaying?.Invoke(userId, state);
            });

            return(Task.CompletedTask);
        }
Ejemplo n.º 14
0
        public void TestRemoveNotifiesBoundLists()
        {
            const string item = "item";

            bindableStringList.Add(item);
            var listA = new BindableList <string>();

            listA.BindTo(bindableStringList);
            var listB = new BindableList <string>();

            listB.BindTo(bindableStringList);
            var listC = new BindableList <string>();

            listC.BindTo(bindableStringList);

            bindableStringList.Remove(item);

            Assert.Multiple(() =>
            {
                Assert.False(listA.Contains(item));
                Assert.False(listB.Contains(item));
                Assert.False(listC.Contains(item));
            });
        }
Ejemplo n.º 15
0
        internal bool FindNext(FindField field, string str, bool wrap, bool startAtBeginning)
        {
            if (_wordPairs.Count == 0)
            {
                if (wrap)
                {
                    ResetSearch();
                }
                return(false);
            }
            if (!startAtBeginning && _selectedWordPairs.Count == 0)
            {
                _startWordPair = _wordPairsView.Cast <WordPairViewModel>().Last();
            }
            else if (_startWordPair == null)
            {
                _startWordPair = _selectedWordPairs[0];
            }
            else if (!startAtBeginning && _selectedWordPairs.Contains(_startWordPair))
            {
                if (wrap)
                {
                    ResetSearch();
                }
                return(false);
            }

            List <WordPairViewModel> wordPairs = _wordPairsView.Cast <WordPairViewModel>().ToList();
            WordPairViewModel        curWordPair;

            if (startAtBeginning)
            {
                curWordPair = wordPairs[wordPairs.Count - 1];
                if (_startWordPair == curWordPair)
                {
                    ResetSearch();
                    return(false);
                }
            }
            else
            {
                curWordPair = _selectedWordPairs.Count == 0 ? _startWordPair : _selectedWordPairs[0];
            }
            int wordPairIndex = wordPairs.IndexOf(curWordPair);

            do
            {
                wordPairIndex++;
                if (wordPairIndex == wordPairs.Count)
                {
                    if (!wrap && !startAtBeginning && _startWordPair != curWordPair)
                    {
                        return(false);
                    }
                    wordPairIndex = 0;
                }
                curWordPair = wordPairs[wordPairIndex];
                bool match = false;
                switch (field)
                {
                case FindField.Form:
                    match = curWordPair.DomainWordPair.Word1.StrRep.Contains(str) ||
                            curWordPair.DomainWordPair.Word2.StrRep.Contains(str);
                    break;

                case FindField.Gloss:
                    match = curWordPair.Meaning.Gloss.Contains(str);
                    break;
                }
                if (match)
                {
                    using (_selectedWordPairsMonitor.Enter())
                    {
                        _selectedWordPairs.Clear();
                        _selectedWordPairs.Add(curWordPair);
                    }
                    return(true);
                }
            }while (_startWordPair != curWordPair);
            if (wrap)
            {
                ResetSearch();
            }
            return(false);
        }