コード例 #1
0
        protected override void CalcDayCells()
        {
            DayCells.Clear();
            RowCount    = GetCellRowCount();
            ColumnCount = GetCellColumnCount();

            var rightToLeftLayout = WindowsFormsSettings.GetIsRightToLeftLayout(Calendar);
            var y = DayCellsBounds.Y;

            for (var iRow = 0; iRow < RowCount; ++iRow)
            {
                var x = rightToLeftLayout ? DayCellsBounds.Right - ActualCellSize.Width : DayCellsBounds.X;
                for (var iCol = 0; iCol < ColumnCount; ++iCol)
                {
                    bool correctDate;

                    if (iRow == 0)
                    {
                        if (iCol < PenaltyIndex)
                        {
                            x += rightToLeftLayout ? -ActualCellSize.Width : ActualCellSize.Width;
                            continue;
                        }
                    }

                    DateTime date;
                    try
                    {
                        date = CalcDate(iRow, iCol, out correctDate);
                    }
                    catch
                    {
                        iRow = RowCount;
                        break;
                    }

                    if (correctDate && CanAddDate(date))
                    {
                        var dayCell = (PersianCalendarCellViewInfo)CreateDayCell(date);
                        dayCell.UpdateVisualState();
                        dayCell.Bounds        = CalcCellBounds(x, y);
                        dayCell.Text          = GetCellText(date, iRow, iCol);
                        dayCell.ContentBounds = CalcDayCellContentBounds(dayCell.Bounds);
                        dayCell.CalculateTextBounds();
                        dayCell.Row    = iRow;
                        dayCell.Column = iCol;

                        UpdateDayCell(dayCell);
                        DayCells.Add(dayCell);
                        CalendarInfo.AddCellToNavigationGrid(dayCell, Row, Column, iRow, iCol);
                    }

                    x += rightToLeftLayout ? -ActualCellSize.Width : ActualCellSize.Width;
                }

                y += ActualCellSize.Height;
            }
        }
コード例 #2
0
        public TimeTableViewModel()
        {
            DayCells.Add(new DayCell("上午", 0));
            DayCells.Add(new DayCell("下午", 1));
            DayCells.Add(new DayCell("晚上", 2));

            var today = DateTime.Today;

            var d = today - TimeSpan.FromDays(1);
            //if(d.DayOfWeek == )
            //d.DayOfWeek

            //DateCells.Add(new DateCell());
        }
コード例 #3
0
        public CalendarWeekViewModel(DateTime date)
        {
            _date = date;

            // Vytvoření Commandů pro navigaci kalendářem po týdnech
            Command_CurrentWeek  = new ChangeViewModelCommand <CalendarWeekViewModel>(DateTime.Now);
            Command_PreviousWeek = new ChangeViewModelCommand <CalendarWeekViewModel>(_date.AddDays(-7));
            Command_NextWeek     = new ChangeViewModelCommand <CalendarWeekViewModel>(_date.AddDays(7));

            DayCells = new();
            for (int i = 0; i < 7; i++)
            {
                DayCells.Add(new DayCellViewModel(FirstDay.AddDays(i)));
            }
        }
コード例 #4
0
        public CalendarMonthViewModel(DateTime yearAndMonth)
        {
            _yearAndMonth = yearAndMonth;

            // Vytvoření Commandů pro navigaci kalendářem po měsících
            Command_CurrentMonth  = new ChangeViewModelCommand <CalendarMonthViewModel>(DateTime.Now);
            Command_PreviousMonth = new ChangeViewModelCommand <CalendarMonthViewModel>(_yearAndMonth.AddMonths(-1));
            Command_NextMonth     = new ChangeViewModelCommand <CalendarMonthViewModel>(_yearAndMonth.AddMonths(1));

            // Získá den týdne (po-ne) prvního dne měsíce (a stanoví pondělí jako první den týdne)
            FirstDayOfWeek = ((int)(new DateTime(Year, Month, 1).DayOfWeek) + 6) % 7;

            // Do Listu s buňkami přidá tolik buněk, kolik má měsíc dnů, a zviditelní je
            DayCells = new();
            for (int i = 0; i < DateTime.DaysInMonth(Year, Month); i++)
            {
                DayCells.Add(new DayCellViewModel(new DateTime(Year, Month, i + 1))
                {
                    Visibility = Visibility.Visible
                });
            }
        }