/// <exception cref="Exception">Cannot show dialog on a non-visible page</exception> public async Task ShowDialog(IDialogOptions i_DialogOptions) { if (ViewStatus != VisualStatus.Visible) { throw new Exception("Cannot show dialog on a non-visible page"); } await m_Page.DisplayAlert(i_DialogOptions.Title, i_DialogOptions.Message, "OK"); i_DialogOptions.Result = true; }
private List <TextInfo> CreateTextInfos(IDialogOptions options) { var Result = new List <TextInfo>(); for (var i = 0; i < options.Count; i++) { var Option = options[i]; Result.Add(new TextInfo(Option.Text, Option.ID.ToString())); } return(Result); }
public async Task ShowDialog(IDialogOptions dialogOptions) { if (ViewStatus == VisualStatus.Visible) { await _page.DisplayAlert(dialogOptions.Title, dialogOptions.Message, "OK"); dialogOptions.Result = true; } else { throw new Exception("You can not call ShowDialog on a non-visible page"); } }
public async Task ShowDialog(IDialogOptions dialogOptions) { var container = GetNavigationContainer(); container.ViewStatus = VisualStatus.Hidden; await container.ShowDialog(dialogOptions); Assert.Equal(false, dialogOptions.Result); container.ViewStatus = VisualStatus.Visible; await container.ShowDialog(dialogOptions); Assert.Equal(true, dialogOptions.Result); }
public async Task ShowDialog(IDialogOptions dialogOptions) { try { if (ViewStatus == VisualStatus.Visible) { await _page.DisplayAlert(dialogOptions.Title, dialogOptions.Message, "OK"); dialogOptions.Result = true; } else { dialogOptions.Result = false; } } catch (Exception ex) { Debug.WriteLine(ex.Message); } }
public async Task ShowDialog(IDialogOptions dialogOptions) { if (ViewStatus == VisualStatus.Visible) { if (string.IsNullOrEmpty(dialogOptions.CancelButtonText)) { await _page.DisplayAlert(dialogOptions.Title, dialogOptions.Message, string.IsNullOrEmpty(dialogOptions.OkButtonText)? "OK" : dialogOptions.OkButtonText); dialogOptions.Result = true; } else { dialogOptions.Result = await _page.DisplayAlert(dialogOptions.Title, dialogOptions.Message, string.IsNullOrEmpty(dialogOptions.OkButtonText)? "OK" : dialogOptions.OkButtonText, dialogOptions.CancelButtonText); } } else { throw new Exception("You can not call ShowDialog on a non-visible page"); } }
public async Task <DialogResult> Begin(TurnContext context, object state, IDialogOptions options) { BotAssert.ContextNotNull(context); if (state == null) { throw new ArgumentNullException(nameof(state)); } if (options == null) { throw new ArgumentNullException(nameof(options)); } // Create empty dialog set and ourselves to it var dialogs = new DialogSet(); dialogs.Add("control", (IDialog)this); // Start the control var cdc = dialogs.CreateContext(context, state); await cdc.Begin("control", options.ApplyDefaults(_defaultOptions)); return(cdc.DialogResult); }
/// <summary> /// Shows the dialog menu for the given dialog options. /// </summary> public void Open(IDialogOptions options) { if (options == null || options.Count == 0) { Close(); return; } Options = options; SelectedOptionIndex = -1; LastSelectedOption = BaseOption.None; State = DialogMenuState.Opening; currentY = -200; Visible = true; Enabled = true; var TextInfos = CreateTextInfos(options); Lines.Set(TextInfos, TextDuration.Persistent, new Vector2(Game.VIRTUAL_WIDTH / 2, 0)); var FirstOptionLine = Lines.Lines[0]; var LastOptionLine = Lines.Lines[Lines.Lines.Count - 1]; Height = (int)(LastOptionLine.Position.Y - FirstOptionLine.Position.Y + LastOptionLine.Hitbox.Height + Game.SCREEN_PADDING); // shift the options eventually Lines.SetPosition(new Vector2(Game.VIRTUAL_WIDTH / 2, Game.VIRTUAL_HEIGHT - Height + FirstOptionLine.Origin.Y)); for (int i = 0; i < Lines.Lines.Count; i++) { var CurrentHitbox = Lines.Lines[i].Hitbox; Lines.Lines[i] = Lines.Lines[i].ChangeHitbox(new Rectangle(0, CurrentHitbox.Y, Width, CurrentHitbox.Height)); } }
/// <summary> /// Creates a new Control instance. /// </summary> public Control(IDialogOptions defaultOptions = null) { _defaultOptions = defaultOptions; }