Example #1
0
            void AlertSignalNameHandler(Page sender, AlertArguments arguments)
            {
                //Managing buttons logic behavior with Xamarin.Forms
                List <string> buttons = new List <string>();

                if (!string.IsNullOrEmpty(arguments.Accept))
                {
                    buttons.Add(arguments.Accept);
                }
                buttons.Add(arguments.Cancel);

                Device.BeginInvokeOnMainThread(async() => {
                    var messageBoxResult = await Electron.Dialog.ShowMessageBoxAsync(new ElectronNET.API.Entities.MessageBoxOptions(arguments.Message)
                    {
                        Title   = arguments.Title,
                        Buttons = buttons.ToArray(),
                        Type    = ElectronNET.API.Entities.MessageBoxType.none,
                        NoLink  = true
                    });

                    bool isOk = true;

                    //If buttons count equal 1, we only have a cancel button
                    //If we have more than 1 button but the Response index is the last button item, then it's a cancel button value
                    if (buttons.Count == 1 || buttons.Count > 1 && messageBoxResult.Response == buttons.Count - 1)
                    {
                        isOk = false;
                    }

                    arguments.SetResult(isOk);
                });
            }
Example #2
0
 public void OnAlertSignalResult(AlertArguments arguments, bool isOk)
 {
     arguments.SetResult(isOk);
 }