Sha256: 7db9c036550a35b6b46d574fbf4168547372dddd78506882904f165789ee416d

Contents?: true

Size: 1.75 KB

Versions: 24

Compression:

Stored size: 1.75 KB

Contents

using System;
using System.Collections.Generic;
using System.Globalization;
using System.Windows.Automation;
using System.Windows.Automation.Provider;
using System.Windows.Forms;
using WindowsForms.AutomationHelpers;

namespace WindowsForms
{
    public class AutomatableMonthCalendar : MonthCalendar
    {
        private MonthCalendarAutomationProvider _automationProvider;

        private IRawElementProviderSimple RawElementProviderSimple
        {
            get { return _automationProvider ?? (_automationProvider = new MonthCalendarAutomationProvider(this)); }
        }

        protected override void WndProc(ref Message m)
        {
            if (m.Msg == 0x3D /* WM_GETOBJECT */)
            {
                m.Result = AutomationInteropProvider.ReturnRawElementProvider(m.HWnd, m.WParam, m.LParam, RawElementProviderSimple);
                return;
            }

            base.WndProc(ref m);
        }
    }

    internal class MonthCalendarAutomationProvider : AutomationProvider, IValueProvider
    {
        private readonly MonthCalendar _control;

        public MonthCalendarAutomationProvider(MonthCalendar control)
            : base(control)
        {
            _control = control;
        }

        protected override List<int> SupportedPatterns
        {
            get { return new List<int> { ValuePatternIdentifiers.Pattern.Id }; }
        }

        public void SetValue(string value)
        {
            _control.SetDate(DateTime.Parse(value, new CultureInfo("en-US")));
        }

        public string Value
        {
            get { return _control.SelectionStart.ToString(new CultureInfo("en-US")); }
        }

        public bool IsReadOnly { get; private set; }
    }
}

Version data entries

24 entries across 24 versions & 2 rubygems

Version Path
mohawk-1.0 features/support/app/WindowsForms/WindowsForms/AutomatableMonthCalendar.cs
mohawk-0.4.4 features/support/app/WindowsForms/WindowsForms/AutomatableMonthCalendar.cs
mohawk-0.4.3 features/support/app/WindowsForms/WindowsForms/AutomatableMonthCalendar.cs
mohawk-0.4.2 features/support/app/WindowsForms/WindowsForms/AutomatableMonthCalendar.cs
mohawk-0.4.1 features/support/app/WindowsForms/WindowsForms/AutomatableMonthCalendar.cs
mohawk-0.4 features/support/app/WindowsForms/WindowsForms/AutomatableMonthCalendar.cs
mohawk-0.3 features/support/app/WindowsForms/WindowsForms/AutomatableMonthCalendar.cs
mohawk-0.2.1 features/support/app/WindowsForms/WindowsForms/AutomatableMonthCalendar.cs
mohawk-0.2 features/support/app/WindowsForms/WindowsForms/AutomatableMonthCalendar.cs
mohawk-0.1.4 features/support/app/WindowsForms/WindowsForms/AutomatableMonthCalendar.cs
mohawk-0.1.0 features/support/app/WindowsForms/WindowsForms/AutomatableMonthCalendar.cs
mohawk-0.0.9 features/support/app/WindowsForms/WindowsForms/AutomatableMonthCalendar.cs
mohawk-0.0.8 features/support/app/WindowsForms/WindowsForms/AutomatableMonthCalendar.cs
mohawk-0.0.7 features/support/app/WindowsForms/WindowsForms/AutomatableMonthCalendar.cs
rautomation-0.10.0 ext/WindowsForms/WindowsForms/AutomatableMonthCalendar.cs
mohawk-0.0.6 features/support/app/WindowsForms/WindowsForms/AutomatableMonthCalendar.cs
mohawk-0.0.5 features/support/app/WindowsForms/WindowsForms/AutomatableMonthCalendar.cs
rautomation-0.9.4 ext/WindowsForms/WindowsForms/AutomatableMonthCalendar.cs
rautomation-0.9.3 ext/WindowsForms/WindowsForms/AutomatableMonthCalendar.cs
mohawk-0.0.4 features/support/app/WindowsForms/WindowsForms/AutomatableMonthCalendar.cs