Exemplo n.º 1
0
 private HandWriting GetHandWriting(int?userId = null)
 {
     return(new HandWriting
     {
         UserId = userId,
         Pauses = Math.Round(PausesList.Average(), 2),
         Holding = Math.Round(HoldingList.Average(), 2),
         ErrorsCount = Math.Round((double)(ErrorCount * 100) / UserText.Length, 2),
         Overlapping = Math.Round((double)(OverlappingCount * 100) / UserText.Length, 2),
         Speed = Math.Round((double)UserText.Length / ((DateTime)EndEnterDate - (DateTime)StartEnterDate).TotalMinutes, 2)
     });
 }
Exemplo n.º 2
0
        protected void AddCharacter(string c)
        {
            if (UserText.Length == 0)
            {
                StartEnterDate = DateTime.Now;
                KeyPressDate   = DateTime.Now;
            }
            else
            {
                PausesList.Add((DateTime.Now - (DateTime)KeyPressDate).TotalMilliseconds);
                KeyPressDate = DateTime.Now;
            }

            UserText += c;

            if (UserText.Length == CurrentText.Length)
            {
                EndEnterDate      = DateTime.Now;
                Login.IsEnabled   = true;
                NewUser.IsEnabled = true;
            }

            Brush runType = null;


            if (UserText.Length > CurrentText.Length)
            {
                return;
            }
            else
            {
                c = CurrentText[UserText.Length - 1].ToString();
                if (UserText[UserText.Length - 1] == CurrentText[UserText.Length - 1])
                {
                    runType = Good;
                }
                else
                {
                    runType = Bad;
                    ErrorCount++;
                }
            }

            if (runType != null)
            {
                if (Building.Background == runType)
                {
                    Building.Text += c;
                }
                else
                {
                    if (Building.Text.Length > 0)
                    {
                        Runs.AddLast(Building);
                    }
                    Building            = new Run(c);
                    Building.Background = runType;
                }
            }

            UpdateParagraph();
        }