Ejemplo n.º 1
0
        public static void ToastMessage(string message, Color color, string goPage)
        {
            Xamarin.Forms.Device.BeginInvokeOnMainThread(() =>
            {
                ToastConfig tc = new ToastConfig(message);
                tc.SetBackgroundColor(color);

                if (color == Color.Aquamarine)
                {
                    tc.SetMessageTextColor(Color.Black);
                    tc.SetPosition(ToastPosition.Bottom);
                }
                else
                {
                    tc.SetMessageTextColor(Color.White);
                    tc.SetPosition(ToastPosition.Bottom);
                }

               
                tc.SetDuration(TimeSpan.FromSeconds(5.0));


                tc.SetAction(x => x.SetText("Ir >").SetAction(() => App.gotopage(goPage)));
              

                UserDialogs.Instance.Toast(tc);
            });
        }
Ejemplo n.º 2
0
 public void ShowMessage(string message, bool error)
 {
     Xamarin.Forms.Device.BeginInvokeOnMainThread(() =>
     {
         try
         {
             var toastConfig = new ToastConfig(message);
             toastConfig.SetDuration(1500);
             if (error)
             {
                 toastConfig.SetBackgroundColor(Color.Red);
             }
             else
             {
                 toastConfig.SetBackgroundColor(Color.LimeGreen);
             }
             toastConfig.MessageTextColor = Color.White;
             toastConfig.SetPosition(ToastPosition.Bottom);
             UserDialogs.Instance.Toast(toastConfig);
         }
         catch (Exception e)
         {
             var toastConfig = new ToastConfig("ERROR " + e.Message);
             toastConfig.SetDuration(1000);
             toastConfig.SetBackgroundColor(Color.Red);
             toastConfig.MessageTextColor = Color.White;
             toastConfig.SetPosition(ToastPosition.Bottom);
             UserDialogs.Instance.Toast(toastConfig);
         }
     });
 }
Ejemplo n.º 3
0
        private async void BtnCancelarOrden_Clicked(object sender, EventArgs e)
        {
            await Task.Factory.StartNew(() => {
                var documents = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments);
                for (int i = 0; i <= 5; i++)
                {
                    var filename = Path.Combine(documents, i.ToString() + ".txt");
                    try
                    {
                        File.Delete(filename);
                    }
                    catch (FileNotFoundException)
                    {
                    }
                }
            });

            await Navigation.PopToRootAsync();

            await Task.Factory.StartNew(() => {
                var toastConfig = new ToastConfig("Orden Cancelada");
                toastConfig.SetDuration(2000);
                toastConfig.SetBackgroundColor(System.Drawing.Color.FromArgb(255, 52, 0));
                toastConfig.SetMessageTextColor(System.Drawing.Color.FromArgb(255, 255, 255));
                toastConfig.SetPosition(ToastPosition.Top);

                UserDialogs.Instance.Toast(toastConfig);
            });
        }
Ejemplo n.º 4
0
        public void ShowNotifaciton(ToastNotificationTypeEnum type, string message, int delay = 2000)
        {
            var config = new ToastConfig(message);

            config.SetPosition(ToastPosition.Bottom);
            config.SetDuration(delay);
            config.SetMessageTextColor(System.Drawing.Color.White);

            switch (type)
            {
            case ToastNotificationTypeEnum.Error:
                config.SetBackgroundColor(System.Drawing.Color.DarkRed);
                break;

            case ToastNotificationTypeEnum.Success:
                config.SetBackgroundColor(System.Drawing.Color.Green);
                break;

            case ToastNotificationTypeEnum.Info:
                config.SetBackgroundColor(System.Drawing.Color.Orange);
                break;

            case ToastNotificationTypeEnum.Warning:
                config.SetBackgroundColor(System.Drawing.Color.MediumVioletRed);
                break;
            }

            UserDialogs.Instance.Toast(config);
        }
Ejemplo n.º 5
0
        public void DisplayToastMessage(string message, int duration = 3000)
        {
            ToastConfig toast = new ToastConfig(message);

            toast.SetDuration(duration);
            toast.SetPosition(ToastPosition.Top);
            UserDialogs.Instance.Toast(toast);
        }
Ejemplo n.º 6
0
        /// <summary>
        /// Show the toast notification
        /// </summary>
        /// <param name="message">Message of notification</param>
        public void CallToolTip(string message)
        {
            var toastConfig = new ToastConfig(message);

            toastConfig.SetDuration(5000); // Five seconds
            toastConfig.SetPosition(ToastPosition.Bottom);
            toastConfig.SetBackgroundColor(System.Drawing.Color.FromArgb(47, 79, 79));
            UserDialogs.Instance.Toast(toastConfig);
        }
Ejemplo n.º 7
0
        public void ShowErrorToast(string message, int ts = 3000, ToastPosition position = ToastPosition.Bottom)
        {
            var toastConfig = new ToastConfig(message);

            toastConfig.SetPosition(position);
            toastConfig.SetDuration(ts);
            toastConfig.SetBackgroundColor(System.Drawing.Color.FromArgb(255, 0, 0));
            _userDialogs.Toast(toastConfig);
        }
Ejemplo n.º 8
0
        public static ToastConfig DisplayToast(Color color, string text)
        {
            var toastConfig = new ToastConfig(text);

            toastConfig.SetDuration(5000);
            toastConfig.SetPosition(ToastPosition.Top);
            toastConfig.SetBackgroundColor(color);
            return(toastConfig);
        }
Ejemplo n.º 9
0
        private async Task <T> TryCallApiAsync <T>(string apiUrl, object request = null) where T : BaseResponse, new()
        {
            var response = new T();

            try
            {
                UserDialogs.Instance.ShowLoading(title: "Завантаження...");
                var current = Connectivity.NetworkAccess;
                if (current != NetworkAccess.Internet)
                {
                    response.IsSuccess  = false;
                    response.ApiMessage = "Немає доступу до інтернету";
                }
                else
                {
                    var uri     = $"{httpClient.BaseAddress}{apiUrl}";
                    var content = new StringContent(JsonConvert.SerializeObject(request ?? new object()), Encoding.UTF8, "application/json");

                    HttpResponseMessage responseMessage = null;

                    responseMessage = await httpClient.PostAsync(uri, content);

                    var responseContext = await responseMessage.Content.ReadAsStringAsync();

                    response = JsonConvert.DeserializeObject <T>(responseContext);
                }
            }
            catch (Exception ex)
            {
                response = new T
                {
                    ApiMessage = $"Client side ERROR: {ex.Message}",
                    IsSuccess  = false
                };
            }
            finally
            {
                var config = new ToastConfig("");
                config.SetDuration(2000);
                config.SetPosition(ToastPosition.Top);
                UserDialogs.Instance.HideLoading();
                if (!response.IsSuccess)
                {
                    config.Message = response.ApiMessage;
                    UserDialogs.Instance.Toast(config);
                }
                if (!response.BaseIsSuccess)
                {
                    config.Message = response.BaseMessage;
                    UserDialogs.Instance.Toast(config);
                }
            }

            return(response);
        }
Ejemplo n.º 10
0
        public static void GreenToast(string mensagem)
        {
            ToastConfig toastConfig = new ToastConfig(mensagem);

            toastConfig.SetPosition(ToastPosition.Bottom);
            toastConfig.SetDuration(3000);
            toastConfig.SetBackgroundColor(Xamarin.Forms.Color.Green);
            toastConfig.SetIcon("ic_check_circle_white_18dp.png");

            UserDialogs.Instance.Toast(toastConfig);
        }
Ejemplo n.º 11
0
        private void ShowToast(string toastMsg)
        {
            var toastConfig = new ToastConfig(toastMsg);

            toastConfig.SetPosition(ToastPosition.Top);
            toastConfig.SetDuration(2000);
            toastConfig.SetBackgroundColor(System.Drawing.Color.FromArgb(12, 131, 193));

            Debug.WriteLine(toastMsg);
            _userDialogs.Toast(toastConfig);
        }
Ejemplo n.º 12
0
        private void ShowReceived(string message)
        {
            if (!String.IsNullOrWhiteSpace(message))
            {
                var toastConfig = new ToastConfig(message);
                toastConfig.SetPosition(ToastPosition.Bottom);
                toastConfig.SetDuration(NotificationMilliseconds);
                toastConfig.SetBackgroundColor(System.Drawing.Color.FromArgb(12, 131, 193));

                Debug.WriteLine(message);

                UserDialogs.Instance.Toast(toastConfig);
            }
        }
Ejemplo n.º 13
0
        async void AddToGrid(object sender, System.EventArgs e)
        {
            try
            {
                if (!(String.IsNullOrEmpty(SKUEntry.Text)) && !(String.IsNullOrEmpty(SKUEntry.Text)))
                {
                    clsWhsItem item = new clsWhsItem
                    {
                        ProductCode = SKUEntry.Text,
                        LoadQty     = Convert.ToInt32(QtyEntry.Text)
                    };

                    bool existItem = items.Any(check => check.ProductCode == item.ProductCode);

                    if (existItem == false)
                    {
                        items.Add(item);
                        itemsTest.Add(item);

                        dataGrid.ItemsSource = items;
                        dataGrid.ItemsSource = itemsTest;

                        SKUEntry.Text = String.Empty;
                        QtyEntry.Text = String.Empty;

                        var toastConfig = new ToastConfig("Added to the list");
                        toastConfig.SetDuration(3000);
                        toastConfig.SetBackgroundColor(System.Drawing.Color.FromArgb(0, 128, 0));
                        toastConfig.SetPosition(0);
                        UserDialogs.Instance.Toast(toastConfig);
                    }
                    else
                    {
                        await DisplayAlert("Duplicate", "Item added to list.", "OK");
                    }
                }
                else
                {
                    await DisplayAlert("Missing field", "Please enter all field.", "OK");
                }
            }
            catch (Exception ex)
            {
                await DisplayAlert("Error", ex.Message, "OK");
            }
        }
Ejemplo n.º 14
0
        void FinJuego()
        {
            juegoTerminado = true;
            for (int i = 0; i < 4; i++)
            {
                boxview[i].Color = Color.Gray;
            }
            var toastmsm = new ToastConfig("Perdiste");

            toastmsm.SetDuration(3000);
            toastmsm.SetBackgroundColor(System.Drawing.Color.Orange);
            toastmsm.SetMessageTextColor(System.Drawing.Color.White);
            toastmsm.SetPosition(ToastPosition.Bottom);
            UserDialogs.Instance.Toast(toastmsm);
            Empezar.Text      = "Intentar de nuevo";
            Empezar.IsVisible = true;
        }
Ejemplo n.º 15
0
        /// <summary>
        /// Shows the message.
        /// </summary>
        /// <param name="message">The message.</param>
        public void ShowMessage(string message)
        {
            try
            {
                var toastOptions = new ToastConfig(message);
                toastOptions.SetDuration(TimeSpan.FromSeconds(5));
                toastOptions.SetBackgroundColor(System.Drawing.Color.Red);
                toastOptions.SetPosition(ToastPosition.Bottom);
                toastOptions.SetMessageTextColor(System.Drawing.Color.White);

                UserDialogs.Instance.Toast(message, TimeSpan.FromSeconds(5));
            }
            catch (Exception ex)
            {
                Debug.WriteLine(ex.Message);
            }
        }
Ejemplo n.º 16
0
        //prompt notification when receive new job notification
        public static void NewJobNotification(ContentPage page)
        {
            try
            {
                pages = page;

                var toastConfig = new ToastConfig("New job available in the job list.");
                toastConfig.SetDuration(6000);
                toastConfig.SetPosition(ToastPosition.Top);
                toastConfig.SetBackgroundColor(System.Drawing.Color.FromArgb(12, 131, 193));
                UserDialogs.Instance.Toast(toastConfig);

                CreateToolBarItem(page);
            }
            catch
            {
                pages.DisplayAlert("Error", "Notification error", "OK");
            }
        }
Ejemplo n.º 17
0
        public static ToastConfig DisplayToastEnum(ToastType ttype, string text)
        {
            var toastConfig = new ToastConfig(text);

            toastConfig.SetDuration(5000);
            Color color = new Color();

            toastConfig.SetPosition(ToastPosition.Top);
            if (ttype == ToastType.Success)
            {
                color = Color.Green;
            }
            else if (ttype == ToastType.Failure)
            {
                color = Color.MediumVioletRed;
            }
            toastConfig.SetBackgroundColor(color);
            return(toastConfig);
        }
Ejemplo n.º 18
0
 public static void ShowToast(this Application application, string toast, Color foreColor,
                              Color backColor)
 {
     if (application == null)
     {
         throw new ArgumentNullException(nameof(application));
     }
     if (toast == null)
     {
         throw new ArgumentNullException(nameof(toast));
     }
     Device.BeginInvokeOnMainThread(() =>
     {
         var conf = new ToastConfig(toast);
         conf.SetDuration(1500);
         conf.SetPosition(ToastPosition.Top);
         conf.SetMessageTextColor(foreColor);
         conf.SetBackgroundColor(backColor);
         UserDialogs.Instance.Toast(conf);
     });
 }
Ejemplo n.º 19
0
 public void ShowMessage(string message, bool error)
 {
     Xamarin.Forms.Device.BeginInvokeOnMainThread(() =>
     {
         var toastConfig = new ToastConfig(message);
         toastConfig.SetDuration(1500);
         if (error)
         {
             toastConfig.SetBackgroundColor(System.Drawing.Color.Red);
         }
         else
         {
             toastConfig.SetBackgroundColor(System.Drawing.Color.LimeGreen);
         }
         toastConfig.MessageTextColor = System.Drawing.Color.White;
         toastConfig.SetPosition(ToastPosition.Bottom);
         Device.BeginInvokeOnMainThread(() =>
         {
             UserDialogs.Instance.Toast(toastConfig);
         });
     });
 }