Beispiel #1
0
        void HandleAddButtonClicked(object sender, EventArgs e)
        {
            if (service.Status == Status.NotAdded)
            {
                var addProjects = new Dictionary <string, DotNetProject> ();

                foreach (DotNetProject project in service.Project.ParentSolution.GetAllProjects().Where(p => p is DotNetProject && p != service.Project))
                {
                    var svc = project.GetConnectedServicesBinding()?.SupportedServices.FirstOrDefault(s => s.Id == service.Id);
                    if (svc != null && svc.Status == Status.NotAdded)
                    {
                        addProjects [project.ItemId] = project;
                    }
                }

                var servicesToAdd = new List <IConnectedService> ();

                if (addProjects.Count > 0)
                {
                    var question = new Xwt.QuestionMessage(GettextCatalog.GetString("Add {0} to {1}", this.Service.DisplayName, this.Service.Project.Name));
                    question.SecondaryText = GettextCatalog.GetString("Also add '{0}' to other projects in the solution?", this.Service.DisplayName);

                    foreach (var project in addProjects)
                    {
                        question.AddOption(project.Key, project.Value.Name, true);
                    }

                    var cmdContinue    = new Command(GettextCatalog.GetString("Continue"));
                    var cmdProjectOnly = new Command(GettextCatalog.GetString("Skip"));
                    var cmdCancel      = new Command(GettextCatalog.GetString("Cancel"));
                    question.Buttons.Add(cmdContinue);
                    question.Buttons.Add(cmdProjectOnly);
                    question.Buttons.Add(cmdCancel);
                    question.DefaultButton = 0;

                    Xwt.Toolkit.NativeEngine.Invoke(delegate {
                        var result = MessageDialog.AskQuestion(question);
                        if (result != cmdCancel)
                        {
                            if (result == cmdContinue)
                            {
                                foreach (var project in addProjects)
                                {
                                    if (question.GetOptionValue(project.Key))
                                    {
                                        servicesToAdd.Add(project.Value.GetConnectedServicesBinding()?.SupportedServices.FirstOrDefault(s => s.Id == service.Id));
                                    }
                                }
                            }
                            AddSelectedServices(service, servicesToAdd);
                        }
                    });
                }
                else
                {
                    AddSelectedServices(service, servicesToAdd);
                }
            }
        }
 public static Command AskQuestion(QuestionMessage message)
 {
     return(GenericAlert(RootWindow, message));
 }
Beispiel #3
0
 public static Command AskQuestion(WindowFrame window, QuestionMessage message)
 {
     return(GenericAlert(window, message));
 }
Beispiel #4
0
 public static Command AskQuestion(QuestionMessage message)
 {
     return(AskQuestion(RootWindow, message));
 }
Beispiel #5
0
		public MessageDialogs ()
		{
			Table table = new Table ();

			TextEntry txtPrimay = new TextEntry ();
			TextEntry txtSecondary = new TextEntry ();
			txtSecondary.MultiLine = true;
			ComboBox cmbType = new ComboBox ();
			cmbType.Items.Add ("Message");
			cmbType.Items.Add ("Question");
			cmbType.Items.Add ("Confirmation");
			cmbType.Items.Add ("Warning");
			cmbType.Items.Add ("Error");
			cmbType.SelectedIndex = 0;

			Button btnShowMessage = new Button ("Show Message");

			Label lblResult = new Label ();

			table.Add (new Label ("Primary Text:"), 0, 0);
			table.Add (txtPrimay, 1, 0, hexpand: true);
			table.Add (new Label ("Secondary Text:"), 0, 1);
			table.Add (txtSecondary, 1, 1, hexpand: true);
			table.Add (new Label ("Message Type:"), 0, 2);
			table.Add (cmbType, 1, 2, hexpand: true);

			table.Add (btnShowMessage, 1, 3, hexpand: true);
			table.Add (lblResult, 1, 4, hexpand: true);

			btnShowMessage.Clicked += (sender, e) => {

				switch (cmbType.SelectedText) {
					case "Message":
						MessageDialog.ShowMessage (this.ParentWindow, txtPrimay.Text, txtSecondary.Text);
						lblResult.Text = "Result: dialog closed";
						break;
					case "Question":
						var question = new QuestionMessage(txtPrimay.Text, txtSecondary.Text);
						question.Buttons.Add(new Command("Answer 1"));
						question.Buttons.Add(new Command("Answer 2"));
						question.DefaultButton = 1;
						question.AddOption ("option1", "Option 1", false);
						question.AddOption ("option2", "Option 2", true);
						var result = MessageDialog.AskQuestion (question);
						lblResult.Text = "Result: " + result.Id;
						if (question.GetOptionValue ("option1"))
							lblResult.Text += " + Option 1";
						if (question.GetOptionValue ("option2"))
							lblResult.Text += " + Option 2";
						break;
					case "Confirmation":
						var confirmation = new ConfirmationMessage (txtPrimay.Text, txtSecondary.Text, Command.Apply);
						confirmation.AddOption ("option1", "Option 1", false);
						confirmation.AddOption ("option2", "Option 2", true);
						confirmation.AllowApplyToAll = true;

						var success = MessageDialog.Confirm (confirmation);
						lblResult.Text = "Result: " + success;
						if (confirmation.GetOptionValue ("option1"))
							lblResult.Text += " + Option 1";
						if (confirmation.GetOptionValue ("option2"))
							lblResult.Text += " + Option 2";

						lblResult.Text += " + All: " + confirmation.AllowApplyToAll;
						break;
					case "Warning":
						MessageDialog.ShowWarning (this.ParentWindow, txtPrimay.Text, txtSecondary.Text);
						lblResult.Text = "Result: dialog closed";
						break;
					case "Error":
						MessageDialog.ShowError (this.ParentWindow, txtPrimay.Text, txtSecondary.Text);
						lblResult.Text = "Result: dialog closed";
						break;
				}
			};

			PackStart (table, true);
		}
Beispiel #6
0
 public static Command AskQuestion(QuestionMessage message)
 {
     return GenericAlert (RootWindow, message);
 }