private void ShowDialog(MessageDialogInfo dialog) { var uiManager = Context.GetNativeModule <UIManagerModule>(); try { uiManager.AddUIBlock(new UIBlock(async() => { if (CoreApplication.GetCurrentView().CoreWindow == null) { // View has no CoreWindow, won't be able to display a dialog box dialog.ErrorCallback($"Alert failed: CoreApplicationView corresponding to RootViewHint {dialog.RootViewHint} has no CoreWindow"); return; } await dialog.MessageDialog.ShowAsync(); } ), dialog.RootViewHint); } catch (InvalidOperationException) { // RootViewHint is bogus, i.e. no Dispatcher thread was found dialog.ErrorCallback($"Alert failed: RootViewHint {dialog.RootViewHint} can't be mapped to a CoreApplicationView"); } }
public void OnResume() { _isInForeground = true; var pendingDialog = _pendingDialog; _pendingDialog = null; if (pendingDialog != null) { ShowDialog(pendingDialog); } }
public void RenderTest() { CommandManager target = new CommandManager(); // TODO: Initialize to an appropriate value OperateRecordManager operateRecordManager = new OperateRecordManager(); // TODO: Initialize to an appropriate value operateRecordManager.NpcId = 1; operateRecordManager.NpcKey = "npc_test"; operateRecordManager.SceneId = 1; MessageDialogInfo messageDialogInfo = new MessageDialogInfo(); messageDialogInfo.Comment = "test"; MessageCommand messageCommand = new MessageCommand(); messageCommand.PageIndex = 1; messageCommand.CommandIndex = 1; messageCommand.messageDialogInfo = messageDialogInfo; operateRecordManager.OperateList.Add(messageCommand); string expected = string.Empty; // TODO: Initialize to an appropriate value string actual; actual = target.Render(operateRecordManager); Assert.AreEqual(expected, actual); Assert.Inconclusive("Verify the correctness of this test method."); }
public void showAlert( JObject config, ICallback errorCallback, ICallback actionCallback) { var message = config.Value <string>("message") ?? ""; var messageDialog = new MessageDialog(message) { Title = config.Value <string>("title"), }; MessageDialogInfo dialogInfo = new MessageDialogInfo { MessageDialog = messageDialog, ErrorCallback = (string error) => errorCallback.Invoke(error) }; if (config.ContainsKey(DialogModuleHelper.RootViewHint)) { dialogInfo.RootViewHint = config.Value <int>(DialogModuleHelper.RootViewHint); } uint commandIndex = 0; if (config.ContainsKey(DialogModuleHelper.KeyButtonPositive)) { messageDialog.Commands.Add(new UICommand { Label = config.Value <string>(DialogModuleHelper.KeyButtonPositive), Id = DialogModuleHelper.KeyButtonPositiveValue, Invoked = target => OnInvoked(target, actionCallback), }); commandIndex++; } if (config.ContainsKey(DialogModuleHelper.KeyButtonNegative)) { messageDialog.Commands.Add(new UICommand { Label = config.Value <string>(DialogModuleHelper.KeyButtonNegative), Id = DialogModuleHelper.KeyButtonNegativeValue, Invoked = target => OnInvoked(target, actionCallback), }); // Use this command for Escape (we don't use the DialogModuleHelper.ActionDismissed since // it's hard to detect the condition messageDialog.CancelCommandIndex = commandIndex; commandIndex++; } DispatcherHelpers.RunOnDispatcher(() => { if (_isInForeground) { ShowDialog(dialogInfo); } else { _pendingDialog = dialogInfo; } }); }