Beispiel #1
0
        void bs_times_CurrentItemChanged(object sender, EventArgs e)
        {
            var selection = grid.SelectedCells.Cast <DataGridViewCell>().Select(fn => fn.RowIndex).Distinct().ToArray();
            var adding    = TimeSpan.Zero;

            foreach (var index in selection)
            {
                var ev = (TimedEvent)grid.Rows[index].DataBoundItem;
                adding += ev.ComputeDuration();
            }
            string msg = "";

            if (selection.Length > 1)
            {
                msg = $" Selection: {(int)adding.TotalHours}:{adding.Minutes:00}";
            }
            var time = TimedEvent.ComputeDuration(Times(), true);

            lblHours.Text = $"Time: {(int)time.TotalHours}:{time.Minutes:00}{msg}";
            if (Started() != null)
            {
                btnStartStop.Text = "Stop Timing";
            }
            else
            {
                btnStartStop.Text = "Start Timing";
            }
        }
Beispiel #2
0
        public void EightHourDayNoBreaks()
        {
            var time = new TimedEvent
            {
                Start = new DateTime(2016, 3, 1, 8, 0, 0),
                End   = new DateTime(2016, 3, 1, 16, 0, 0)
            };
            var duration = time.ComputeDuration();

            Assert.AreEqual(new TimeSpan(8, 0, 0), duration, "Time should be eight hours");
        }
Beispiel #3
0
        public void EightHourDayWithBreak()
        {
            var time1 = new TimedEvent
            {
                Start = new DateTime(2016, 3, 1, 8, 0, 0),
                End   = new DateTime(2016, 3, 1, 12, 0, 0)
            };
            var time2 = new TimedEvent
            {
                Start = new DateTime(2016, 3, 1, 12, 30, 0),
                End   = new DateTime(2016, 3, 1, 16, 30, 0)
            };
            var duration = TimedEvent.ComputeDuration(new[] { time1, time2 });

            Assert.AreEqual(new TimeSpan(8, 0, 0), duration, "Time should be eight hours");
        }