示例#1
0
        private void PrepareTitleLetters()
        {
            var list = new List <TitleLetterModel>();
            int?startNormalLetterIndex = null;


            int wordIndex = 0;

            if (!string.IsNullOrEmpty(this.normalizedAnswer))
            {
                var charArray = this.normalizedAnswer.ToCharArray();
                for (int i = 0; i < charArray.Length; i++)
                {
                    char             item        = charArray[i];
                    TitleLetterModel titleLetter = new TitleLetterModel();
                    this.SetTitleLetterState(titleLetter, TitleLetterState.LetterNotSetted);

                    if (!StringTools.IsOnQuizzAppAlphabet(item))
                    {
                        titleLetter.Letter    = item;
                        titleLetter.wordIndex = -1;
                        this.SetTitleLetterState(titleLetter, TitleLetterState.StaticLetter);

                        if (i > 0 && StringTools.IsOnQuizzAppAlphabet(charArray[i - 1]))
                        {
                            wordIndex++;
                        }
                    }
                    else
                    {
                        titleLetter.wordIndex = wordIndex;
                        if (startNormalLetterIndex == null)
                        {
                            startNormalLetterIndex = i;
                        }

                        if (this.IsTitleFound)
                        {
                            titleLetter.Letter = item;
                            this.SetTitleLetterState(titleLetter, TitleLetterState.LetterSettedAndValid);
                        }
                    }

                    list.Add(titleLetter);
                }
            }

            this.TitleLetters          = list;
            this.CurrentTextInputIndex = startNormalLetterIndex.HasValue ? startNormalLetterIndex.Value : 0;
        }
示例#2
0
        public KeyboardControlViewModel()
        {
            this.DefaultBackgroundLetterBrush   = new SolidColorBrush(Color.FromArgb(255, 255, 187, 51)); //
            this.GoodLetterBackgroundColorBrush = new SolidColorBrush(Color.FromArgb(255, 153, 204, 0));
            this.BadLetterBackgroundColorBrush  = new SolidColorBrush(Color.FromArgb(255, 255, 68, 68));
            this.titleAreaBackgroundBrush       = new SolidColorBrush(Color.FromArgb(255, 255, 136, 0));
            this.NbTotalLetters   = 14;
            this.IsTitleFound     = false;
            this.nbSecondsForHelp = 10;

            if (this.IsInDesignMode)
            {
                this.TitleLetters = new List <TitleLetterModel>();
                TitleLetterModel letterModel = new TitleLetterModel();
                letterModel.Letter = 'A';
                this.SetTitleLetterState(letterModel, TitleLetterState.LetterSetted);
                this.TitleLetters.Add(letterModel);
            }
        }
示例#3
0
        private void SetTitleLetterState(TitleLetterModel letter, TitleLetterState titleLetterState)
        {
            switch (titleLetterState)
            {
            case TitleLetterState.StaticLetter:
                letter.BackgroundBrush   = this.DefaultBackgroundLetterBrush;
                letter.TitleLetterState  = titleLetterState;
                letter.BackgroundOpacity = 0.4;
                break;

            case TitleLetterState.LetterNotSetted:
                letter.BackgroundBrush   = this.DefaultBackgroundLetterBrush;
                letter.TitleLetterState  = titleLetterState;
                letter.BackgroundOpacity = 1;
                break;

            case TitleLetterState.LetterSetted:
                letter.BackgroundBrush   = this.DefaultBackgroundLetterBrush;
                letter.TitleLetterState  = titleLetterState;
                letter.BackgroundOpacity = 1;
                break;

            case TitleLetterState.LetterSettedAndValid:
                letter.BackgroundBrush   = this.GoodLetterBackgroundColorBrush;
                letter.TitleLetterState  = titleLetterState;
                letter.BackgroundOpacity = 1;
                break;

            case TitleLetterState.LetterSettedAndInvalid:
                letter.BackgroundBrush   = this.BadLetterBackgroundColorBrush;
                letter.TitleLetterState  = titleLetterState;
                letter.BackgroundOpacity = 1;
                break;

            default:
                break;
            }
        }