Respond() public method

public Respond ( Xwt.Command cmd ) : void
cmd Xwt.Command
return void
Beispiel #1
0
        public void TwoResponds()
        {
            // When Respond is called twice before leaving an event handler, the last call is the good one

            using (var win = new Dialog()) {
                Application.TimeoutInvoke(10, delegate {
                    win.Respond(Command.Ok);
                    win.Respond(Command.Apply);
                    return(false);
                });
                var cmd = win.Run();
                Assert.AreEqual(Command.Apply, cmd);
            }
        }
Beispiel #2
0
		public void TwoResponds ()
		{
			// When Respond is called twice before leaving an event handler, the last call is the good one

			using (var win = new Dialog ()) {
				Application.TimeoutInvoke (10, delegate {
					win.Respond (Command.Ok);
					win.Respond (Command.Apply);
					return false;
				});
				var cmd = win.Run ();
				Assert.AreEqual (Command.Apply, cmd);
			}
		}
Beispiel #3
0
        public void RespondOnClosing()
        {
            // Respond can be used in a CloseRequest handler to provide a result for the Run method

            using (var win = new Dialog()) {
                bool closeResult = false;
                win.Buttons.Add(new DialogButton(Command.Ok));
                win.CloseRequested += delegate(object sender, CloseRequestedEventArgs args) {
                    win.Respond(Command.Apply);
                };
                Application.TimeoutInvoke(10, delegate {
                    closeResult = win.Close();
                    return(false);
                });
                var cmd = win.Run();
                Assert.AreEqual(Command.Apply, cmd);
                Assert.IsTrue(closeResult);
            }
        }
Beispiel #4
0
		public void RespondDoesNotFireClose ()
		{
			// The close event is not fired after running a dialog

			bool closed = false, closing = false;
			using (var win = new Dialog ()) {
				win.Buttons.Add (new DialogButton (Command.Ok));
				win.CloseRequested += (sender, e) => closing = true;
				win.Closed += (sender, e) => closed = true;
				Application.TimeoutInvoke (10, delegate {
					win.Respond (Command.Apply);
					return false;
				});
				var cmd = win.Run ();
				Assert.IsFalse (closing, "CloseRequested event should not be fired");
				Assert.IsFalse (closed, "Close event should not be fired");
				Assert.AreEqual (Command.Apply, cmd);
			}
			Assert.IsFalse (closing, "CloseRequested event should not be fired when disposing");
			Assert.IsFalse (closed, "Close event should not be fired when disposing");
		}
Beispiel #5
0
        public void RespondDoesNotFireClose()
        {
            // The close event is not fired after running a dialog

            bool closed = false, closing = false;

            using (var win = new Dialog()) {
                win.Buttons.Add(new DialogButton(Command.Ok));
                win.CloseRequested += (sender, e) => closing = true;
                win.Closed         += (sender, e) => closed = true;
                Application.TimeoutInvoke(10, delegate {
                    win.Respond(Command.Apply);
                    return(false);
                });
                var cmd = win.Run();
                Assert.IsFalse(closing, "CloseRequested event should not be fired");
                Assert.IsFalse(closed, "Close event should not be fired");
                Assert.AreEqual(Command.Apply, cmd);
            }
            Assert.IsFalse(closing, "CloseRequested event should not be fired when disposing");
            Assert.IsFalse(closed, "Close event should not be fired when disposing");
        }
Beispiel #6
0
		public void RespondOnClosing ()
		{
			// Respond can be used in a CloseRequest handler to provide a result for the Run method

			using (var win = new Dialog ()) {
				bool closeResult = false;
				win.Buttons.Add (new DialogButton (Command.Ok));
				win.CloseRequested += delegate(object sender, CloseRequestedEventArgs args) {
					win.Respond (Command.Apply);
				};
				Application.TimeoutInvoke (10, delegate {
					closeResult = win.Close ();
					return false;
				});
				var cmd = win.Run ();
				Assert.AreEqual (Command.Apply, cmd);
				Assert.IsTrue (closeResult);
			}
		}