Ejemplo n.º 1
0
        public override void requestInformation(RequestEventArgs e)
        {
            switch (e.info_type) {
                case RequestType.BackupFolder:
                    if (changeBackupPath()) {
                        e.result.Cancelled = false;
                        e.response = ResponseType.OK;
                    } else {
                        e.result.Cancelled = true;
                        e.response = ResponseType.Cancel;
                    }
                    return;
                case RequestType.SyncFolder:
                    if (changeSyncPath()) {
                        e.result.Cancelled = false;
                        e.response = ResponseType.OK;
                    } else {
                        e.result.Cancelled = true;
                        e.response = ResponseType.Cancel;
                    }
                    return;

                default:
                    base.requestInformation(e);
                    break;
            }
        }
Ejemplo n.º 2
0
 public override void requestInformation(RequestEventArgs e)
 {
     switch (e.info_type) {
         default:
             base.requestInformation(e);
             return;
     }
 }
Ejemplo n.º 3
0
 public MessageBox(RequestEventArgs e, AViewWindow owner, IEmailSource email_source)
     : this(e.title, e.message, e.suppressable, owner, email_source) {
     this.e = e;
     switch (e.info_type) {
         case RequestType.Question:
             yesButton.Visibility = System.Windows.Visibility.Visible;
             noButton.Visibility = System.Windows.Visibility.Visible;
             questionIcon.Visibility = System.Windows.Visibility.Visible;
             break;
         default:
             this.DialogResult = false;
             throw new NotImplementedException();
     }
     this.Suppress.Content = Strings.GetLabelString("SuppressFurtherRequests");
 }
Ejemplo n.º 4
0
 public ChoiceWindow(RequestEventArgs e, AViewWindow owner)
     : base(owner, null) {
     InitializeComponent();
     this.Icon = owner.Icon;
     TranslationHelpers.translateWindow(this);
     int selected = 0;
     this.Title = e.title;
     messageGrp.Header = e.message;
     foreach (string add_me in e.options) {
         choiceCombo.Items.Add(add_me);
         if (add_me == e.default_option)
             choiceCombo.SelectedIndex = selected;
         selected++;
     }
 }
Ejemplo n.º 5
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;
        }
Ejemplo n.º 6
0
        public bool askTranslatedQuestion(String string_name, bool suppressable, params string[] variables) {
            StringCollection mes = Strings.getStrings(string_name);
            string title, message;

            if (mes.ContainsKey(StringType.Title))
                title = mes[StringType.Title].interpret(variables);
            else
                title = string_name;

            if (mes.ContainsKey(StringType.Message))
                message = mes[StringType.Message].interpret(variables);
            else
                message = string_name;

            RequestEventArgs e = new RequestEventArgs(RequestType.Question, title, message, null, null, new RequestReply(), suppressable);
            return displayQuestion(e);
        }
Ejemplo n.º 7
0
 public bool displayQuestion(RequestEventArgs e) {
     MessageBox box = new MessageBox(e, this, this.email_source);
     bool result = box.ShowDialog() == true;
     if (result) {
         e.result.SelectedOption = "Yes";
         e.result.SelectedIndex = 1;
         e.response = ResponseType.OK;
     } else {
         e.response = ResponseType.Cancel;
     }
     e.result.Suppressed = box.Suppressed;
     return result;
 }
Ejemplo n.º 8
0
 public virtual void requestInformation(RequestEventArgs e) {
     switch (e.info_type) {
         case RequestType.Question:
             displayQuestion(e);
             return;
         case RequestType.Choice:
             ChoiceWindow choice = new ChoiceWindow(e, this);
             if ((bool)choice.ShowDialog()) {
                 choice.Close();
                 e.result.SelectedIndex = choice.selected_index;
                 e.result.SelectedOption = choice.selected_item;
                 e.response = ResponseType.OK;
             } else {
                 e.response = ResponseType.Cancel;
             }
             return;
         default:
             throw new NotImplementedException("The specified request type " + e.info_type.ToString() + " is not supported in this GUI toolkit.");
     }
 }