public static RequestReply Request(RequestType type, string title, string message, List<string> choices, string default_choice) { RequestReply request = new RequestReply(); if(type== RequestType.Choice&&choices==null) throw new MException("NeedInfo Error","A choice was requested, but no options provided",true); RequestEventArgs e = new RequestEventArgs(type,title,message,choices,default_choice,request); ICommunicationReceiver receiver = getReceiver(); if(receiver==null) { request.cancelled =true; return request; } if(receiver.context!=null) { receiver.context.Post(new SendOrPostCallback(delegate(object state) { RequestEventHandler handler = receiver.requestInformation; if(handler!=null) { handler(e); } }),null); } else { receiver.requestInformation(e); } waitForResponse(e); if(e.response== ResponseType.Cancel||e.response== ResponseType.No) e.result.cancelled = true; return e.result; }
public RequestEventArgs(RequestType new_info_type, string new_title, string new_message, List<string> new_options, string new_default_option, RequestReply new_result) : base() { title = new_title; message = new_message; info_type = new_info_type; options = new_options; default_option = new_default_option; result = new_result; }