Esempio n. 1
0
            private CalendarRowAccessibleObject GetCalendarRow(int calendarIndex, AccessibleObject parentAccessibleObject, int rowIndex)
            {
                if ((HasHeaderRow ? rowIndex < -1 : rowIndex < 0) ||
                    rowIndex >= RowCount)
                {
                    return(null);
                }

                // Search name for the first cell in the row.
                bool success = GetCalendarGridInfo(
                    ComCtl32.MCGIF.DATE,
                    ComCtl32.MCGIP.CALENDARCELL,
                    calendarIndex,
                    rowIndex,
                    0,
                    out RECT calendarPartRectangle,
                    out Kernel32.SYSTEMTIME endDate,
                    out Kernel32.SYSTEMTIME startDate);

                if (!success)
                {
                    // Not able to get cell date for the row.
                    return(null);
                }

                SelectionRange cellsRange = _owner.GetDisplayRange(false);

                if (cellsRange.Start > DateTimePicker.SysTimeToDateTime(endDate) || cellsRange.End < DateTimePicker.SysTimeToDateTime(startDate))
                {
                    // Do not create row if the row's first cell is out of the current calendar's view range.
                    return(null);
                }

                return(new CalendarRowAccessibleObject(this, calendarIndex, (CalendarBodyAccessibleObject)parentAccessibleObject, rowIndex));
            }
Esempio n. 2
0
            private CalendarCellAccessibleObject GetCalendarCell(int calendarIndex, AccessibleObject parentAccessibleObject, int columnIndex)
            {
                if (columnIndex < 0 ||
                    columnIndex >= MAX_DAYS ||
                    columnIndex >= ColumnCount)
                {
                    return(null);
                }

                CalendarRowAccessibleObject parentRowAccessibleObject = (CalendarRowAccessibleObject)parentAccessibleObject;
                int  rowIndex      = parentRowAccessibleObject.RowIndex;
                bool getNameResult = GetCalendarGridInfoText(ComCtl32.MCGIP.CALENDARCELL, calendarIndex, rowIndex, columnIndex, out string text);
                bool getDateResult = GetCalendarGridInfo(ComCtl32.MCGIF.DATE, ComCtl32.MCGIP.CALENDARCELL,
                                                         calendarIndex,
                                                         rowIndex,
                                                         columnIndex,
                                                         out RECT rectangle,
                                                         out Kernel32.SYSTEMTIME systemEndDate,
                                                         out Kernel32.SYSTEMTIME systemStartDate);

                DateTime endDate   = DateTimePicker.SysTimeToDateTime(systemEndDate).Date;
                DateTime startDate = DateTimePicker.SysTimeToDateTime(systemStartDate).Date;

                if (getNameResult && !string.IsNullOrEmpty(text))
                {
                    string cellName = GetCalendarCellName(endDate, startDate, text, rowIndex == -1);

                    // The cell is present on the calendar, so create accessible object for it.
                    return(new CalendarCellAccessibleObject(this, calendarIndex, parentAccessibleObject, rowIndex, columnIndex, cellName));
                }

                return(null);
            }