Exemple #1
0
        public static void DoToast(string toast, ToastType toastType, int duration = 2000)
        {
            var toastConfig = new ToastConfig(toast);

            toastConfig.SetDuration(duration);

            switch (toastType)
            {
            case ToastType.Green:
                toastConfig.SetBackgroundColor(System.Drawing.Color.FromArgb(12, 220, 25));
                break;

            case ToastType.Red:
                toastConfig.SetBackgroundColor(System.Drawing.Color.FromArgb(220, 12, 25));
                break;

            case ToastType.Yellow:
                toastConfig.SetBackgroundColor(System.Drawing.Color.FromArgb(193, 193, 25));
                break;

            default:
                toastConfig.SetBackgroundColor(System.Drawing.Color.FromArgb(12, 131, 193));
                break;
            }

            Device.BeginInvokeOnMainThread(() =>
            {
                UserDialogs.Instance.Toast(toastConfig);
            });
        }
        public static void ShowToast(string message, DialogType type)
        {
            var toastConfig = new ToastConfig(message);

            toastConfig.SetDuration(3000);
            switch (type)
            {
            case DialogType.Success:
                toastConfig.SetBackgroundColor(Color.Green);
                break;

            case DialogType.Information:
                toastConfig.SetBackgroundColor(Color.Blue);
                break;

            case DialogType.Warning:
                toastConfig.SetBackgroundColor(Color.LightBlue);
                break;

            case DialogType.Error:
                toastConfig.SetBackgroundColor(Color.Red);
                break;

            default:
                break;
            }

            toastConfig.SetMessageTextColor(Color.White);

            UserDialogs.Instance.Toast(toastConfig);
        }
Exemple #3
0
        public void ShowToast(ToastConfig config, ToastModes mode = ToastModes.Info)
        {
            switch (mode)
            {
            case ToastModes.Error:
                config.SetBackgroundColor(Color.Red);
                config.SetMessageTextColor(Color.White);
                //config.SetIcon(AppImages.Error);
                //config.Position = ToastPosition.Top;
                break;

            case ToastModes.Warning:
                config.SetBackgroundColor(Color.Yellow);
                config.SetMessageTextColor(Color.Black);
                //config.SetIcon(AppImages.Warning);
                //config.Position = ToastPosition.Top;
                break;


            case ToastModes.Info:
                config.SetBackgroundColor(Color.LightGray);
                config.SetMessageTextColor(Color.Black);
                //config.SetIcon(AppImages.Info);
                break;
            }
            UserDialogs.Instance.Toast(config);
        }
Exemple #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);
        }
 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);
         }
     });
 }
Exemple #6
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);
            });
        }
Exemple #7
0
        private async void Send()
        {
            try
            {
                var values = new FormUrlEncodedContent(new[]
                {
                    new KeyValuePair <string, string>("conversation_id", "10"),
                    new KeyValuePair <string, string>("api_key", "59423"),
                    new KeyValuePair <string, string>("message", outGoingText)
                });

                var client = new HttpClient();

                var response = await client.PostAsync("http://dev.foodforus.cloud/public/api/v1/createMessage", values);

                var respond = await response.Content.ReadAsStringAsync();

                var toastConfig = new ToastConfig("Message Sent");
                toastConfig.SetDuration(3000);
                toastConfig.SetBackgroundColor(System.Drawing.Color.FromArgb(12, 131, 193));

                UserDialogs.Instance.Toast(toastConfig);
                OutGoingText = String.Empty;
                Debug.WriteLine(respond + "?ioooooooooooooooooooooooooooooooooooooooooo");
            }
            catch (Exception ex)
            {
                Debug.WriteLine("Hello", ex);
            }
        }
 /// <summary>
 /// Deals the with the exception async.
 /// </summary>
 /// <returns>The with exception async.</returns>
 /// <param name="ex">Ex.</param>
 async Task DealWithExceptionAsync(Exception ex)
 {
     if (ex.GetType() == typeof(RequestException))
     {
         var toastConfig = new ToastConfig(ex.Message);
         toastConfig.Duration = TimeSpan.FromSeconds(5);
         toastConfig.SetBackgroundColor(System.Drawing.Color.OrangeRed);
         UserDialogs.Instance.Toast(toastConfig);
     }
     else if (ex.GetType() == typeof(NotConnectedException))
     {
         var toastConfig = new ToastConfig(ex.Message);
         toastConfig.Duration = TimeSpan.FromSeconds(5);
         toastConfig.SetBackgroundColor(System.Drawing.Color.OrangeRed);
         UserDialogs.Instance.Toast(toastConfig);
     }
     else
     if (ex.InnerException?.GetType() == typeof(WebException))
     {
         await UserDialogs.Instance.AlertAsync("We have an unrecoverable Error.", "Oops!", "Ok");
     }
     else
     {
         await UserDialogs.Instance.AlertAsync("We have an unrecoverable Error.", "Oops!", "Ok");
     }
 }
Exemple #9
0
        /// <summary>
        /// Invoked when the Log In button is clicked.
        /// </summary>
        /// <param name="obj">The Object</param>
        private async void LoginClicked(object obj)
        {
            var current = Connectivity.NetworkAccess;

            if (current == NetworkAccess.Internet)
            {
                var toastConfig = new ToastConfig("Please wait...");
                toastConfig.SetDuration(3000);
                toastConfig.SetBackgroundColor(System.Drawing.Color.FromArgb(12, 131, 193));
                if (!loading)
                {
                    loading = true;
                    UserDialogs.Instance.Toast(toastConfig);
                    checkCreds();
                }
                else
                {
                    UserDialogs.Instance.Toast(toastConfig);
                }
            }
            else
            {
                var toastConfig = new ToastConfig("Please check your internet connection!");
                toastConfig.SetDuration(3000);
                toastConfig.SetBackgroundColor(System.Drawing.Color.FromArgb(242, 76, 101));
                UserDialogs.Instance.Toast(toastConfig);
            }
        }
Exemple #10
0
        private void OnPropertyChanged()
        {
            //Si l'application est occupée on affiche un message de chargement
            if (_isBusy == true)
            {
                ToastConfig toastConfig = null;
                switch (Configuration.currentLanguage)
                {
                case CR_TTLangue.French_Canada:
                {
                    toastConfig = new ToastConfig("Chargement...");
                    break;
                }

                case CR_TTLangue.English:
                {
                    toastConfig = new ToastConfig("Loading...");
                    break;
                }
                }

                toastConfig.SetDuration(500);
                toastConfig.SetBackgroundColor(System.Drawing.Color.FromArgb(12, 131, 193));
                UserDialogs.Instance.Toast(toastConfig);
            }
        }
        async Task LookUpPatient(string nfcText)
        {
            var toastConfig = new ToastConfig("Tag gescand");

            toastConfig.SetDuration(1500);
            toastConfig.SetBackgroundColor(System.Drawing.Color.Green);
            toastConfig.SetMessageTextColor(System.Drawing.Color.White);

            UserDialogs.Instance.Toast(toastConfig);
            try
            {
                var foundPatient = await patientService.GetPatient(nfcText);

                allParameters.Add("patient", foundPatient);

                await _navigationService.NavigateAsync("NfcReadPatientTagResultPage", allParameters);
            }
            catch (ArgumentOutOfRangeException ex)
            {
                toastConfig = new ToastConfig("Er is iets misgegaan. Mogelijk is dit geen geldige tag.");
                toastConfig.SetDuration(5000);
                toastConfig.SetBackgroundColor(System.Drawing.Color.Firebrick);
                toastConfig.SetMessageTextColor(System.Drawing.Color.White);

                UserDialogs.Instance.Toast(toastConfig);

                Console.WriteLine(ex.Message);
            }
        }
Exemple #12
0
        public static void Success(string mensagem)
        {
            ToastConfig toastConfig = new ToastConfig(mensagem);

            toastConfig.SetBackgroundColor(Color.FromArgb(92, 184, 92));
            UserDialogs.Instance.Toast(toastConfig);
        }
Exemple #13
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);
            });
        }
        private async void RecuperaInfo_Clicked(object sender, EventArgs e)
        {
            //var result = await DisplayAlert("Confirmación", "¿Estás seguro que quieres contectar?", "Sí", "No");
            var dialogo = await UserDialogs.Instance.LoginAsync(new LoginConfig
            {
                Message             = "Introduce tu nombre de usuario y contraseña",
                OkText              = "Conecta",
                CancelText          = "Cancela",
                LoginPlaceholder    = "Nombre usuario",
                PasswordPlaceholder = "Contraseña"
            }, null);

            if (dialogo.Ok && dialogo.LoginText == "admin" && dialogo.Password == "aaaa")
            {
                conexInfo.Text = await coms.Enviar(0, 0, 0);

                infoMeteo.Text = coms.informacion;

                manecilla.AnchorY = 0.9;
                //manecilla.Rotation = coms.dirvent;
                bool x = await manecilla.RotateTo(coms.dirvent, 2000, Easing.BounceOut);
            }
            else
            {
                var toastConf = new ToastConfig("Usuario y/o contraseña incorrecta");
                toastConf.SetDuration(3000);
                toastConf.SetBackgroundColor(System.Drawing.Color.FromArgb(12, 131, 193));
                UserDialogs.Instance.Toast(toastConf);
            }
        }
Exemple #15
0
        private async void Button_OnClickedAsync(object sender, EventArgs e)
        {
            try
            {
                var values = new FormUrlEncodedContent(new[]
                {
                    new KeyValuePair <string, string>("conversation_id", ConversationID),
                    new KeyValuePair <string, string>("api_key", _apiKey),
                    new KeyValuePair <string, string>("message", Outgo.Text)
                });

                var client = new HttpClient();

                var response = await client.PostAsync("http://dev.foodforus.cloud/public/api/v1/createMessage", values);

                var respond = await response.Content.ReadAsStringAsync();

                var toastConfig = new ToastConfig("Message Sent");
                toastConfig.SetDuration(3000);
                toastConfig.SetBackgroundColor(System.Drawing.Color.FromArgb(12, 131, 193));

                UserDialogs.Instance.Toast(toastConfig);
                Outgo.Text = String.Empty;

                var allProducts = await data.GetChatlistmessage(PostId);

                _transactions          = new ObservableCollection <ChatModel>(allProducts);
                Listmesage.ItemsSource = _transactions;
                Debug.WriteLine(respond + "?ioooooooooooooooooooooooooooooooooooooooooo");
            }
            catch (Exception ex)
            {
                Debug.WriteLine("Hello", ex);
            }
        }
Exemple #16
0
        public static void ShowToastMessage(ToastMessageType type, string message)
        {
            var icon = string.Empty;

            System.Drawing.Color color = System.Drawing.Color.FromArgb(0, 188, 212);

            switch (type)
            {
            case ToastMessageType.Success:
                icon = "ic_check_white_24dp.png";
                break;

            case ToastMessageType.Error:
                icon  = "ic_error.png";
                color = System.Drawing.Color.Red;
                break;
            }

            var toastConfig = new ToastConfig(message);

            toastConfig.SetDuration(2000);
            toastConfig.SetBackgroundColor(color);
            toastConfig.SetIcon(icon);
            UserDialogs.Instance.Toast(toastConfig);
        }
Exemple #17
0
        public static void Info(string mensagem)
        {
            ToastConfig toastConfig = new ToastConfig(mensagem);

            toastConfig.SetBackgroundColor(Color.FromArgb(33, 150, 243));
            UserDialogs.Instance.Toast(toastConfig);
        }
Exemple #18
0
        private async void checkEmail()
        {
            try
            {
                var httpClient     = new HttpClient();
                var recentChatPage = new Views.Chat.RecentChatPage();
                var payload        = "{\"email\": \"" + this.Email + "\"" +
                                     "}";
                var                 url    = new Uri(App.BaseApiUrl + "/users/search");
                HttpContent         c      = new StringContent(payload, Encoding.UTF8, "application/json");
                HttpResponseMessage result = await httpClient.PostAsync(url, c);

                var users = JsonConvert.DeserializeObject <List <RestUserModel> >(result.Content.ReadAsStringAsync().Result);
                if (users.Count == 1)
                {
                    addChat(users[0].Id.ToString());
                    await Application.Current.MainPage.Navigation.PopAsync();
                }
                else
                {
                    var toastConfig = new ToastConfig("Email is invalid!");
                    toastConfig.SetDuration(3000);
                    toastConfig.SetBackgroundColor(System.Drawing.Color.FromArgb(242, 76, 101));
                    UserDialogs.Instance.Toast(toastConfig);
                }
            }
            catch (Exception e)
            {
                System.Diagnostics.Debug.WriteLine(e.Message);
            }
        }
Exemple #19
0
        public VoiceRecognitionViewModel(INavigationService navigationService) : base(navigationService)
        {
            StartRecordingCommand = new DelegateCommand(StartButtonClicked);
            ResetMetricCommand    = new DelegateCommand(ResetMetric);
            FinishMetricCommand   = new DelegateCommand(FinishMetric);
            _navigationService    = navigationService;
            _metricService        = new MetricService();
            metrics = new List <string>();

            DateTime now = DateTime.Now;

            try
            {
                _speechRecognitionInstance = DependencyService.Get <ISpeechToText>();
            }
            catch (Exception ex)
            {
                var toastConfig = new ToastConfig("Er is iets mis gegaan bij het opnemen. Neem contact op wanneer dit blijft gebeuren");
                toastConfig.SetDuration(5000);
                toastConfig.SetBackgroundColor(System.Drawing.Color.Firebrick);

                UserDialogs.Instance.Toast(toastConfig);
            }

            MessagingCenter.Subscribe <ISpeechToText, string>(this, "STT", (sender, args) =>
            {
                SpeechToTextFinalResultReceived(args);
            });

            MessagingCenter.Subscribe <IMessageSender, string>(this, "STT", (sender, args) =>
            {
                SpeechToTextFinalResultReceived(args);
            });
        }
Exemple #20
0
        public static void Error(string mensagem)
        {
            ToastConfig toastConfig = new ToastConfig(mensagem);

            toastConfig.SetBackgroundColor(Color.FromArgb(255, 115, 115));
            UserDialogs.Instance.Toast(toastConfig);
        }
Exemple #21
0
        public void Toast(string Message, System.Drawing.Color color)
        {
            var toastConfig = new ToastConfig(Message);

            toastConfig.SetDuration(SharedConfig.COMMON_TOAST_DURATION);
            toastConfig.SetBackgroundColor(color);
            _userDialogs.Toast(toastConfig);
        }
Exemple #22
0
        public void ShowToast(string text, ToastType toastType = ToastType.NORMAL, int duration = 3000)
        {
            var toastConfig = new ToastConfig(text);

            toastConfig.SetDuration(duration);
            switch (toastType)
            {
            case ToastType.SUCCESS:
                toastConfig.SetBackgroundColor(System.Drawing.Color.FromArgb(75, 181, 67));
                break;

            case ToastType.ERROR:
                toastConfig.SetBackgroundColor(System.Drawing.Color.FromArgb(255, 0, 51));
                break;
            }
            UserDialogs.Instance.Toast(toastConfig);
        }
        public void ShowToast(string message, Color color)
        {
            var toastConfig = new ToastConfig(message);

            toastConfig.SetDuration(5000);
            toastConfig.SetBackgroundColor(color);
            UserDialogs.Instance.Toast(toastConfig);
        }
Exemple #24
0
        public void ShowToast(string message)
        {
            var toastConfig = new ToastConfig(message);

            toastConfig.SetDuration(3000);
            toastConfig.SetBackgroundColor(System.Drawing.Color.FromArgb(12, 131, 193));
            _userDialogs.Toast(toastConfig);
        }
Exemple #25
0
        public static void ToastMessage(string Message)
        {
            ToastConfig toast = new ToastConfig(Message);

            toast.SetDuration(3000);
            toast.SetBackgroundColor(System.Drawing.Color.DimGray);
            UserDialogs.Instance.Toast(toast);
        }
        public void DisplayToast(string message)
        {
            var toastConfig = new ToastConfig(message);

            toastConfig.SetDuration(2000);
            toastConfig.Position = 0;
            toastConfig.SetMessageTextColor(System.Drawing.Color.FromArgb(0, 0, 0));
            if (message == "Success")
            {
                toastConfig.SetBackgroundColor(System.Drawing.Color.FromArgb(0, 128, 0));
            }
            else
            {
                toastConfig.SetBackgroundColor(System.Drawing.Color.FromArgb(255, 0, 0));
            }
            UserDialogs.Instance.Toast(toastConfig);
        }
Exemple #27
0
        public static void featureComingSoon()
        {
            var toastConfig = new ToastConfig("Feature will be added soon!");

            toastConfig.SetDuration(2000);
            toastConfig.SetBackgroundColor(System.Drawing.Color.FromArgb(242, 76, 101));
            UserDialogs.Instance.Toast(toastConfig);
        }
Exemple #28
0
        public static void SnackbarMessage(string message)
        {
            var toastConfig = new ToastConfig(message);

            toastConfig.SetDuration(3000);
            toastConfig.SetBackgroundColor(System.Drawing.Color.FromArgb(113, 191, 68));
            UserDialogs.Instance.Toast(toastConfig);
        }
Exemple #29
0
        public void displayToast(string message)
        {
            var toastConfig = new ToastConfig(message);

            toastConfig.SetDuration(2000);
            toastConfig.Position = 0;
            toastConfig.SetMessageTextColor(System.Drawing.Color.FromArgb(0, 0, 0));
            if (message == "New job added to list")
            {
                toastConfig.SetBackgroundColor(System.Drawing.Color.FromArgb(0, 128, 0));
            }
            else if (message == "Job already exist in list")
            {
                toastConfig.SetBackgroundColor(System.Drawing.Color.FromArgb(255, 0, 0));
            }
            UserDialogs.Instance.Toast(toastConfig);
        }
Exemple #30
0
        private static void Toast()
        {
            ToastConfig toastConfig = new ToastConfig("Toast");

            toastConfig.SetDuration(3000);
            toastConfig.SetBackgroundColor(Color.DimGray);

            UserDialogs.Instance.Toast(toastConfig);
        }