private void OnAction(RenderedAdaptiveCard sender, AdaptiveActionEventArgs e) { if (e.Action is AdaptiveOpenUrlAction openUrlAction) { Process.Start(openUrlAction.Url.AbsoluteUri); } else if (e.Action is AdaptiveShowCardAction showCardAction) { // Action.ShowCard can be rendered inline automatically, or in "popup" mode // If the Host Config is set to Popup mode, then the app needs to show it if (Renderer.HostConfig.Actions.ShowCard.ActionMode == ShowCardActionMode.Popup) { var dialog = new ShowCardWindow(showCardAction.Title, showCardAction, Resources); dialog.Owner = this; dialog.ShowDialog(); } } else if (e.Action is AdaptiveSubmitAction submitAction) { var inputs = sender.UserInputs.AsJson(); // Merge the Action.Submit Data property with the inputs inputs.Merge(submitAction.Data); MessageBox.Show(this, JsonConvert.SerializeObject(inputs, Formatting.Indented), "SubmitAction"); } }
public void InvokeOnAction(object sender, AdaptiveActionEventArgs args) { Device.BeginInvokeOnMainThread(() => { MessagingCenter.Send(sender as RenderedAdaptiveCard, "AdaptiveCardAction", args); }); }
private void HandleAdaptiveCardAction(RenderedAdaptiveCard renderdCard, AdaptiveActionEventArgs args) { Task.Factory.StartNew(async() => { try { if (args.Action is AdaptiveOpenUrlAction openUrlAction) { Process.Start(openUrlAction.Url.AbsoluteUri); } else if (args.Action is AdaptiveSubmitAction submitAction) { var inputs = renderdCard.UserInputs.AsJson(); var text = submitAction.Data is String data ? data : null; if (inputs.Count > 0) { //Merge the Action.Submit Data property with the inputs inputs.Merge(submitAction.Data); } object value = null; if (inputs.Count > 0) { value = inputs; } else if (text == null && submitAction.Data != null) { value = submitAction.Data; } await botService.SendMessageToBot(text, value); if (!string.IsNullOrWhiteSpace(text)) { AddMessage(listView, text, MessageType.OutgoingText); } } else { var text = args.Action.Title; await botService.SendMessageToBot(text); if (!string.IsNullOrWhiteSpace(text)) { AddMessage(listView, text, MessageType.OutgoingText); } } } catch (Exception) { } }); }
private void RenderedCard_OnAction(RenderedAdaptiveCard sender, AdaptiveActionEventArgs e) { if (e.Action is AdaptiveOpenUrlAction openUrlAction) { Process.Start(openUrlAction.Url.AbsoluteUri); } else if (e.Action is AdaptiveSubmitAction submitAction) { var inputs = sender.UserInputs.AsJson(); // Merge the Action.Submit Data property with the inputs inputs.Merge(submitAction.Data); MessageBox.Show(this, JsonConvert.SerializeObject(inputs, Formatting.Indented), "SubmitAction"); } }
private void OnAction(object sender, AdaptiveActionEventArgs e) { if (e.Action is AdaptiveOpenUrlAction openUrlAction) { Process.Start(openUrlAction.Url); } else if (e.Action is AdaptiveShowCardAction) { MessageBox.Show("Action.ShowCard is not alloed from within a sub-card"); } else if (e.Action is AdaptiveSubmitAction submitAction) { MessageBox.Show(this, submitAction.DataJson, "SubmitAction"); Close(); } }
private async void RenderResult_OnAction(RenderedAdaptiveCard sender, AdaptiveActionEventArgs e) { if (e.Action.ActionType == ActionType.OpenUrl) { _userActivity.ActivationUri = new Uri("adaptivecards://openLastPost"); _userActivity.VisualElements.DisplayText = "Windows AppConsult blog"; _userActivity.VisualElements.Content = AdaptiveCardBuilder.CreateAdaptiveCardFromJson(json); await _userActivity.SaveAsync(); _userActivitySession?.Dispose(); _userActivitySession = _userActivity.CreateSession(); var action = e.Action as AdaptiveOpenUrlAction; await Launcher.LaunchUriAsync(action.Url); } }
public string SerializeActionEventArgsToString(AdaptiveActionEventArgs args) { string answer = "Action invoked!"; answer += "\nType: " + args.Action.ActionType; if (args.Action is AdaptiveSubmitAction) { answer += "\nData: " + (args.Action as AdaptiveSubmitAction).DataJson.Stringify(); } else if (args.Action is AdaptiveOpenUrlAction) { answer += "\nUrl: " + (args.Action as AdaptiveOpenUrlAction).Url; } answer += "\nInputs: " + args.Inputs.AsJson(InputValueMode.RawString).Stringify(); return(answer); }
private void RenderedCard_OnAction(RenderedAdaptiveCard sender, AdaptiveActionEventArgs e) { if (e.Action is AdaptiveSubmitAction submitAction) { var viewModel = DataContext as MainViewModel; if (submitAction.Id == "Ok") { viewModel.ShowAdaptiveCard = false; return; } var inputs = sender.UserInputs.AsDictionary(); var notes = inputs["Notes"]; viewModel.UpdateNotes(notes); viewModel.ShowAdaptiveCard = false; sender.OnAction -= RenderedCard_OnAction; } }
private async void RenderResult_OnAction(RenderedAdaptiveCard sender, AdaptiveActionEventArgs e) { if (e.Action.Type == "Action.OpenUrl") { if (_desktopBridgeHelpers.IsRunningAsUwp()) { _userActivity.ActivationUri = new Uri("adaptivecards://openLastPost"); _userActivity.VisualElements.DisplayText = "Windows AppConsult blog"; _userActivity.VisualElements.Content = AdaptiveCardBuilder.CreateAdaptiveCardFromJson(json); await _userActivity.SaveAsync(); _userActivitySession?.Dispose(); _userActivitySession = _userActivity.CreateSession(); } var action = e.Action as AdaptiveOpenUrlAction; Process.Start(action.Url.ToString()); } }
private void OnAction(RenderedAdaptiveCard sender, AdaptiveActionEventArgs e) { if (e.Action is AdaptiveOpenUrlAction openUrlAction) { Process.Start(openUrlAction.Url); } else if (e.Action is AdaptiveShowCardAction showCardAction) { if (Renderer.HostConfig.Actions.ShowCard.ActionMode == ShowCardActionMode.Popup) { var dialog = new ShowCardWindow(showCardAction.Title, showCardAction, Resources); dialog.Owner = this; dialog.ShowDialog(); } } else if (e.Action is AdaptiveSubmitAction submitAction) { var inputs = sender.UserInputs.AsJson(); inputs.Merge(submitAction.Data); MessageBox.Show(this, JsonConvert.SerializeObject(inputs, Formatting.Indented), "SubmitAction"); } }