Ejemplo n.º 1
0
 public void ParseTimeSpan()
 {
     Assert.AreEqual(TimeSpanExtensions.ParseTimeSpan("01.211"), new TimeSpan(0, 0, 0, 1, 211));
     Assert.AreEqual(TimeSpanExtensions.ParseTimeSpan("01.11"), new TimeSpan(0, 0, 0, 1, 110));
     Assert.AreEqual(TimeSpanExtensions.ParseTimeSpan("01.1"), new TimeSpan(0, 0, 0, 1, 100));
     Assert.AreEqual(TimeSpanExtensions.ParseTimeSpan("02,21"), new TimeSpan(0, 0, 0, 2, 210));
     Assert.AreEqual(TimeSpanExtensions.ParseTimeSpan("02,3"), new TimeSpan(0, 0, 0, 2, 300));
     Assert.AreEqual(TimeSpanExtensions.ParseTimeSpan("1:01,111"), new TimeSpan(0, 0, 1, 1, 111));
     Assert.AreEqual(TimeSpanExtensions.ParseTimeSpan("61.111"), new TimeSpan(0, 0, 1, 1, 111));
     Assert.AreEqual(TimeSpanExtensions.ParseTimeSpan("121,11"), new TimeSpan(0, 0, 2, 1, 110));
 }
Ejemplo n.º 2
0
        private bool CheckTime(TextBox txtbox)
        {
            TimeSpan?ts        = TimeSpanExtensions.ParseTimeSpan(txtbox.Text);
            bool     validTime = ts != null;

            if (!validTime && !string.IsNullOrWhiteSpace(txtbox.Text) && txtbox.IsEnabled)
            {
                txtbox.Background = Brushes.Orange;
            }
            else
            {
                txtbox.Background = Brushes.White;
            }

            return(validTime);
        }
Ejemplo n.º 3
0
        private void UpdateRunTime()
        {
            try
            {
                TimeSpan?run    = null;
                TimeSpan?start  = TimeSpanExtensions.ParseTimeSpan(txtStart.Text);
                TimeSpan?finish = TimeSpanExtensions.ParseTimeSpan(txtFinish.Text);

                if (start != null && finish != null)
                {
                    run = (new RoundedTimeSpan((TimeSpan)(finish - start), 2, RoundedTimeSpan.ERoundType.Floor)).TimeSpan;
                }

                if (run != null)
                {
                    txtRun.Text = run?.ToString(@"mm\:ss\,ff");
                }
            }
            catch (Exception)
            { }
        }
Ejemplo n.º 4
0
        private void BtnManualTimeStore_Click(object sender, RoutedEventArgs e)
        {
            TimeSpan?start = null, finish = null, run = null;

            start  = TimeSpanExtensions.ParseTimeSpan(txtStart.Text);
            finish = TimeSpanExtensions.ParseTimeSpan(txtFinish.Text);
            run    = TimeSpanExtensions.ParseTimeSpan(txtRun.Text);

            uint startNumber = 0U;

            try { startNumber = uint.Parse(txtStartNumber.Text); } catch (Exception) { }
            RaceParticipant participant = _thisRace.GetParticipant(startNumber);

            if (participant != null)
            {
                bool bDifference   = object.Equals((cmbManualMode.SelectedItem as CBItem)?.Value, "Difference");
                bool bDeletingTime = (bDifference && (start == null || finish == null)) || run == null;

                if (bDeletingTime)
                {
                    MessageBoxResult messageBoxResult = System.Windows.MessageBox.Show("Manche Zeiten werden gelöscht\nFortfahren?", "Zeiten löschen?", System.Windows.MessageBoxButton.YesNo, MessageBoxImage.Exclamation);
                    if (messageBoxResult == MessageBoxResult.No)
                    {
                        return;
                    }
                }

                if (bDifference)
                {
                    _currentRaceRun.SetStartFinishTime(participant, start, finish);
                }

                _currentRaceRun.SetRunTime(participant, run);
            }

            selectNextParticipant(participant);
        }