Ejemplo n.º 1
0
        public void Update(Size availableSize, Instant firstVisibleDay)
        {
            ColumnWidth = LayoutHelper.RoundLayoutValue(availableSize.Width / ColumnsCount);

            if (DoubleUtil.GreaterThanOrClose(ColumnWidth * ColumnsCount, availableSize.Width) == true)
            {
                ColumnWidth = LayoutHelper.FloorLayoutValue(availableSize.Width / ColumnsCount);
            }

            RowsHeight = LayoutHelper.RoundLayoutValue(availableSize.Height / RowsCount);

            if (DoubleUtil.GreaterThanOrClose(RowsHeight * RowsCount, availableSize.Height) == true)
            {
                RowsHeight = LayoutHelper.FloorLayoutValue(availableSize.Height / RowsCount);
            }

            GridCellSize = new Size(ColumnWidth, RowsHeight);

            Bounds = LayoutHelper.RoundLayoutRect3(new Rect(0, 0, ColumnWidth * ColumnsCount, RowsHeight * RowsCount));

            double columnOffset = 0;

            Grid = new MonthViewDay[RowsCount][];

            IClock       systemClock = SystemClock.Instance;
            Instant      now         = systemClock.GetCurrentInstant();
            DateTimeZone tz          = DateTimeZoneProviders.Tzdb.GetSystemDefault();
            LocalDate    today       = now.InZone(tz).Date;

            ZonedDateTime currentDay = tz.AtStartOfDay(today);

            for (int rowIndex = 0; rowIndex < RowsCount; rowIndex++)
            {
                columnOffset   = 0;
                Grid[rowIndex] = new MonthViewDay[ColumnsCount];

                for (int columnIndex = 0; columnIndex < ColumnsCount; columnIndex++)
                {
                    // ColumnWidth and RowHeight should be already layout rounded - so no need to round the rect bounds
                    var day = new MonthViewDay();
                    day.GridCell = new Rect(columnIndex * ColumnWidth, rowIndex * RowsHeight, ColumnWidth, RowsHeight);
                    var nextDay = currentDay.Plus(NodaTime.Duration.FromDays(1));
                    day.Day    = new Interval(currentDay.ToInstant(), nextDay.ToInstant()); // may be we should use 23:59:99999 as end interval?????
                    currentDay = nextDay;
                    Grid[rowIndex][columnIndex] = day;
                }

                columnOffset += ColumnWidth;
            }
        }
Ejemplo n.º 2
0
        private Size CalculateGridCell(Size availableSize)
        {
            var ColumnWidth = LayoutHelper.RoundLayoutValue(availableSize.Width / ColumnsCount);

            if (DoubleUtil.GreaterThanOrClose(ColumnWidth * ColumnsCount, availableSize.Width) == true)
            {
                ColumnWidth = LayoutHelper.FloorLayoutValue(availableSize.Width / ColumnsCount);
            }

            var RowsHeight = LayoutHelper.RoundLayoutValue(availableSize.Height / RowsCount);

            if (DoubleUtil.GreaterThanOrClose(RowsHeight * RowsCount, availableSize.Height) == true)
            {
                RowsHeight = LayoutHelper.FloorLayoutValue(availableSize.Height / RowsCount);
            }

            return(new Size(ColumnWidth, RowsHeight));
        }
Ejemplo n.º 3
0
        protected override Size MeasureOverride(Size availableSize)
        {
            var a = VisualScrollableAreaClip;

            scrollOffset = scrollLine = LayoutHelper.RoundLayoutValue(availableSize.Height / (rowsCount - 2));
            extendSize   = availableSize;

            ///ScheduleView.MonthsViewData.Update(availableSize);
            foreach (var child in Children.OfType <UIElement>())
            {
                child.Measure(availableSize);
            }

            if (ScrollOwner != null)
            {
                ScrollOwner.InvalidateScrollInfo();
            }

            return(availableSize);
        }