コード例 #1
0
        /// <summary>
        /// Specify which control or form we should use for the relative position.
        /// </summary>
        public void UseOn(ReflectionTester control)
        {
            if (mouseControl == null)
            {
                Win32.GetCursorPos(out originalPosition);
            }

            if (control == null)
            {
                throw new ArgumentNullException("control");
            }

            mouseControl = new MouseControl(control);

            PositioXunit = GraphicsUnit.Pixel;

            // Block any user input while we are active.
            if (!restoreUserInput)
            {
                if (!Win32.BlockInput(true))
                {
                    //throw new Win32Exception();
                }

                restoreUserInput = true;
            }
        }
コード例 #2
0
        /// <summary>
        /// Initializes the KeyboardController, blocks user input, and sets
        /// the focus on the specified control.
        /// </summary>
        /// <param name="control">The ControlTester to use the keyboard on.</param>
        public void UseOn(ReflectionTester control)
        {
            if (control == null)
            {
                throw new ArgumentNullException("control");
            }

            Control c = control.TheObject as Control;

            FormsAssert.IsTrue(c != null, "Keyboard control requires tester of Control");
            sendKeys = sendKeysFactory.Create(c.Handle);

            keyboardControl = new KeyboardControl(control);

            if (!restoreUserInput)
            {
                //if this next line returns false, I used to throw an exception...
                Win32.BlockInput(true);
                restoreUserInput = true;
            }
        }
コード例 #3
0
        /// <summary>
        /// Initializes the KeyboardController, blocks user input, and sets
        /// the focus on the specified control.
        /// </summary>
        /// <param name="control">The ControlTester to use the keyboard on.</param>
        public void UseOn(ReflectionTester control)
        {
            if (control == null)
            {
                throw new ArgumentNullException("control");
            }

            Control c = control.TheObject as Control;
            FormsAssert.IsTrue(c != null, "Keyboard control requires tester of Control");
            sendKeys = sendKeysFactory.Create(c.Handle);

            keyboardControl = new KeyboardControl(control);

            if (!restoreUserInput)
            {
                //if this next line returns false, I used to throw an exception...
                Win32.BlockInput(true);
                restoreUserInput = true;
            }
        }
コード例 #4
0
 internal MouseControl(ReflectionTester tester)
 {
     this.tester = tester;
 }
コード例 #5
0
 internal MouseControl(ReflectionTester tester)
 {
     this.tester = tester;
 }
コード例 #6
0
 /// <summary>
 ///   Creates and initialises a new instance of the class for the specified tester.
 /// </summary>
 /// <remarks>
 ///   The <see cref="Position">mouse position</see> is relative to the <see cref="Control"/> managed by
 ///   the <paramref name="controlTester"/>.
 ///   <para>
 ///   While the <b>MouseController</b> is active, user keyboard and mouse input is disabled.  For this
 ///   reason the <b>MouseController</b> should be disposed of when the testing is concluded.
 ///   </para>
 /// </remarks>
 /// <example>
 /// <code>
 /// using (MouseController mouse = new MouseControler(myTestControl))
 /// {
 ///   mouse.Position = new PointF(1,1);
 ///   mouse.PressAndRelease(MouseButtons.Middle);
 /// }
 /// </code>
 /// </example>
 public MouseController(ReflectionTester controlTester)
 {
     UseOn(controlTester);
 }
コード例 #7
0
 internal KeyboardControl(ReflectionTester tester)
 {
     this.tester = tester;
 }
コード例 #8
0
        /// <summary>
        /// Specify which control or form we should use for the relative position.
        /// </summary>
        public void UseOn(ReflectionTester control)
        {
            if (mouseControl == null)
            {
                Win32.GetCursorPos(out originalPosition);
            }

            if (control == null)
            {
                throw new ArgumentNullException("control");
            }

            mouseControl = new MouseControl(control);

            PositioXunit = GraphicsUnit.Pixel;

            // Block any user input while we are active.
            if (!restoreUserInput)
            {
                if (!Win32.BlockInput(true))
                {
                    //throw new Win32Exception();
                }

                restoreUserInput = true;
            }
        }
コード例 #9
0
 /// <summary>
 ///   Creates and initialises a new instance of the class for the specified tester.
 /// </summary>
 /// <remarks>
 ///   The <see cref="Position">mouse position</see> is relative to the <see cref="Control"/> managed by
 ///   the <paramref name="controlTester"/>.
 ///   <para>
 ///   While the <b>MouseController</b> is active, user keyboard and mouse input is disabled.  For this
 ///   reason the <b>MouseController</b> should be disposed of when the testing is concluded.
 ///   </para>
 /// </remarks>
 /// <example>
 /// <code>
 /// using (MouseController mouse = new MouseControler(myTestControl))
 /// {
 ///   mouse.Position = new PointF(1,1);
 ///   mouse.PressAndRelease(MouseButtons.Middle);
 /// }
 /// </code>
 /// </example>
 public MouseController(ReflectionTester controlTester)
 {
     UseOn(controlTester);
 }