/// <summary>
        /// Displays a message box in the session and returns the user's response to the message box.
        /// </summary>
        /// <param name="text">The text to display in the message box.</param>
        /// <param name="caption">The caption of the message box.</param>
        /// <param name="synchronous">true to wait for and return the user's response to the message box. Otherwise, return immediately.</param>
        /// <param name="timeoutSeconds">The amount of time to wait for a response from the user before closing the message box. The system will wait forever if this is set to 0.</param>
        /// <param name="buttons">The buttons to display in the message box.</param>
        /// <param name="icon">The icon to display in the message box.</param>
        /// <param name="defaultButton">The button that should be selected by default in the message box.</param>
        /// <param name="options">Options for the message box.</param>
        /// <returns>
        /// The user's response to the message box. If <paramref name="synchronous" /> is <c>false</c>, the method will always return <see cref="RemoteMessageBoxResult.Asynchronous" />.
        /// If the timeout expired before the user responded to the message box, the result will be <see cref="RemoteMessageBoxResult.Timeout" />.
        /// </returns>
        public RemoteMessageBoxResult MessageBox(
            string text,
            string caption     = null,
            bool synchronous   = false,
            int timeoutSeconds = 0,
            RemoteMessageBoxButtons buttons             = RemoteMessageBoxButtons.Ok,
            RemoteMessageBoxIcon icon                   = RemoteMessageBoxIcon.None,
            RemoteMessageBoxDefaultButton defaultButton = RemoteMessageBoxDefaultButton.Button1,
            RemoteMessageBoxOptions options             = RemoteMessageBoxOptions.None& RemoteMessageBoxOptions.TopMost)
        {
            timeoutSeconds = timeoutSeconds < 0 ? 0 : timeoutSeconds;

            var style = (int)buttons | (int)icon | (int)defaultButton | (int)options;

            var result = NativeMethodsHelper.SendMessage(
                this._server.Handle,
                this._sessionId,
                caption,
                text,
                style,
                timeoutSeconds,
                synchronous);

            return(result == 0 ? RemoteMessageBoxResult.Timeout : result);
        }
        public RemoteMessageBoxResult MessageBox(string text, string caption, RemoteMessageBoxButtons buttons,
                                                 RemoteMessageBoxIcon icon, RemoteMessageBoxDefaultButton defaultButton,
                                                 RemoteMessageBoxOptions options, TimeSpan timeout, bool synchronous)
        {
            int timeoutSeconds = (int)timeout.TotalSeconds;
            int style          = (int)buttons | (int)icon | (int)defaultButton | (int)options;
            // TODO: Win 2003 Server doesn't start timeout counter until user moves mouse in session.
            RemoteMessageBoxResult result =
                NativeMethodsHelper.SendMessage(_server.Handle, _sessionId, caption, text, style, timeoutSeconds,
                                                synchronous);

            // TODO: Windows Server 2008 R2 beta returns 0 if the timeout expires.
            // find out why this happens or file a bug report.
            return(result == 0 ? RemoteMessageBoxResult.Timeout : result);
        }
예제 #3
0
 public RemoteMessageBoxResult MessageBox(string text, string caption, RemoteMessageBoxButtons buttons,
     RemoteMessageBoxIcon icon, RemoteMessageBoxDefaultButton defaultButton, RemoteMessageBoxOptions options,
     TimeSpan timeout, bool synchronous)
 {
     var timeoutSeconds = (int) timeout.TotalSeconds;
     var style = (int) buttons | (int) icon | (int) defaultButton | (int) options;
     // TODO: Win 2003 Server doesn't start timeout counter until user moves mouse in session.
     var result = NativeMethodsHelper.SendMessage(_server.Handle, _sessionId, caption, text, style,
         timeoutSeconds, synchronous);
     // TODO: Windows Server 2008 R2 beta returns 0 if the timeout expires.
     // find out why this happens or file a bug report.
     return result == 0 ? RemoteMessageBoxResult.Timeout : result;
 }