示例#1
0
        public void ShowDay(DateTime day)
        {
            Title = day.ToString("dd.MM.yyyy");

            var      tasks = new Dictionary <Task, TimeSpan>();
            TimeSpan total = new TimeSpan();

            var nextDay = day.AddDays(1).Date;

            foreach (var period in TaskPeriod.GetForDay(day))
            {
                var periodLength = (period.End < nextDay ? period.End : nextDay) - (period.Start > day ? period.Start : day);
                if (tasks.ContainsKey(period.Task))
                {
                    tasks[period.Task] += periodLength;
                }
                else
                {
                    tasks.Add(period.Task, periodLength);
                }
                total += periodLength;
            }

            Periods.Clear();
            foreach (var pair in tasks)
            {
                Periods.Add(new TaskData()
                {
                    Task = pair.Key.Name, Length = pair.Value.ToJira()
                });
            }

            dayText.Text = string.Format("Total: {0}", total.ToJira());
        }
示例#2
0
 public static void Load(JsonArray json)
 {
     foreach (JsonValue jperiod in json)
     {
         TaskPeriod period = new TaskPeriod(jperiod);
         Periods.Add(period);
     }
 }
示例#3
0
        public void SetDay(DateTime day)
        {
            _day = day;
            var nextDay = day.AddDays(1).Date;

            dayText.Text = day.ToString("dd.MM");
            grid.Children.Clear();
            grid.RowDefinitions.Clear();

            try
            {
                var last = day.Date;//.AddHours(8);
                int row  = 0;
                foreach (var period in TaskPeriod.GetForDay(day))
                {
                    var start = period.Start > last ? period.Start : last;
                    var end   = period.End < nextDay ? period.End : nextDay;

                    if (start > last)
                    {
                        var length = start - last;
                        grid.RowDefinitions.Add(new RowDefinition()
                        {
                            Height = new GridLength(length.TotalMinutes, GridUnitType.Star)
                        });
                        row++;
                    }
                    var periodLength = end - start;
                    grid.RowDefinitions.Add(new RowDefinition()
                    {
                        Height = new GridLength(periodLength.TotalMinutes, GridUnitType.Star)
                    });
                    var tb = new TextBlock
                    {
                        Text                = period.Task.Name,
                        TextWrapping        = TextWrapping.Wrap,
                        HorizontalAlignment = HorizontalAlignment.Stretch
                    };
                    var rect = new Rectangle();// { Stroke = new SolidColorBrush(Color.FromRgb(112, 112, 112)) };
                    grid.Children.Add(rect);
                    grid.Children.Add(tb);
                    Grid.SetRow(rect, row);
                    Grid.SetRow(tb, row);

                    last = end;
                    row++;
                }

                if (last < nextDay)
                {
                    var length = nextDay - last;
                    grid.RowDefinitions.Add(new RowDefinition()
                    {
                        Height = new GridLength(length.TotalMinutes, GridUnitType.Star)
                    });
                }
            }
            catch
            {
            }
        }