Exemple #1
0
        /// <summary>
        /// Returns the text label of the CalendarButton that is associated with
        /// this CalendarButtonAutomationPeer. This method is called by GetName.
        /// </summary>
        /// <returns>
        /// The text label of the element that is associated with this
        /// automation peer.
        /// </returns>
        /// <remarks>
        /// The name property can be thought of as the string of text that a
        /// user would use to explain which control is being referred to.  It is
        /// important to have a textual representation for all controls in the
        /// graphical user interface (GUI) so that you can programmatically
        /// refer to the control in a localized manner.  The value is settable
        /// on control instances through the AutomationProperties.Name attached
        /// property.
        /// </remarks>
        protected override string GetNameCore()
        {
            string name = base.GetNameCore();

            if (string.IsNullOrEmpty(name))
            {
                AutomationPeer labeledBy = GetLabeledByCore();
                if (labeledBy != null)
                {
                    name = labeledBy.GetName();
                }

                CalendarButton button = this.OwningCalendarButton;
                if (string.IsNullOrEmpty(name) && button != null)
                {
                    if (button.DataContext is DateTime)
                    {
                        if (this.OwningCalendar.DisplayMode == CalendarMode.Decade)
                        {
                            name = DateTimeHelper.ToYearString((DateTime)button.DataContext);
                        }
                        else
                        {
                            name = DateTimeHelper.ToYearMonthPatternString((DateTime)button.DataContext);
                        }
                    }
                    else if (button.Content != null)
                    {
                        name = string.Format(DateTimeHelper.GetCurrentDateFormat(), button.Content.ToString());
                    }
                }
            }
            return(name);
        }
Exemple #2
0
        /// <summary>Gets the text label of the <see cref="T:System.Windows.UIElement" /> that corresponds to the data item in the <see cref="P:System.Windows.Controls.ItemsControl.Items" /> collection that is associated with this <see cref="T:System.Windows.Automation.Peers.ItemAutomationPeer" />. </summary>
        /// <returns>The text label.</returns>
        // Token: 0x0600271E RID: 10014 RVA: 0x000B8FD4 File Offset: 0x000B71D4
        protected override string GetNameCore()
        {
            AutomationPeer wrapperPeer = this.GetWrapperPeer();
            string         text        = null;
            object         item        = this.Item;

            if (wrapperPeer != null)
            {
                text = wrapperPeer.GetName();
            }
            else if (item != null)
            {
                using (RecyclableWrapper recyclableWrapperPeer = this.ItemsControlAutomationPeer.GetRecyclableWrapperPeer(item))
                {
                    text = recyclableWrapperPeer.Peer.GetName();
                }
            }
            if (string.IsNullOrEmpty(text) && item != null)
            {
                FrameworkElement frameworkElement = item as FrameworkElement;
                if (frameworkElement != null)
                {
                    text = frameworkElement.GetPlainText();
                }
                if (string.IsNullOrEmpty(text))
                {
                    text = item.ToString();
                }
            }
            return(text);
        }
        /// <summary>
        /// Returns the text label of the CalendarDayButton that is associated
        /// with this CalendarDayButtonAutomationPeer. This method is called by
        /// GetName.
        /// </summary>
        /// <returns>
        /// The text label of the element that is associated with this
        /// automation peer.
        /// </returns>
        /// <remarks>
        /// The name property can be thought of as the string of text that a
        /// user would use to explain which control is being referred to.  It is
        /// important to have a textual representation for all controls in the
        /// graphical user interface (GUI) so that you can programmatically
        /// refer to the control in a localized manner.  The value is settable
        /// on control instances through the AutomationProperties.Name attached
        /// property.
        /// </remarks>
        protected override string GetNameCore()
        {
            string name = base.GetNameCore();

            if (string.IsNullOrEmpty(name))
            {
                AutomationPeer labeledBy = GetLabeledByCore();
                if (labeledBy != null)
                {
                    name = labeledBy.GetName();
                }

                CalendarDayButton button = OwningCalendarDayButton;
                if (string.IsNullOrEmpty(name) && button != null)
                {
                    if (button.DataContext is DateTime)
                    {
                        name = ((DateTime)button.DataContext).ToLongDateString();
                    }
                    else if (button.Content != null)
                    {
                        name = string.Format(DateTimeHelper.GetCurrentDateFormat(), button.Content.ToString());
                    }
                }
            }
            return(name);
        }
        ///
        protected override string GetNameCore()
        {
            AutomationPeer wrapperPeer = GetWrapperPeer();
            string         name        = null;
            object         item        = Item;

            if (wrapperPeer != null)
            {
                name = wrapperPeer.GetName();
            }
            else if (item != null)
            {
                using (RecyclableWrapper recyclableWrapper = ItemsControlAutomationPeer.GetRecyclableWrapperPeer(item))
                {
                    name = recyclableWrapper.Peer.GetName();
                }
            }

            if (string.IsNullOrEmpty(name) && item != null)
            {
                // For FE we can't use ToString as that provides extraneous information than just the plain text
                FrameworkElement fe = item as FrameworkElement;
                if (fe != null)
                {
                    name = fe.GetPlainText();
                }

                if (string.IsNullOrEmpty(name))
                {
                    name = item.ToString();
                }
            }

            return(name);
        }
Exemple #5
0
        public string GetName()
        {
            AutomationPeer labeledByPeer = GetLabeledBy();

            if (labeledByPeer != null)
            {
                return(labeledByPeer.GetName() ?? string.Empty);
            }
            else
            {
                return(GetNameCore());
            }
        }
Exemple #6
0
        /// <summary>Gets the text label of the element that is associated with this <see cref="T:System.Windows.Automation.Peers.TextAutomationPeer" />. Called by <see cref="M:System.Windows.Automation.Peers.AutomationPeer.GetName" />.</summary>
        /// <returns>The value of <see cref="P:System.Windows.Automation.AutomationProperties.Name" /> or <see cref="P:System.Windows.Automation.AutomationProperties.LabeledBy" /> if either is set; otherwise this method returns an empty string. </returns>
        // Token: 0x06002832 RID: 10290 RVA: 0x000BBCD8 File Offset: 0x000B9ED8
        protected override string GetNameCore()
        {
            string name = AutomationProperties.GetName(base.Owner);

            if (string.IsNullOrEmpty(name))
            {
                AutomationPeer labeledByCore = this.GetLabeledByCore();
                if (labeledByCore != null)
                {
                    name = labeledByCore.GetName();
                }
            }
            return(name ?? string.Empty);
        }
Exemple #7
0
        /// <summary>
        /// GetNameCore will return a value matching (in priority order)
        ///
        /// 1. Automation.Name
        /// 2. GetLabeledBy.Name
        /// 3. String.Empty
        ///
        /// This differs from the base implementation in that we must
        /// never return GetPlainText() .
        /// </summary>
        override protected string GetNameCore()
        {
            string result = AutomationProperties.GetName(this.Owner);

            if (string.IsNullOrEmpty(result))
            {
                AutomationPeer labelAutomationPeer = GetLabeledByCore();
                if (labelAutomationPeer != null)
                {
                    result = labelAutomationPeer.GetName();
                }
            }

            return(result ?? string.Empty);
        }
        ///
        protected override string GetNameCore()
        {
            AutomationPeer wrapperPeer = OwningCellPeer;
            string         name        = null;

            if (wrapperPeer != null)
            {
                name = wrapperPeer.GetName();
            }

            if (string.IsNullOrEmpty(name))
            {
                name = SR.Get(SRID.DataGridCellItemAutomationPeer_NameCoreFormat, Item, _column.DisplayIndex);
            }

            return(name);
        }
        /// <summary>
        /// Overrides the GetNameCore method for CalendarDayButtonAutomationPeer
        /// </summary>
        /// <returns></returns>
        protected override string GetNameCore()
        {
            string nameCore = base.GetNameCore();

            if (string.IsNullOrEmpty(nameCore))
            {
                AutomationPeer labeledByCore = this.GetLabeledByCore();
                if (labeledByCore != null)
                {
                    nameCore = labeledByCore.GetName();
                }
                if (string.IsNullOrEmpty(nameCore) && this.OwningCalendarDayButton != null && this.OwningCalendarDayButton.Content != null)
                {
                    nameCore = string.Format(DateTimeHelper.GetCurrentDateFormat(), this.OwningCalendarDayButton.Content.ToString());
                }
            }
            return(nameCore);
        }
Exemple #10
0
        /// <summary>Gets the text label of the <see cref="T:System.Windows.ContentElement" /> that is associated with this <see cref="T:System.Windows.Automation.Peers.ContentElementAutomationPeer" />. Called by <see cref="M:System.Windows.Automation.Peers.AutomationPeer.GetName" />.</summary>
        /// <returns>The text label of the element that is associated with this automation peer.</returns>
        // Token: 0x0600269C RID: 9884 RVA: 0x000B7880 File Offset: 0x000B5A80
        protected override string GetNameCore()
        {
            string text = base.GetNameCore();

            if (string.IsNullOrEmpty(text))
            {
                AutomationPeer labeledByCore = this.GetLabeledByCore();
                if (labeledByCore != null)
                {
                    text = labeledByCore.GetName();
                }
                if (string.IsNullOrEmpty(text))
                {
                    text = ((FrameworkElement)base.Owner).GetPlainText();
                }
            }
            return(text ?? string.Empty);
        }
        /// <summary>
        /// Inherited code: Requires comment.
        /// </summary>
        /// <returns>Inherited code: Requires comment 1.</returns>
        protected override string GetNameCore()
        {
            string nameCore = base.GetNameCore();

            if (string.IsNullOrEmpty(nameCore))
            {
                AutomationPeer labeledByCore = this.GetLabeledByCore();
                if (labeledByCore != null)
                {
                    nameCore = labeledByCore.GetName();
                }
                if (string.IsNullOrEmpty(nameCore))
                {
                    nameCore = this.OwningDatePicker.ToString();
                }
            }
            return(nameCore);
        }
        /// <summary>
        /// Gets the text label of the
        /// <see cref="T:System.Windows.Controls.FloatableWindow" /> that is
        /// associated with this
        /// <see cref="T:System.Windows.Automation.Peers.FloatableWindowAutomationPeer" />.
        /// Called by
        /// <see cref="M:System.Windows.Automation.Peers.AutomationPeer.GetName" />.
        /// </summary>
        /// <returns>
        /// The text label of the element that is associated with this
        /// automation peer.
        /// </returns>
        protected override string GetNameCore()
        {
            string name = base.GetNameCore();

            if (string.IsNullOrEmpty(name))
            {
                AutomationPeer labeledBy = GetLabeledByCore();
                if (labeledBy != null)
                {
                    name = labeledBy.GetName();
                }

                if (string.IsNullOrEmpty(name) && this.OwningFloatableWindow.Title != null)
                {
                    name = this.OwningFloatableWindow.Title.ToString();
                }
            }
            return(name);
        }
Exemple #13
0
        /// <summary>
        /// Returns the text label of the GlobalCalendar that is associated with this
        /// GlobalCalendarAutomationPeer.  This method is called by GetName.
        /// </summary>
        /// <returns>
        /// The text label of the element that is associated with this
        /// automation peer.
        /// </returns>
        protected override string GetNameCore()
        {
            string name = base.GetNameCore();

            if (string.IsNullOrEmpty(name))
            {
                AutomationPeer labeledBy = GetLabeledByCore();
                if (labeledBy != null)
                {
                    name = labeledBy.GetName();
                }

                if (string.IsNullOrEmpty(name))
                {
                    name = OwningCalendar.ToString();
                }
            }
            return(name);
        }
        // Token: 0x06002590 RID: 9616 RVA: 0x000B4920 File Offset: 0x000B2B20
        protected override string GetNameCore()
        {
            AutomationPeer owningCellPeer = this.OwningCellPeer;
            string         text           = null;

            if (owningCellPeer != null)
            {
                text = owningCellPeer.GetName();
            }
            if (string.IsNullOrEmpty(text))
            {
                text = SR.Get("DataGridCellItemAutomationPeer_NameCoreFormat", new object[]
                {
                    this.Item,
                    this._column.DisplayIndex
                });
            }
            return(text);
        }
Exemple #15
0
        ///
        override protected string GetNameCore()
        {
            string result = base.GetNameCore();

            if (string.IsNullOrEmpty(result))
            {
                AutomationPeer labelAutomationPeer = GetLabeledByCore();
                if (labelAutomationPeer != null)
                {
                    result = labelAutomationPeer.GetName();
                }

                if (string.IsNullOrEmpty(result))
                {
                    result = ((FrameworkElement)Owner).GetPlainText();
                }
            }

            return(result ?? string.Empty);
        }
        /// <summary>
        /// Returns the text label of the GlobalCalendarButton that is associated with
        /// this GlobalCalendarButtonAutomationPeer. This method is called by GetName.
        /// </summary>
        /// <returns>
        /// The text label of the element that is associated with this
        /// automation peer.
        /// </returns>
        /// <remarks>
        /// The name property can be thought of as the string of text that a
        /// user would use to explain which control is being referred to.  It is
        /// important to have a textual representation for all controls in the
        /// graphical user interface (GUI) so that you can programmatically
        /// refer to the control in a localized manner.  The value is settable
        /// on control instances through the AutomationProperties.Name attached
        /// property.
        /// </remarks>
        protected override string GetNameCore()
        {
            string name = base.GetNameCore();

            if (string.IsNullOrEmpty(name))
            {
                AutomationPeer labeledBy = GetLabeledByCore();
                if (labeledBy != null)
                {
                    name = labeledBy.GetName();
                }

                if (string.IsNullOrEmpty(name) && OwningCalendarButton.Content != null)
                {
                    name = string.Format(
                        OwningCalendar.Info.DateFormatInfo,
                        OwningCalendarButton.Content.ToString());
                }
            }
            return(name);
        }
Exemple #17
0
 /// <summary>
 /// Gets text that describes the DataPager that is associated with this automation peer.
 /// Called by System.Windows.Automation.Peers.AutomationPeer.GetName().
 /// </summary>
 /// <returns>
 /// When the control is not paging data:
 /// - Value returned by the base implementation if it's not empty
 /// - Name of the owning DataPager control if it's not empty
 /// - Name returned by the LabeledBy automation peer if it's not empty
 /// - DataPager class name if none of the above is valid
 /// When the control is paging data:
 /// - "Page N" when the total page count is unknown
 /// - "Page N of M" when the count is known
 /// </returns>
 protected override string GetNameCore()
 {
     if (this.OwningDataPager.Source == null || this.OwningDataPager.PageSize == 0)
     {
         string name = base.GetNameCore();
         if (string.IsNullOrEmpty(name))
         {
             name = this.OwningDataPager.Name;
         }
         if (string.IsNullOrEmpty(name))
         {
             AutomationPeer labeledByAutomationPeer = this.GetLabeledByCore();
             if (labeledByAutomationPeer != null)
             {
                 name = labeledByAutomationPeer.GetName();
             }
         }
         if (string.IsNullOrEmpty(name))
         {
             name = this.GetClassNameCore();
         }
         return(name);
     }
     if (this.OwningDataPager.PagedSource != null &&
         this.OwningDataPager.PagedSource.TotalItemCount == -1)
     {
         // Returns "Page M"
         return(string.Format(
                    CultureInfo.InvariantCulture,
                    PagerResources3.AutomationPeerName_TotalPageCountUnknown,
                    (this.OwningDataPager.PageIndex + 1).ToString(CultureInfo.CurrentCulture)));
     }
     // Returns "Page M of N"
     return(string.Format(
                CultureInfo.InvariantCulture,
                PagerResources3.AutomationPeerName_TotalPageCountKnown,
                (this.OwningDataPager.PageIndex + 1).ToString(CultureInfo.CurrentCulture),
                this.OwningDataPager.PageCount.ToString(CultureInfo.CurrentCulture)));
 }
        protected override string GetNameCore()
        {
            ButtonBase buttonBase = Owner as ButtonBase;

            // Only when Content is TextBlock TextBlock.Name is returned
            string name = buttonBase.Content as string;

            if (name == null)
            {
                TextBlock textblock = buttonBase.Content as TextBlock;
                if (textblock == null)
                {
                    name = string.Empty;
                }
                else
                {
                    AutomationPeer peer
                         = FrameworkElementAutomationPeer.CreatePeerForElement(textblock);
                    name = peer.GetName();
                }
            }

            return(buttonBase.GetValue(AutomationProperties.NameProperty) as string ?? name);
        }
 private static object GetName(AutomationPeer peer)                  {   return peer.GetName();          }