コード例 #1
0
        Dictionary <string, string> CollectCommonProperties(FrameworkElement source, EventArgs e)
        {
            Dictionary <string, string> properties = new Dictionary <string, string>();

            properties["Name"]      = source.Name;
            properties["ClassName"] = source.GetType().ToString();

            if (previousArgs == null)
            {
                previousArgs = new PreviousArgs()
                {
                    EventArgs = e, Id = (currentId++).ToString("X")
                };
            }
            else
            {
                if (e == null || !Object.ReferenceEquals(previousArgs.EventArgs, e))
                {
                    previousArgs = new PreviousArgs()
                    {
                        EventArgs = e, Id = (currentId++).ToString("X")
                    };
                }
            }
            properties["#e"] = previousArgs.Id;

            AutomationPeer automation = GetAutomationPeer(source);

            if (automation == null)
            {
                return(properties);
            }

            properties["Name"] = string.IsNullOrEmpty(source.Name) ? automation.GetName() : source.Name;

            string itemType = automation.GetItemType();

            if (!string.IsNullOrEmpty(itemType))
            {
                properties["ItemType"] = itemType;
            }

            var automationId = automation.GetAutomationId();

            if (!string.IsNullOrEmpty(automationId))
            {
                properties["AutomationID"] = automationId;
            }

            properties["ControlType"]   = automation.GetAutomationControlType().ToString();
            properties["windowCaption"] = properties["Name"];

            CollectValue(properties, automation);
            return(properties);
        }
コード例 #2
0
        public override void GetItemType_AttachedProperty()
        {
            TabControl tabControl = new TabControl();

            CreateAsyncTest(tabControl,
                            () => {
                TabItem tabItem     = new TabItem();
                AutomationPeer peer = FrameworkElementAutomationPeer.CreatePeerForElement(tabItem);

                Assert.AreEqual(string.Empty, peer.GetItemType(), "GetItemType");

                string itemType = "My Item Type";

                tabItem.SetValue(AutomationProperties.ItemTypeProperty, itemType);
                Assert.AreEqual(string.Empty, peer.GetItemType(), "GetItemType #1");

                tabItem.SetValue(AutomationProperties.ItemTypeProperty, null);
                Assert.AreEqual(string.Empty, peer.GetItemType(), "GetItemType #2");
            });
        }
コード例 #3
0
        protected override string GetItemTypeCore()
        {
            AutomationPeer wrapperPeer = this.GetWrapperPeer();

            if (wrapperPeer != null)
            {
                return(wrapperPeer.GetItemType());
            }

            return(string.Empty);
        }