Esempio n. 1
0
 public RequestEventArgs(RequestType new_info_type, string new_title, string new_message, List<string> new_options, string new_default_option, RequestReply new_result, bool suppressable)
     : base() {
     title = new_title;
     message = new_message;
     info_type = new_info_type;
     options = new_options;
     default_option = new_default_option;
     result = new_result;
     this.suppressable = suppressable;
 }
Esempio n. 2
0
        protected static RequestReply Request(RequestType type, string title, string message, List<string> choices, string default_choice, bool suppressable) {
            RequestReply request = new RequestReply();

            if (type == RequestType.Choice && (choices == null || choices.Count == 0))
                throw new CommunicatableException("Request Error", "A choice was requested, but no options provided");


            RequestEventArgs e = new RequestEventArgs(type, title, message, choices, default_choice, request, suppressable);

            ICommunicationReceiver receiver = getReceiver();

            if (receiver == null) {
                request.Cancelled = true;
                return request;
            }

			if (receiver.ThreadBridge != null) {
                if (receiver.isSameContext()) {
                    receiver.requestInformation(e);
                } else {
					receiver.ThreadBridge.Post(delegate() {
                        RequestEventHandler handler = receiver.requestInformation;
                        if (handler != null) {
                            handler(e);
                        }
                    });
                    waitForResponse(e);
                }
            } else {
                receiver.requestInformation(e);
            }


            switch (e.response) {
                case ResponseType.Cancel:
                case ResponseType.No:
                    e.result.Cancelled = true;
                    break;
            }

            return e.result;
        }