Example #1
0
 public CalendarCellAccessibleObject(CalendarRowAccessibleObject calendarRowAccessibleObject,
                                     CalendarBodyAccessibleObject calendarBodyAccessibleObject,
                                     MonthCalendarAccessibleObject monthCalendarAccessibleObject,
                                     int calendarIndex, int rowIndex, int columnIndex)
     : base(monthCalendarAccessibleObject)
 {
     _calendarRowAccessibleObject   = calendarRowAccessibleObject;
     _calendarBodyAccessibleObject  = calendarBodyAccessibleObject;
     _monthCalendarAccessibleObject = monthCalendarAccessibleObject;
     _calendarIndex = calendarIndex;
     _rowIndex      = rowIndex;
     _columnIndex   = columnIndex;
     // RuntimeId don't change if the calendar date range is not changed,
     // otherwise the calendar accessibility tree will be rebuilt.
     // So save this value one time to avoid recreating new structures and making extra calculations.
     _initRuntimeId = new int[]
     {
         _calendarRowAccessibleObject.RuntimeId[0],
         _calendarRowAccessibleObject.RuntimeId[1],
         _calendarRowAccessibleObject.RuntimeId[2],
         _calendarRowAccessibleObject.RuntimeId[3],
         _calendarRowAccessibleObject.RuntimeId[4],
         GetChildId()
     };
 }
            internal override UiaCore.IRawElementProviderFragment ElementProviderFromPoint(double x, double y)
            {
                int innerX = (int)x;
                int innerY = (int)y;

                MCHITTESTINFO hitTestInfo = GetHitTestInfo(innerX, innerY);

                switch ((MCHT)hitTestInfo.uHit)
                {
                case MCHT.TITLEBTNPREV:
                    return(GetCalendarChildAccessibleObject(_calendarIndex, CalendarChildType.PreviousButton));

                case MCHT.TITLEBTNNEXT:
                    return(GetCalendarChildAccessibleObject(_calendarIndex, CalendarChildType.NextButton));

                case MCHT.TITLE:
                case MCHT.TITLEMONTH:
                case MCHT.TITLEYEAR:
                    return(GetCalendarChildAccessibleObject(_calendarIndex, CalendarChildType.CalendarHeader));

                case MCHT.CALENDARDAY:
                case MCHT.CALENDARWEEKNUM:
                case MCHT.CALENDARDATE:
                    // Get calendar body's child.
                    CalendarBodyAccessibleObject calendarBodyAccessibleObject = (CalendarBodyAccessibleObject)GetCalendarChildAccessibleObject(_calendarIndex, CalendarChildType.CalendarBody);
                    return(calendarBodyAccessibleObject.GetFromPoint(hitTestInfo));

                case MCHT.TODAYLINK:
                    return(GetCalendarChildAccessibleObject(_calendarIndex, CalendarChildType.TodayLink));
                }

                return(base.ElementProviderFromPoint(x, y));
            }
Example #3
0
        public void CalendarBodyAccessibleObject_ControlType_IsTable()
        {
            using MonthCalendar control = new MonthCalendar();
            CalendarBodyAccessibleObject accessibleObject = CreateCalendarBodyAccessibleObject(control);

            Assert.Equal(UiaCore.UIA.TableControlTypeId, accessibleObject.GetPropertyValue(UiaCore.UIA.ControlTypePropertyId));
            Assert.False(control.IsHandleCreated);
        }
Example #4
0
        public void CalendarBodyAccessibleObject_ctor_Default()
        {
            using MonthCalendar calendar = new MonthCalendar();
            MonthCalendarAccessibleObject calendarAccessibleObject = new MonthCalendarAccessibleObject(calendar);
            CalendarBodyAccessibleObject  bodyAccessibleObject     = new CalendarBodyAccessibleObject(calendarAccessibleObject, 0);

            Assert.Equal(calendarAccessibleObject, bodyAccessibleObject.Parent);
        }
Example #5
0
        public void CalendarBodyAccessibleObject_State_IsDefault()
        {
            using MonthCalendar control = new MonthCalendar();
            CalendarBodyAccessibleObject accessibleObject = CreateCalendarBodyAccessibleObject(control);

            Assert.Equal(AccessibleStates.Default, accessibleObject.State);
            Assert.False(control.IsHandleCreated);
        }
Example #6
0
        public void CalendarBodyAccessibleObject_GetChildId_ReturnsExpected()
        {
            using MonthCalendar control = new MonthCalendar();
            CalendarBodyAccessibleObject accessibleObject = CreateCalendarBodyAccessibleObject(control);

            Assert.Equal(2, accessibleObject.GetChildId());
            Assert.False(control.IsHandleCreated);
        }
Example #7
0
        public void CalendarBodyAccessibleObject_Role_IsTable()
        {
            using MonthCalendar control = new MonthCalendar();
            CalendarBodyAccessibleObject accessibleObject = CreateCalendarBodyAccessibleObject(control);

            Assert.Equal(AccessibleRole.Table, accessibleObject.Role);
            Assert.False(control.IsHandleCreated);
        }
Example #8
0
        public void CalendarBodyAccessibleObject_Supports_GridAndTablePatterns(int pattern)
        {
            using MonthCalendar control = new MonthCalendar();
            CalendarBodyAccessibleObject accessibleObject = CreateCalendarBodyAccessibleObject(control);

            Assert.True(accessibleObject.IsPatternSupported((UiaCore.UIA)pattern));
            Assert.False(control.IsHandleCreated);
        }
Example #9
0
        public void CalendarBodyAccessibleObject_GetColumnHeaders_HasSevenCells()
        {
            using MonthCalendar control = new MonthCalendar();

            control.CreateControl();
            CalendarBodyAccessibleObject accessibleObject = CreateCalendarBodyAccessibleObject(control);

            Assert.Equal(7, accessibleObject.GetColumnHeaders().Length); // Contains days of week
            Assert.True(control.IsHandleCreated);
        }
Example #10
0
        public void CalendarBodyAccessibleObject_GetColumnHeaders_IsNull_IfViewIsNotMonth(int view)
        {
            using MonthCalendar control = new MonthCalendar();

            control.CreateControl();
            User32.SendMessageW(control, (User32.WM)MCM.SETCURRENTVIEW, IntPtr.Zero, (IntPtr)view);
            CalendarBodyAccessibleObject accessibleObject = CreateCalendarBodyAccessibleObject(control);

            Assert.Null(accessibleObject.GetColumnHeaders());
            Assert.True(control.IsHandleCreated);
        }
Example #11
0
        public void CalendarBodyAccessibleObject_ColumnCount_ReturnsExpected(int view, int expected)
        {
            using MonthCalendar control = new MonthCalendar();

            control.CreateControl();
            User32.SendMessageW(control, (User32.WM)MCM.SETCURRENTVIEW, IntPtr.Zero, (IntPtr)view);
            CalendarBodyAccessibleObject accessibleObject = CreateCalendarBodyAccessibleObject(control);

            Assert.Equal(expected, accessibleObject.ColumnCount);
            Assert.True(control.IsHandleCreated);
        }
Example #12
0
        public void CalendarBodyAccessibleObject_Bounds_HasExpectedSize()
        {
            using MonthCalendar control = new MonthCalendar();

            control.CreateControl();
            CalendarBodyAccessibleObject accessibleObject = CreateCalendarBodyAccessibleObject(control);

            Assert.Equal(217, accessibleObject.Bounds.Width);
            Assert.Equal(106, accessibleObject.Bounds.Height);
            Assert.True(control.IsHandleCreated);
        }
 public CalendarWeekNumberCellAccessibleObject(CalendarRowAccessibleObject calendarRowAccessibleObject,
                                               CalendarBodyAccessibleObject calendarBodyAccessibleObject,
                                               MonthCalendarAccessibleObject monthCalendarAccessibleObject,
                                               int calendarIndex, int rowIndex, int columnIndex, string weekNumber)
     : base(calendarRowAccessibleObject, calendarBodyAccessibleObject,
            monthCalendarAccessibleObject, calendarIndex, rowIndex, columnIndex)
 {
     _calendarRowAccessibleObject = calendarRowAccessibleObject;
     // Name don't change if the calendar date range is not changed,
     // otherwise the calendar accessibility tree will be rebuilt.
     // So save this value one time to avoid sending messages to Windows every time.
     _weekNumber = weekNumber;
 }
        public ScenarioResult CalendarBodyAccessibleObject_GetFromPoint_ReturnsNull_IfMCHITTESTINFOIsIncorrect(TParams p)
        {
            using var wrapper = new MonthCalendarWrapper(this);
            Application.DoEvents();
            MonthCalendarAccessibleObject accessibleObject     = (MonthCalendarAccessibleObject)wrapper.Calendar.AccessibilityObject;
            CalendarBodyAccessibleObject  bodyAccessibleObject = new CalendarBodyAccessibleObject(accessibleObject, 0);
            MCHITTESTINFO info = new MCHITTESTINFO
            {
                uHit = MCHT.CALENDARDAY,
                iRow = -10
            };

            Application.DoEvents();
            CalendarChildAccessibleObject cell = bodyAccessibleObject.GetFromPoint(info);

            return(new ScenarioResult(cell is null));
        }
Example #15
0
        public void CalendarBodyAccessibleObject_Name_IsExpected(int view, int calendarIndex, string expected)
        {
            using MonthCalendar control = new MonthCalendar();
            control.FirstDayOfWeek      = Day.Sunday;
            control.Size           = new Size(450, 450);
            control.SelectionStart = new DateTime(2021, 1, 1);

            control.CreateControl();
            User32.SendMessageW(control, (User32.WM)MCM.SETCURRENTVIEW, IntPtr.Zero, (IntPtr)view);
            MonthCalendarAccessibleObject             controlAccessibleObject = (MonthCalendarAccessibleObject)control.AccessibilityObject;
            LinkedListNode <CalendarAccessibleObject> calendarNode            = controlAccessibleObject.CalendarsAccessibleObjects.First;

            for (int i = 1; i <= calendarIndex; i++)
            {
                calendarNode = calendarNode.Next;
            }

            Assert.NotNull(calendarNode);

            CalendarBodyAccessibleObject calendarBody = calendarNode.Value.CalendarBodyAccessibleObject;

            Assert.Equal(expected, calendarBody.Name);
            Assert.True(control.IsHandleCreated);
        }
 public CalendarRowAccessibleObject(MonthCalendarAccessibleObject calendarAccessibleObject, int calendarIndex, CalendarBodyAccessibleObject parentAccessibleObject, int rowIndex)
     : base(calendarAccessibleObject, calendarIndex, CalendarChildType.CalendarRow, parentAccessibleObject, rowIndex)
 {
     _rowIndex = rowIndex;
 }