Example #1
0
        private void InitTimes(List <DateTime> startEnd)
        {
            StackPanel.Children.Clear();
            double totalHours = TimeServer.DecToQuarter(DataBaseManager.Instance.HoursInRange(startEnd[0], startEnd[1]).TotalHours);

            if (DateTimeFormatInfo.CurrentInfo != null)
            {
                WpfWeekViewBar weekViewBar = new WpfWeekViewBar(startEnd[0], totalHours);
                weekViewBar.DeleteWeekEvent  += OnDeleteWeek;
                weekViewBar.EmailWeekEvent   += HtmlTimeReporter.OnEmailWeek;
                weekViewBar.PreviewWeekEvent += HtmlTimeReporter.OnPreviewWeek;
                StackPanel.Children.Add(weekViewBar);
            }

            Day prev = new Day(new DateTime(2001, 1, 1));

            foreach (Day day in DataBaseManager.Instance.DaysInRange(startEnd[0], startEnd[1]))
            {
                WpfDayViewBar datevViewBar = new WpfDayViewBar(day);
                datevViewBar.DayClickEvent  += OnDateViewClick;
                datevViewBar.DeleteDayEvent += OnDeleteDayClick;
                StackPanel.Children.Add(datevViewBar);
                foreach (Time time in day.Times)
                {
                    WpfTimeViewBar timeView = new WpfTimeViewBar(time, _24Hour);
                    timeView.TimeDeleteEvent += TimeDeleteTime;
                    timeView.TimeClickEvent  += TimeViewTimeClick;
                    StackPanel.Children.Add(timeView);
                }

                prev = day;
            }

            TotalTime.Content = totalHours;
        }
Example #2
0
        private void OnDateViewClick(Day day)
        {
            if (day == null)
            {
                return;
            }

            WpfDayViewEdit dayView = new WpfDayViewEdit(day);

            dayView.ShowDialog();

            InitTimes(TimeServer.StartEndWeek(_baseDate));
        }
Example #3
0
        public void Test_PushPull()
        {
            Day         day1   = new Day(new DateTime(2001, 11, 7, 9, 44, 15, 411));
            List <Time> times1 = new List <Time>();

            times1.Add(new Time(new DateTime(2001, 11, 7, 9, 44, 15, 411), new DateTime(2001, 11, 7, 12, 3, 1, 411))
            {
                Key = TimeServer.GenerateId()
            });
            times1.Add(new Time(new DateTime(2001, 11, 7, 1, 00, 00, 200), new DateTime(2001, 11, 7, 3, 00, 1, 999))
            {
                Key = TimeServer.GenerateId()
            });
            day1.Times   = times1;
            day1.Details = "does this even work any more?";

            Day         day2   = new Day(new DateTime(2051, 11, 6, 8, 44, 15, 411));
            List <Time> times2 = new List <Time>();

            times2.Add(new Time(new DateTime(2051, 11, 6, 8, 44, 15, 411), new DateTime(2051, 11, 6, 12, 30, 1, 100))
            {
                Key = TimeServer.GenerateId()
            });
            times2.Add(new Time(new DateTime(2051, 11, 6, 10, 4, 15, 411), new DateTime(2051, 11, 6, 11, 44, 15, 411))
            {
                Key = TimeServer.GenerateId()
            });
            day2.Times   = times2;
            day2.Details = "lets try again.....";

            Day         day3   = new Day(new DateTime(2021, 4, 3, 5, 5, 5, 888));
            List <Time> times3 = new List <Time>();

            times3.Add(new Time(new DateTime(2021, 4, 3, 5, 5, 5, 888), new DateTime(2021, 4, 3, 8, 5, 9, 800))
            {
                Key = TimeServer.GenerateId()
            });
            times3.Add(new Time(new DateTime(2021, 4, 3, 1, 5, 9, 800), new DateTime(2021, 4, 3, 6, 55, 9, 800))
            {
                Key = TimeServer.GenerateId()
            });
            day3.Times   = times3;
            day3.Details = "one more time!";

            var push = new List <Day>()
            {
                day1, day2, day3
            };

            _instance.Push(push);
            var pull = _instance.Pull();

            foreach (Day day in push)
            {
                bool contains = false;
                foreach (Day d in pull)
                {
                    if (Day.Equals(day, d))
                    {
                        contains = true;
                    }
                }
                Assert.IsTrue(contains);
            }
            Assert.IsTrue(push.Count == pull.Count);
        }
Example #4
0
 private void OnDeleteDayClick(Day day)
 {
     DataBaseManager.Instance.DeleteDay(day.Date);
     InitTimes(TimeServer.StartEndWeek(_baseDate));
 }