Example #1
0
        public static String GetEnumDesc(MessageResult e)
        {
            FieldInfo _enumInfo       = e.GetType().GetField(e.ToString());
            var       _enumAttributes = (DescriptionAttribute[])_enumInfo.
                                        GetCustomAttributes(typeof(DescriptionAttribute), false);

            if (_enumAttributes.Length > 0)
            {
                return(_enumAttributes[0].Description);
            }
            return(e.ToString());
        }
Example #2
0
    public Task<MessageResult> ShowDialog(string Title, string Message, int IconAttribute = Android.Resource.Attribute.AlertDialogIcon, bool SetCancelable = false, MessageResult PositiveButton = MessageResult.OK, MessageResult NegativeButton = MessageResult.NONE, MessageResult NeutralButton = MessageResult.NONE)
    {
        var tcs = new TaskCompletionSource<MessageResult>();

        var builder = new AlertDialog.Builder(mcontext);
        builder.SetIconAttribute(IconAttribute);
        builder.SetTitle(Title);
        builder.SetMessage(Message);
        builder.SetInverseBackgroundForced(false);
        builder.SetCancelable(SetCancelable);

        builder.SetPositiveButton((PositiveButton != MessageResult.NONE) ? PositiveButton.ToString() : string.Empty, (senderAlert, args) =>
        {
            tcs.SetResult(PositiveButton);
        });
        builder.SetNegativeButton((NegativeButton != MessageResult.NONE) ? NegativeButton.ToString() : string.Empty, delegate
        {
            tcs.SetResult(NegativeButton);
        });
        builder.SetNeutralButton((NeutralButton != MessageResult.NONE) ? NeutralButton.ToString() : string.Empty, delegate
        {
            tcs.SetResult(NeutralButton);
        });

        MainThread.BeginInvokeOnMainThread(() =>
        {
        });

        MainThread.BeginInvokeOnMainThread(() =>
        {
            builder.Show();
        });

        return tcs.Task;
    }
Example #3
0
        async void ShowMessageBox()
        {
            IMessageBoxService dialogService = ServiceContainer.GetService <IMessageBoxService>();
            var           buttons            = (MessageButton)Enum.Parse(typeof(MessageButton), SelectedMessageDialogButtons);
            MessageResult result             = await dialogService.ShowAsync(Message, Title, buttons);

            Output = result.ToString();
        }
Example #4
0
        private static async void Chat()
        {
            var server = new Server();
            var client = new Client();

            MessageResult result1 = await client.ConnectAsync(server);

            result1.ToString();             // SuccessMessageResult.ToString

            MessageResult result2 = await server.SendAsync("Hello from server!");

            result2.ToString();             // SuccessMessageResult.ToString or ErrorMessageResult.ToString

            Task <MessageResult> task    = client.SendAsync($"Hello from client {client.Id}!");
            MessageResult        result3 = await task;

            result3.ToString();             // ErrorMessageResult.ToString
        }
        public void ShowDialogPrompt(string Title, string Message,
                                     bool SetCancelable           = false, bool SetInverseBackgroundForced = false,
                                     MessageResult PositiveButton = MessageResult.OK,
                                     MessageResult NegativeButton = MessageResult.CANCEL,
                                     MessageResult NeutralButton  = MessageResult.YES)
        {
            var tcs = new TaskCompletionSource <MessageResult>();

            var builder = new AlertDialog.Builder(MainActivity.AppActivity);

            builder.SetIconAttribute(Android.Resource.Attribute.AlertDialogIcon);
            builder.SetTitle(Title);
            builder.SetMessage(Message);
            builder.SetInverseBackgroundForced(SetInverseBackgroundForced);
            builder.SetCancelable(SetCancelable);

            builder.SetPositiveButton((PositiveButton != MessageResult.NONE) ? PositiveButton.ToString() : string.Empty, (senderAlert, args) =>
            {
                tcs.SetResult(PositiveButton);
            });
            builder.SetNegativeButton((NegativeButton != MessageResult.NONE) ? NegativeButton.ToString() : string.Empty, delegate
            {
                tcs.SetResult(NegativeButton);
            });
            builder.SetNeutralButton((NeutralButton != MessageResult.NONE) ? NeutralButton.ToString() : string.Empty, delegate
            {
                tcs.SetResult(NeutralButton);
            });

            Xamarin.Forms.Device.BeginInvokeOnMainThread(() =>
            {
            });

            Xamarin.Forms.Device.BeginInvokeOnMainThread(() =>
            {
                builder.Show();
            });
        }
 protected virtual string GetButtonText(MessageResult button)
 {
     return button.ToString();
 }
 protected virtual string GetButtonText(MessageResult button)
 {
     return(button.ToString());
 }
 internal void Set(MessageResult result, Action <MessageResult> onClick)
 {
     this.result  = result;
     this.onClick = onClick;
     label.text   = result.ToString();
 }
Example #9
0
        // --------------------------------------------------
        // Signals
        // --------------------------------------------------

        public void OnAnyButtonDown(MessageResult result)
        {
            GD.print(result.ToString());
            _messageResult = result;
        }
Example #10
0
 protected virtual string GetButtonText(MessageResult button)
 {
     return(ApplicationSettings.MessagePresenterGetButtonText?.Invoke(button) ?? button.ToString());
 }