private static void UpdateEnabledChanged(AlertDialog alertDialog, DialogButtonType dialogButtonType, bool isEnabled) { var button = alertDialog.GetButton((int)dialogButtonType); button.Enabled = isEnabled; }
/// <summary> /// Gets translation of button text. /// </summary> /// <returns>The translated buttontext.</returns> /// <param name="buttonType">Button type.</param> static string GetTranslatedButtonText(DialogButtonType buttonType) { string translationKey = ""; if (buttonType == DialogButtonType.no) { translationKey = "No"; } else if (buttonType == DialogButtonType.yes) { translationKey = "Yes"; } else if (buttonType == DialogButtonType.ok) { translationKey = "OK"; } else if (buttonType == DialogButtonType.cancel) { translationKey = "Cancel"; } var translation = LeanLocalization.GetTranslation(translationKey); if (translation == null) { return(translationKey); } return(LeanLocalization.GetTranslation(translationKey).Text); }
public bool OnSimpleDialogButtonClick(DialogButtonType buttonType, string fragmentTag, string extTagKey, string extTag) { switch (extTagKey) { case LogoutDialog: if (buttonType == DialogButtonType.Positive) { ProcessLogout(); } return(true); case NetworkFlowOverLimitationDialog: if (buttonType == DialogButtonType.Positive) { DataCache.INSTATNCE.PublicationManager.DownloadPublication(this, Int32.Parse(extTag), true); } return(true); case PublicationExtInfo.CANCELDOWNLOAD_CONFIRM_DIALOG_EXTRATAG: if (buttonType == DialogButtonType.Positive) { var extInfo = DataCache.INSTATNCE.PublicationManager.GetPublicationExtInfo(Int32.Parse(extTag)); if (extInfo.CancellationSource != null) { extInfo.CancellationSource.Cancel(); } } return(true); } return(false); }
/// <summary> /// Instantiates a dialog and passes a generated result /// </summary> /// <param name="dialogPrefab">Dialog prefab</param> /// <param name="buttons">button configuration type which is defined in DialogButtonType enum</param> /// <param name="title">Title text of the dialog</param> /// <param name="message">Description text of the dialog</param> /// <param name="variable">Object with additional variable</param> public static Dialog Open(GameObject dialogPrefab, DialogButtonType buttons, string title, string message, bool placeForNearInteraction, System.Object variable = null) { GameObject dialogGameObject = GameObject.Instantiate(dialogPrefab) as GameObject; if (placeForNearInteraction == true) { // For HoloLens 2, place the dialog at 45cm from the user for the near hand interactions. // Size is maintained by ConstantViewSize solver RadialView rv = dialogGameObject.GetComponent <RadialView>(); rv.MinDistance = 0.4f; rv.MaxDistance = 0.7f; } else { // For HoloLens 1 and other platforms, place the dialog for far interactions with gaze or pointers. // Size is maintained by ConstantViewSize solver RadialView rv = dialogGameObject.GetComponent <RadialView>(); rv.MinDistance = 1.5f; rv.MaxDistance = 2.0f; } Dialog dialog = dialogGameObject.GetComponent <Dialog>(); DialogResult result = new DialogResult { Buttons = buttons, Title = title, Message = message, Variable = variable }; dialog.Launch(result); return(dialog); }
private Button CreateDialogButton(DialogButtonType type) { Button button = new Button(); Binding textBinding = new Binding { Mode = BindingMode.OneWay, Source = this, Path = type == DialogButtonType.Primary ? new PropertyPath(nameof(PrimaryButtonText)) : new PropertyPath(nameof(SecondaryButtonText)), }; button.SetBinding(Button.ContentProperty, textBinding); Binding commandBinding = new Binding { Mode = BindingMode.OneWay, Source = this, Path = type == DialogButtonType.Primary ? new PropertyPath(nameof(PrimaryButtonCommand)) : new PropertyPath(nameof(SecondaryButtonCommand)) }; button.SetBinding(Button.CommandProperty, commandBinding); Binding commandParameterBinding = new Binding { Mode = BindingMode.OneWay, Source = this, Path = type == DialogButtonType.Primary ? new PropertyPath(nameof(PrimaryButtonCommandParameter)) : new PropertyPath(nameof(SecondaryButtonCommandParameter)) }; button.SetBinding(Button.CommandParameterProperty, commandParameterBinding); Binding isEnabledBinding = new Binding { Mode = BindingMode.OneWay, Source = this, Path = type == DialogButtonType.Primary ? new PropertyPath(nameof(IsPrimaryButtonEnabled)) : new PropertyPath(nameof(IsSecondaryButtonEnabled)) }; button.SetBinding(Button.IsEnabledProperty, isEnabledBinding); if (type == DialogButtonType.Primary) { button.Click += PrimaryButton_Click; } else if (type == DialogButtonType.Secondary) { button.Click += SecondaryButton_Click; } button.HorizontalAlignment = HorizontalAlignment.Stretch; button.VerticalAlignment = VerticalAlignment.Center; return(button); }
public MessageDialog(DialogButtonType buttons, string primaryLabel, string secondaryLabel, MessageType messageType) { InicializeComponent(); //TransientFor = MainClass.MainWindow; Buttons = buttons; PrimaryText = primaryLabel; SecondaryText = secondaryLabel; MessageType = messageType; }
public bool OnSimpleDialogButtonClick(DialogButtonType buttonType, string fragmentTag, string extTagKey, string extTag) { switch (buttonType) { case DialogButtonType.Negative: break; case DialogButtonType.Neutral: break; case DialogButtonType.Positive: HttpResponse taskresponse = new HttpResponse(); if (extTagKey == "StartTask") { //启动任务 taskresponse = IoCContainer.Instance.Resolve <IDeliveryService>().StartTask(new Common.Entity.StartTaskRequest { keyValue = extTag, UserName = GlobalAccess.Instance.UserCredential.Email }); } if (extTagKey == "EndTask") { //结束任务 taskresponse = IoCContainer.Instance.Resolve <IDeliveryService>().EndTask(new Common.Entity.EndTaskRequest { result = "", keyValue = extTag }); } if (taskresponse.IsSuccess) { var response = taskresponse.DeserializeObject <ServiceResponse>(); if (response.Success) { Toast.MakeText(Activity, response.Message, ToastLength.Short).Show(); bool originalyEmptyPublicationList = DataCache.INSTATNCE.PublicationManager.IsPublicationListEmpty(); //tvNoTitleMessage.Visibility = originalyEmptyPublicationList ? ViewStates.Visible : ViewStates.Gone; tvNoTitleMessage.Visibility = ViewStates.Gone; // Only when truely new create view, the wait dialog should be poped up. // Rotation of screen will not popup wait dialog. bool newCreated = false; GetPublicationListOnline(originalyEmptyPublicationList && newCreated); } else { //操作失败提示给用户 Toast.MakeText(Activity, response.Message, ToastLength.Short).Show(); } } return(true); default: break; } return(false); }
public MessageDialogUrl(DialogButtonType buttons, string primaryLabel, string secondaryLabel,string secondaryUrl, MessageType messageType) { InicializeComponent(); TransientFor = MainClass.MainWindow; Buttons = buttons; PrimaryText = primaryLabel; linkBtn.Label = secondaryLabel; linkBtn.LinkUrl = secondaryUrl; MessageType = messageType; }
public MessageDialogUrl(DialogButtonType buttons, string primaryLabel, string secondaryLabel, string secondaryUrl, MessageType messageType) { InicializeComponent(); TransientFor = MainClass.MainWindow; Buttons = buttons; PrimaryText = primaryLabel; linkBtn.Label = secondaryLabel; linkBtn.LinkUrl = secondaryUrl; MessageType = messageType; }
public MessageDialog(DialogButtonType buttons, string primaryLabel, string secondaryLabel, MessageType messageType,Gtk.Window parent) { InicializeComponent(); //if (parent == null) parent =MainClass.MainWindow; if (parent != null) TransientFor =parent; Buttons = buttons; PrimaryText = primaryLabel; SecondaryText = secondaryLabel; MessageType = messageType; }
public static DialogButton AddButton(this IDialog dialog, DialogButtonType type, Action action = null, Func <bool> canExecute = null) { if (dialog == null) { throw new ArgumentNullException(nameof(dialog)); } DialogButton button = DialogButton.Create(type); ProcessAddButton(dialog, button, action, canExecute); return(button); }
public bool OnSimpleDialogButtonClick(DialogButtonType buttonType, string fragmentTag, string extTagKey, string extTag) { if (extTagKey == ReminderPasswordSucceedDialog) { var loginActivity = Activity as ILoginActivity; if (loginActivity != null) { loginActivity.ReminderPasswordFragment_ReturnLogin(); } return(true); } return(false); }
public bool OnSimpleDialogButtonClick(DialogButtonType buttonType, string fragmentTag, string extTagKey, string extTag) { if (extTagKey == ChangePasswordSucceedDialog) { var currentLoginActivity = Activity as ILoginActivity; if (currentLoginActivity != null) { currentLoginActivity.LoginSucceed(); } return(true); } return(false); }
public MessageDialog(DialogButtonType buttons, string primaryLabel, string secondaryLabel, MessageType messageType, Gtk.Window parent) { InicializeComponent(); //if (parent == null) parent =MainClass.MainWindow; if (parent != null) { TransientFor = parent; } Buttons = buttons; PrimaryText = primaryLabel; SecondaryText = secondaryLabel; MessageType = messageType; }
public bool OnSimpleDialogButtonClick(DialogButtonType buttonType, string fragmentTag, string extTagKey, string extTag) { if (extTagKey == LogoutDialog) { if (buttonType == DialogButtonType.Positive) { Activity.SetResult(Result.Ok); ((ContentActivity)Activity).CloseContent(); } return(true); } return(false); }
/// <summary> /// Instantiates a dialog and passes a generated result /// </summary> /// <param Name="dialogPrefab"></param> /// <param Name="buttons"></param> /// <param Name="title"></param> /// <param Name="message"></param> /// <returns></returns> public static Dialog Open(GameObject dialogPrefab, DialogButtonType buttons, string title, string message) { GameObject dialogGameObject = GameObject.Instantiate(dialogPrefab) as GameObject; Dialog dialog = dialogGameObject.GetComponent <Dialog>(); DialogResult result = new DialogResult { Buttons = buttons, Title = title, Message = message }; dialog.Launch(result); return(dialog); }
/// <summary> /// Instantiates a slate from the default prefab at position and rotation /// </summary> private void InstantiateFromPrefab(string title, string message, DialogButtonType buttonType, bool isNearInteraction, Vector3?position = null, Quaternion?rotation = null) { GameObject prefab = (GameObject)AssetDatabase.LoadAssetAtPath(slatePrefabAssetPath, typeof(GameObject)); dialogComponent = Dialog.Open(prefab, buttonType, title, message, isNearInteraction); Assert.IsNotNull(dialogComponent); dialogGameObject = dialogComponent.gameObject; Assert.IsNotNull(dialogGameObject); if (dialogComponent != null) { dialogComponent.OnClosed += OnClosedDialogEvent; } dialogGameObject.transform.position = position != null ? (Vector3)position : Vector3.forward; dialogGameObject.transform.rotation = rotation != null ? (Quaternion)rotation : Quaternion.identity; }
public bool OnSimpleDialogButtonClick(DialogButtonType buttonType, string fragmentTag, string extTagKey, string extTag) { if (extTagKey == DeletePubWarningDialog) { if (buttonType == DialogButtonType.Positive) { var bookId = Int32.Parse(extTag); DataCache.INSTATNCE.PublicationManager.RemovePublication(bookId); organisePublicationsListAdaptor.DeletePub(bookId); // call api PublicationUtil.Instance.DeletePublicationByUser(bookId); } return(true); } return(false); }
public bool OnSimpleDialogButtonClick(DialogButtonType buttonType, string fragmentTag, string extTagKey, string extTag) { //switch (extTagKey) //{ // case NetworkFlowOverLimitationDialog: // if (buttonType == DialogButtonType.Positive) // { // DataCache.INSTATNCE.PublicationManager.DownloadPublication(this, Int32.Parse(extTag), true); // } // return true; // case PublicationExtInfo.CANCELDOWNLOAD_CONFIRM_DIALOG_EXTRATAG: // if (buttonType == DialogButtonType.Positive) // { // var extInfo = DataCache.INSTATNCE.PublicationManager.GetPublicationExtInfo(Int32.Parse(extTag)); // if (extInfo.CancellationSource != null) // { // extInfo.CancellationSource.Cancel(); // } // } // return true; // case InstallPublicationCompletedDialog: // if (buttonType == DialogButtonType.Positive) // { // CloseContent(); // } // return true; // case InstallOfficeAppDialog: // if (buttonType == DialogButtonType.Positive) // { // var intent = new Intent(Intent.ActionView); // intent.SetData(Android.Net.Uri.Parse("market://details?id=com.mobisystems.office")); // StartActivity(intent); // } // return true; //} return(false); }
/// <summary> /// Show the dialog box. /// </summary> /// <param name="dialogueBox">GameObject refrence.</param> /// <param name="buttons">Type of button confirm etc.</param> /// <param name="title">Title to display on dialog.</param> /// <param name="message">Message to display on dialog.</param> public static void OpenDialogue(GameObject dialogueBox, DialogButtonType buttons, string title, string message) { dialogueBox.SetActive(true); JMRDialogAbstractBase dialogue = dialogueBox.GetComponent <JMRDialogAbstractBase>(); if (dialogue) { DialogueBoxData dbData = new DialogueBoxData { Buttons = buttons, Title = title, Message = message }; dialogue.DisplayDialogue(dbData); } else { JMRLogHandler.LogError("Missing Dialogue Script"); } }
public void DialogButtonCreateTest([Values( DialogButtonType.Ok, DialogButtonType.Cancel, DialogButtonType.Yes, DialogButtonType.No, DialogButtonType.Custom)] DialogButtonType type) { var dialogButton = DialogButton.Create(type); Assert.NotNull(dialogButton); Assert.AreEqual(type, dialogButton.Type); if (type != DialogButtonType.Custom) { Assert.AreEqual(type.ToString().ToUpperInvariant(), dialogButton.Caption.ToUpperInvariant()); } Assert.AreEqual(type == DialogButtonType.Ok || type == DialogButtonType.Yes || type == DialogButtonType.Custom, dialogButton.IsDefault); Assert.AreEqual(type == DialogButtonType.Cancel, dialogButton.IsCancel); }
public void DialogViewModelExtensionAddButtonTest([Values( DialogButtonType.Ok, DialogButtonType.Cancel, DialogButtonType.Yes, DialogButtonType.No, DialogButtonType.Custom)] DialogButtonType type) { var vm = new MockDialogViewModel(); vm.AddButton(type); Assert.NotNull(vm.Buttons); var button = vm.Buttons.First(); Assert.NotNull(button); Assert.AreEqual(type, button.Type); Assert.Null(vm.SelectedButton); button.Command.Execute(null); Assert.AreEqual(button, vm.SelectedButton); }
/// <summary> /// This function is called to set the settings for the dialog and then open it. /// </summary> /// <param Name="buttons">Enum describing the number of buttons that will be created on the Dialog</param> /// <param Name="title">This string will appear at the top of the Dialog</param> /// <param Name="message">This string will appear in the body of the Dialog</param> /// <returns>IEnumerator used for Coroutine funtions in Unity</returns> protected IEnumerator LaunchDialog(DialogButtonType buttons, string title, string message) { isDialogLaunched = true; //Open Dialog by sending in prefab Dialog dialog = Dialog.Open(dialogPrefab.gameObject, buttons, title, message); if (dialog != null) { //listen for OnClosed Event dialog.OnClosed += OnClosed; } // Wait for dialog to close while (dialog.State < DialogState.InputReceived) { yield return(null); } //only let one dialog be created at a time isDialogLaunched = false; yield break; }
/// <summary> /// Display standard dialog with text info and one button. /// </summary> /// <param name="infoText">Text to diaopley in dialog.</param> /// <param name="buttonType">Button type to display.</param> public static void ShowInfo(string infoText, DialogButtonType buttonType) { ShowInfo(infoText, GetTranslatedButtonText(buttonType)); }
/// <summary> /// Initializes a new instance of the <see cref="DialogButton"/> class with content text. /// </summary> /// <param name="type"> /// The type of button. /// </param> /// <param name="content"> /// The content text to display on the button. /// </param> public DialogButton(DialogButtonType type, string content) { this.Type = type; this.Content = content; }
/// <summary> /// Initializes a new instance of the <see cref="DialogButton"/> class with content text and an invoke action. /// </summary> /// <param name="type"> /// The type of button. /// </param> /// <param name="content"> /// The content text to display on the button. /// </param> /// <param name="invokeAction"> /// The action to perform when the button is invoked. /// </param> public DialogButton(DialogButtonType type, string content, DialogButtonInvokedHandler invokeAction) { this.Type = type; this.Content = content; this.InvokeAction = invokeAction; }
public Button GetButton(DialogButtonType type) { return(base.GetButton((Int32)type)); }
private void SetButton(DialogButtonType type, String text, Action callback) { SetLayoutBottomPadding(0); base.SetButton((Int32)type, text, (s, e) => callback?.Invoke()); }
private void OnClosedDialogEvent(DialogResult obj) { dialogResult = obj.Result; }
protected ICancellableAlert ChangeButton (DialogButtonType type, string title, Func<EventHandler> callback = null) { Button button; if (dialogShown != null && (button = dialogShown.GetButton((int)type)) != null){ if (callback != null) button.Click += (s,e) => callback()(s,e); button.Text = title; button.Invalidate(); } else { funcButtonsMap [type]?.Invoke (builder, title, (s,e) => callback?.Invoke()(s,e)); } return this; }
/// <summary> /// Show standard dialog with text info and two buttons. /// </summary> /// <param name="questionText">text to diaopley in dialog.</param> /// <param name="button1Type">Cancel button type.</param> /// <param name="button2Type">Ok button type</param> /// <param name="OnButtonClickAction">Action to call when button pressed</param> public static void ShowQuesttion(string questionText, DialogButtonType button1Type, DialogButtonType button2Type, Action <bool> OnButtonClickAction) { ShowQuesttion(questionText, GetTranslatedButtonText(button1Type), GetTranslatedButtonText(button2Type), OnButtonClickAction); }
public Guid ShowDialog(string headerText, string text, DialogType type, bool showCancelButton, DialogButtonType? focusedButton) { Guid dialogHandle = Guid.NewGuid(); ItemsList buttons = new ItemsList(); switch (type) { case DialogType.OkDialog: buttons.Add(CreateButtonListItem(OK_BUTTON_TEXT, dialogHandle, DialogResult.Ok, focusedButton == DialogButtonType.Ok || !showCancelButton)); break; case DialogType.YesNoDialog: buttons.Add(CreateButtonListItem(YES_BUTTON_TEXT, dialogHandle, DialogResult.Yes, focusedButton == DialogButtonType.Yes)); buttons.Add(CreateButtonListItem(NO_BUTTON_TEXT, dialogHandle, DialogResult.No, focusedButton == DialogButtonType.No)); break; default: throw new NotImplementedException(string.Format("DialogManager: DialogType {0} is not implemented yet", type)); } if (showCancelButton) buttons.Add(CreateButtonListItem(CANCEL_BUTTON_TEXT, dialogHandle, DialogResult.Cancel, focusedButton == DialogButtonType.Cancel)); IScreenManager screenManager = ServiceRegistration.Get<IScreenManager>(); _dialogData = new GenericDialogData(headerText, text, buttons, dialogHandle); Guid? dialogInstanceId = screenManager.ShowDialog(GENERIC_DIALOG_SCREEN, OnDialogClosed); if (!dialogInstanceId.HasValue) throw new InvalidDataException("Generic dialog could not be shown"); _dialogData.DialogInstanceId = dialogInstanceId.Value; return dialogHandle; }
/// <summary>创建一个Dialog 一直yield返回直到Dialog响应</summary> public static IEnumerator LaunchDialog(this ZCore.View view, Dialog dialogPrefab, DialogButtonType buttons, string title, string message) { Dialog dialog = Dialog.Open(dialogPrefab.gameObject, buttons, title, message); while (dialog.State < DialogState.InputReceived) { yield return(null); } yield break; }
/// <summary> /// Checks to determine if all bits in a provided mask are set. /// </summary> /// <param name="a"><see cref="DialogButtonType"/> value.</param> /// <param name="b"><see cref="DialogButtonType"/> mask.</param> /// <returns> /// True if all of the bits in the specified mask are set in the current value. /// </returns> public static bool IsMaskSet(this DialogButtonType a, DialogButtonType b) { return((a & b) == b); }
public bool OnSimpleDialogButtonClick(DialogButtonType buttonType, string fragmentTag, string extTagKey, string extTag) { return(true); }