Пример #1
0
        public void TestPropChangeEvent()
        {
            using (AppHost host = new AppHost("notepad.exe", ""))
            {
                TransformPattern transformPattern = (TransformPattern)host.Element.GetCurrentPattern(TransformPattern.Pattern);

                PropertyChangeHandler handler = new PropertyChangeHandler();
                Automation.AddAutomationPropertyChangedEventHandler(
                    host.Element,
                    TreeScope.Element,
                    new AutomationPropertyChangedEventHandler(handler.HandleEvent),
                    AutomationElement.BoundingRectangleProperty);
                handler.Start();
                System.Threading.Thread.Sleep(100 /* ms */);
                transformPattern.Move(200, 200);
                Assert.IsTrue(handler.Confirm());
                Assert.IsNotNull(handler.EventSource);
                Assert.AreEqual(host.Element, handler.EventSource);
                Automation.RemoveAutomationPropertyChangedEventHandler(
                    host.Element,
                    new AutomationPropertyChangedEventHandler(handler.HandleEvent));
            }
        }
Пример #2
0
        public void TestPropChangeEvent()
        {
            using (AppHost host = new AppHost("notepad.exe", ""))
            {
                TransformPattern transformPattern = (TransformPattern)host.Element.GetCurrentPattern(TransformPattern.Pattern);

                PropertyChangeHandler handler = new PropertyChangeHandler();
                Automation.AddAutomationPropertyChangedEventHandler(
                    host.Element,
                    TreeScope.Element,
                    new AutomationPropertyChangedEventHandler(handler.HandleEvent),
                    AutomationElement.BoundingRectangleProperty);
                handler.Start();
                System.Threading.Thread.Sleep(100 /* ms */);
                transformPattern.Move(200, 200);
                Assert.IsTrue(handler.Confirm());
                Assert.IsNotNull(handler.EventSource);
                Assert.AreEqual(host.Element, handler.EventSource);
                Automation.RemoveAutomationPropertyChangedEventHandler(
                    host.Element,
                    new AutomationPropertyChangedEventHandler(handler.HandleEvent));
            }
        }