Ejemplo n.º 1
0
        // Provides Peer if exist in Weak Reference Storage
        private DateTimeAutomationPeer GetPeerFromWeakRefStorage(DateTimeCalendarModePair dateTimeCalendarModePairKey)
        {
            DateTimeAutomationPeer returnPeer = null;
            WeakReference          weakRefEP  = null;

            WeakRefElementProxyStorage.TryGetValue(dateTimeCalendarModePairKey, out weakRefEP);

            if (weakRefEP != null)
            {
                ElementProxy provider = weakRefEP.Target as ElementProxy;
                if (provider != null)
                {
                    returnPeer = PeerFromProvider(provider as IRawElementProviderSimple) as DateTimeAutomationPeer;
                    if (returnPeer == null)
                    {
                        WeakRefElementProxyStorage.Remove(dateTimeCalendarModePairKey);
                    }
                }
                else
                {
                    WeakRefElementProxyStorage.Remove(dateTimeCalendarModePairKey);
                }
            }

            return(returnPeer);
        }
        private DateTimeAutomationPeer GetOrCreateDateTimeAutomationPeer(DateTime date, CalendarMode buttonMode, bool addParentInfo)
        {
            DateTimeCalendarModePair dateTimeCalendarModePair = new DateTimeCalendarModePair(date, buttonMode);
            DateTimeAutomationPeer   dateTimeAutomationPeer   = null;

            this.DateTimePeers.TryGetValue(dateTimeCalendarModePair, out dateTimeAutomationPeer);
            if (dateTimeAutomationPeer == null)
            {
                dateTimeAutomationPeer = this.GetPeerFromWeakRefStorage(dateTimeCalendarModePair);
                if (dateTimeAutomationPeer != null && !addParentInfo)
                {
                    dateTimeAutomationPeer.AncestorsInvalid = false;
                    dateTimeAutomationPeer.ChildrenValid    = false;
                }
            }
            if (dateTimeAutomationPeer == null)
            {
                dateTimeAutomationPeer = new DateTimeAutomationPeer(date, this.OwningCalendar, buttonMode);
                if (addParentInfo && dateTimeAutomationPeer != null)
                {
                    dateTimeAutomationPeer.TrySetParentInfo(this);
                }
            }
            AutomationPeer wrapperPeer = dateTimeAutomationPeer.WrapperPeer;

            if (wrapperPeer != null)
            {
                wrapperPeer.EventsSource = dateTimeAutomationPeer;
            }
            return(dateTimeAutomationPeer);
        }
Ejemplo n.º 3
0
        // Called by DateTimeAutomationPeer
        internal void AddProxyToWeakRefStorage(WeakReference wr, DateTimeAutomationPeer dateTimePeer)
        {
            DateTimeCalendarModePair key = new DateTimeCalendarModePair(dateTimePeer.Date, dateTimePeer.ButtonMode);

            if (GetPeerFromWeakRefStorage(key) == null)
            {
                WeakRefElementProxyStorage.Add(key, wr);
            }
        }
        // Token: 0x06002529 RID: 9513 RVA: 0x000B319C File Offset: 0x000B139C
        protected override List <AutomationPeer> GetChildrenCore()
        {
            if (this.OwningCalendar.MonthControl == null)
            {
                return(null);
            }
            List <AutomationPeer> list = new List <AutomationPeer>();
            Dictionary <DateTimeCalendarModePair, DateTimeAutomationPeer> dictionary = new Dictionary <DateTimeCalendarModePair, DateTimeAutomationPeer>();
            AutomationPeer automationPeer = UIElementAutomationPeer.CreatePeerForElement(this.OwningCalendar.MonthControl.PreviousButton);

            if (automationPeer != null)
            {
                list.Add(automationPeer);
            }
            automationPeer = UIElementAutomationPeer.CreatePeerForElement(this.OwningCalendar.MonthControl.HeaderButton);
            if (automationPeer != null)
            {
                list.Add(automationPeer);
            }
            automationPeer = UIElementAutomationPeer.CreatePeerForElement(this.OwningCalendar.MonthControl.NextButton);
            if (automationPeer != null)
            {
                list.Add(automationPeer);
            }
            foreach (object obj in this.OwningGrid.Children)
            {
                UIElement uielement = (UIElement)obj;
                int       num       = (int)uielement.GetValue(Grid.RowProperty);
                if (this.OwningCalendar.DisplayMode == CalendarMode.Month && num == 0)
                {
                    AutomationPeer automationPeer2 = UIElementAutomationPeer.CreatePeerForElement(uielement);
                    if (automationPeer2 != null)
                    {
                        list.Add(automationPeer2);
                    }
                }
                else
                {
                    Button button = uielement as Button;
                    if (button != null && button.DataContext is DateTime)
                    {
                        DateTime date = (DateTime)button.DataContext;
                        DateTimeAutomationPeer orCreateDateTimeAutomationPeer = this.GetOrCreateDateTimeAutomationPeer(date, this.OwningCalendar.DisplayMode, false);
                        list.Add(orCreateDateTimeAutomationPeer);
                        DateTimeCalendarModePair key = new DateTimeCalendarModePair(date, this.OwningCalendar.DisplayMode);
                        dictionary.Add(key, orCreateDateTimeAutomationPeer);
                    }
                }
            }
            this.DateTimePeers = dictionary;
            return(list);
        }
Ejemplo n.º 5
0
        private DateTimeAutomationPeer GetOrCreateDateTimeAutomationPeer(DateTime date, CalendarMode buttonMode, bool addParentInfo)
        {
            // try to reuse old peer if it exists either in Current AT or in WeakRefStorage of Peers being sent to Client
            DateTimeCalendarModePair key  = new DateTimeCalendarModePair(date, buttonMode);
            DateTimeAutomationPeer   peer = null;

            DateTimePeers.TryGetValue(key, out peer);

            if (peer == null)
            {
                peer = GetPeerFromWeakRefStorage(key);
                if (peer != null && !addParentInfo)
                {
                    // As cached peer is getting used it must be invalidated. addParentInfo check ensures that call is coming from GetChildrenCore
                    peer.AncestorsInvalid = false;
                    peer.ChildrenValid    = false;
                }
            }

            if (peer == null)
            {
                peer = new DateTimeAutomationPeer(date, OwningCalendar, buttonMode);

                // Sets hwnd and parent info
                if (addParentInfo)
                {
                    if (peer != null)
                    {
                        peer.TrySetParentInfo(this);
                    }
                }
            }
            // Set EventsSource if visual exists
            AutomationPeer wrapperPeer = peer.WrapperPeer;

            if (wrapperPeer != null)
            {
                wrapperPeer.EventsSource = peer;
            }

            return(peer);
        }
        // Token: 0x0600252E RID: 9518 RVA: 0x000B346C File Offset: 0x000B166C
        private DateTimeAutomationPeer GetPeerFromWeakRefStorage(DateTimeCalendarModePair dateTimeCalendarModePairKey)
        {
            DateTimeAutomationPeer dateTimeAutomationPeer = null;
            WeakReference          weakReference          = null;

            this.WeakRefElementProxyStorage.TryGetValue(dateTimeCalendarModePairKey, out weakReference);
            if (weakReference != null)
            {
                ElementProxy elementProxy = weakReference.Target as ElementProxy;
                if (elementProxy != null)
                {
                    dateTimeAutomationPeer = (base.PeerFromProvider(elementProxy) as DateTimeAutomationPeer);
                    if (dateTimeAutomationPeer == null)
                    {
                        this.WeakRefElementProxyStorage.Remove(dateTimeCalendarModePairKey);
                    }
                }
                else
                {
                    this.WeakRefElementProxyStorage.Remove(dateTimeCalendarModePairKey);
                }
            }
            return(dateTimeAutomationPeer);
        }
Ejemplo n.º 7
0
        protected override List <AutomationPeer> GetChildrenCore()
        {
            if (OwningCalendar.MonthControl == null)
            {
                return(null);
            }

            List <AutomationPeer> peers = new List <AutomationPeer>();
            Dictionary <DateTimeCalendarModePair, DateTimeAutomationPeer> newChildren = new Dictionary <DateTimeCalendarModePair, DateTimeAutomationPeer>();

            // Step 1: Add previous, header and next buttons
            AutomationPeer buttonPeer;

            buttonPeer = FrameworkElementAutomationPeer.CreatePeerForElement(OwningCalendar.MonthControl.PreviousButton);
            if (buttonPeer != null)
            {
                peers.Add(buttonPeer);
            }
            buttonPeer = FrameworkElementAutomationPeer.CreatePeerForElement(OwningCalendar.MonthControl.HeaderButton);
            if (buttonPeer != null)
            {
                peers.Add(buttonPeer);
            }
            buttonPeer = FrameworkElementAutomationPeer.CreatePeerForElement(OwningCalendar.MonthControl.NextButton);
            if (buttonPeer != null)
            {
                peers.Add(buttonPeer);
            }

            // Step 2: Add Calendar Buttons depending on the Calendar.DisplayMode
            DateTime date;
            DateTimeAutomationPeer peer;

            foreach (UIElement child in this.OwningGrid.Children)
            {
                int childRow = (int)child.GetValue(Grid.RowProperty);
                // first row is day titles
                if (OwningCalendar.DisplayMode == CalendarMode.Month && childRow == 0)
                {
                    AutomationPeer dayTitlePeer = UIElementAutomationPeer.CreatePeerForElement(child);
                    if (dayTitlePeer != null)
                    {
                        peers.Add(dayTitlePeer);
                    }
                }
                else
                {
                    Button owningButton = child as Button;
                    if (owningButton != null && owningButton.DataContext is DateTime)
                    {
                        date = (DateTime)owningButton.DataContext;
                        peer = GetOrCreateDateTimeAutomationPeer(date, OwningCalendar.DisplayMode, /*addParentInfo*/ false);
                        peers.Add(peer);

                        DateTimeCalendarModePair key = new DateTimeCalendarModePair(date, OwningCalendar.DisplayMode);
                        newChildren.Add(key, peer);
                    }
                }
            }

            DateTimePeers = newChildren;
            return(peers);
        }
Ejemplo n.º 8
0
        // Called by DateTimeAutomationPeer
        internal void AddProxyToWeakRefStorage(WeakReference wr, DateTimeAutomationPeer dateTimePeer)
        {
            DateTimeCalendarModePair key = new DateTimeCalendarModePair(dateTimePeer.Date, dateTimePeer.ButtonMode); 

            if (GetPeerFromWeakRefStorage(key) == null) 
                WeakRefElementProxyStorage.Add(key, wr); 
        }
Ejemplo n.º 9
0
        // Provides Peer if exist in Weak Reference Storage 
        private DateTimeAutomationPeer GetPeerFromWeakRefStorage(DateTimeCalendarModePair dateTimeCalendarModePairKey)
        { 
            DateTimeAutomationPeer returnPeer = null; 
            WeakReference weakRefEP = null;
            WeakRefElementProxyStorage.TryGetValue(dateTimeCalendarModePairKey, out weakRefEP); 

            if (weakRefEP != null)
            {
                ElementProxy provider = weakRefEP.Target as ElementProxy; 
                if (provider != null)
                { 
                    returnPeer = PeerFromProvider(provider as IRawElementProviderSimple) as DateTimeAutomationPeer; 
                    if (returnPeer == null)
                        WeakRefElementProxyStorage.Remove(dateTimeCalendarModePairKey); 
                }
                else
                    WeakRefElementProxyStorage.Remove(dateTimeCalendarModePairKey);
 
            }
 
            return returnPeer; 
        }
Ejemplo n.º 10
0
        private DateTimeAutomationPeer GetOrCreateDateTimeAutomationPeer(DateTime date, CalendarMode buttonMode, bool addParentInfo)
        {
            // try to reuse old peer if it exists either in Current AT or in WeakRefStorage of Peers being sent to Client
            DateTimeCalendarModePair key = new DateTimeCalendarModePair(date, buttonMode); 
            DateTimeAutomationPeer peer = null;
            DateTimePeers.TryGetValue(key, out peer); 
 
            if (peer == null)
            { 
                peer = GetPeerFromWeakRefStorage(key);
                if (peer != null && !addParentInfo)
                {
                    // As cached peer is getting used it must be invalidated. addParentInfo check ensures that call is coming from GetChildrenCore 
                    peer.AncestorsInvalid = false;
                    peer.ChildrenValid = false; 
                } 
            }
 
            if( peer == null )
            {
                peer = new DateTimeAutomationPeer(date, OwningCalendar, buttonMode);
 
                // Sets hwnd and parent info
                if (addParentInfo) 
                { 
                    if(peer != null)
                        peer.TrySetParentInfo(this); 
                }
            }
            // Set EventsSource if visual exists
            AutomationPeer wrapperPeer = peer.WrapperPeer; 
            if (wrapperPeer != null)
            { 
                wrapperPeer.EventsSource = peer; 
            }
 
            return peer;
        }
Ejemplo n.º 11
0
        protected override List<AutomationPeer> GetChildrenCore()
        {
            if (OwningCalendar.MonthControl == null)
            { 
                return null;
            } 
 
            List<AutomationPeer> peers = new List<AutomationPeer>();
            Dictionary<DateTimeCalendarModePair, DateTimeAutomationPeer> newChildren = new Dictionary<DateTimeCalendarModePair,DateTimeAutomationPeer>(); 

            // Step 1: Add previous, header and next buttons
            AutomationPeer buttonPeer;
            buttonPeer = FrameworkElementAutomationPeer.CreatePeerForElement(OwningCalendar.MonthControl.PreviousButton); 
            if (buttonPeer != null)
            { 
                peers.Add(buttonPeer); 
            }
            buttonPeer = FrameworkElementAutomationPeer.CreatePeerForElement(OwningCalendar.MonthControl.HeaderButton); 
            if (buttonPeer != null)
            {
                peers.Add(buttonPeer);
            } 
            buttonPeer = FrameworkElementAutomationPeer.CreatePeerForElement(OwningCalendar.MonthControl.NextButton);
            if (buttonPeer != null) 
            { 
                peers.Add(buttonPeer);
            } 

            // Step 2: Add Calendar Buttons depending on the Calendar.DisplayMode
            DateTime date;
            DateTimeAutomationPeer peer; 
            foreach (UIElement child in this.OwningGrid.Children)
            { 
                int childRow = (int)child.GetValue(Grid.RowProperty); 
                // first row is day titles
                if (OwningCalendar.DisplayMode == CalendarMode.Month && childRow == 0) 
                {
                    AutomationPeer dayTitlePeer = UIElementAutomationPeer.CreatePeerForElement(child);
                    peers.Add(dayTitlePeer);
                } 
                else
                { 
                    Button owningButton = child as Button; 
                    if (owningButton != null && owningButton.DataContext is DateTime)
                    { 
                        date = (DateTime)owningButton.DataContext;
                        peer = GetOrCreateDateTimeAutomationPeer(date, OwningCalendar.DisplayMode, /*addParentInfo*/ false);
                        peers.Add(peer);
 
                        DateTimeCalendarModePair key = new DateTimeCalendarModePair(date, OwningCalendar.DisplayMode);
                        newChildren.Add(key, peer); 
                    } 
                }
            } 

            DateTimePeers = newChildren;
            return peers;
        }