コード例 #1
0
        private void LectureInfos()
        {
            try
            {
                string fileName             = PrefsApp.fileUserPref;
                string data                 = DependencyService.Get <Class.IFileReadWrite>().ReadData(fileName);
                var    jsonObj              = Newtonsoft.Json.JsonConvert.DeserializeObject <JObject>(data);
                UserInfosObjectStruct infos = (UserInfosObjectStruct)Newtonsoft.Json.JsonConvert.DeserializeObject(jsonObj.ToString(), typeof(UserInfosObjectStruct));
                if (infos.Recorded == "true")
                {
                    prenom.Text = infos.Prenom;
                    nom.Text    = infos.Nom;
                    mail.Text   = infos.Mail;
                    gsm.Text    = infos.Gsm;

                    dateNaissance.Date = ToolsLocal.ConvertDateStringToDate(infos.DateNaissance);
                    nomContact.Text    = infos.NomContact;
                    prenomContact.Text = infos.PrenomContact;
                    gsmContact.Text    = infos.GsmContact;
                    mailContact.Text   = infos.MailContact;

                    heureMatin.Time = ToolsLocal.ConvertTimeStringToTime(infos.HeureMatin);
                    heureMidi.Time  = ToolsLocal.ConvertTimeStringToTime(infos.HeureMidi);
                    heureSoir.Time  = ToolsLocal.ConvertTimeStringToTime(infos.HeureSoir);
                }
            }
            catch (Exception err)
            {
                Console.WriteLine("Utlisateur non enregistré. ou erreur:" + err.Message.ToString());
            }
        }
コード例 #2
0
        private async Task Bp_delete_ClickedAsync(object sender, EventArgs e)
        {
            Boolean answer = await DisplayAlert("Question?", "êtes-vous certain de vouloir effacer cet utilisateur?", "Oui", "Non");

            if (answer == true)
            {
                string fileName = PrefsApp.fileUserPref;
                UserInfosObjectStruct UserInfos = new UserInfosObjectStruct
                {
                    Recorded      = "",
                    Prenom        = "",
                    Nom           = "",
                    Mail          = "",
                    Gsm           = "",
                    DateNaissance = "",
                    NomContact    = "",
                    PrenomContact = "",
                    GsmContact    = "",
                    MailContact   = "",
                    HeureMatin    = "",
                    HeureMidi     = "",
                    HeureSoir     = ""
                };

                string json = JsonConvert.SerializeObject(UserInfos);
                DependencyService.Get <Class.IFileReadWrite>().WriteData(fileName, json);
                await DisplayAlert("Info", "Utilisateur effacé.: ", "ok");

                ResetInfos();
            }
        }
コード例 #3
0
        public UserInfosObjectStruct FindInfosUser()
        {
            string fileName = PrefsApp.fileUserPref;

            string data    = DependencyService.Get <Class.IFileReadWrite>().ReadData(fileName);
            var    jsonObj = Newtonsoft.Json.JsonConvert.DeserializeObject <JObject>(data);

            UserInfosObjectStruct infos = (UserInfosObjectStruct)Newtonsoft.Json.JsonConvert.DeserializeObject(jsonObj.ToString(), typeof(UserInfosObjectStruct));


            return(infos);
        }
コード例 #4
0
        public Boolean TestIfRecorded()
        {
            Boolean retour   = false;
            string  fileName = PrefsApp.fileUserPref;


            Boolean IsFileConfigExist = DependencyService.Get <Class.IFileReadWrite>().IsFileExiste(fileName);

            if (IsFileConfigExist == true)
            {
                string data    = DependencyService.Get <Class.IFileReadWrite>().ReadData(fileName);
                var    jsonObj = Newtonsoft.Json.JsonConvert.DeserializeObject <JObject>(data);

                UserInfosObjectStruct infos = (UserInfosObjectStruct)Newtonsoft.Json.JsonConvert.DeserializeObject(jsonObj.ToString(), typeof(UserInfosObjectStruct));
                if (infos.Recorded == "true")
                {
                    retour = true;
                }
            }
            else
            {
                UserInfosObjectStruct UserInfos = new UserInfosObjectStruct
                {
                    Recorded      = "",
                    Prenom        = "",
                    Nom           = "",
                    Mail          = "",
                    Gsm           = "",
                    DateNaissance = "",
                    NomContact    = "",
                    PrenomContact = "",
                    GsmContact    = "",
                    MailContact   = "",
                    HeureMatin    = "",
                    HeureMidi     = "",
                    HeureSoir     = ""
                };

                string json = JsonConvert.SerializeObject(UserInfos);
                DependencyService.Get <Class.IFileReadWrite>().WriteData(fileName, json);
            }
            return(retour);
        }
コード例 #5
0
        public StackLayout StackUIBase(StackLayout StackMainID, string arg, string message, MainPage ThisLocal)
        {
            StackLayout Retour = new StackLayout();

            UserInfosObjectStruct InfosUser = FindInfos.FindInfosUser();

            DateTime dateNow = DateTime.Now;
            DateTime dNow    = DateTime.Parse(dateNow.Hour.ToString() + ":" + dateNow.Minute.ToString(), PrefsApp.cultureApp); //Peut être utiliser DateTime.TryParse pour valider l'heure
            DateTime dMatin  = DateTime.Parse(InfosUser.HeureMatin, PrefsApp.cultureApp);
            DateTime dMidi   = DateTime.Parse(InfosUser.HeureMidi, PrefsApp.cultureApp);
            DateTime dSoir   = DateTime.Parse(InfosUser.HeureSoir, PrefsApp.cultureApp);

            string Quand = Tools.MomentJourneeMesure(dMatin, dMidi, dSoir, dNow);


            //  string Heure = "";
            //  string NomHeureMessage = "";
            if (Quand == "midi")
            {
                PrefsApp.Heure              = InfosUser.HeureMidi;
                PrefsApp.HeureRefMesure     = InfosUser.HeureMidi;
                PrefsApp.NomHeureMessage    = "de midi";
                PrefsApp.NomMomentRefMesure = "midi";
            }

            else if (Quand == "soir")
            {
                PrefsApp.Heure              = InfosUser.HeureSoir;
                PrefsApp.HeureRefMesure     = InfosUser.HeureSoir;
                PrefsApp.NomHeureMessage    = "du soir";
                PrefsApp.NomMomentRefMesure = "soir";
            }

            else
            {
                PrefsApp.Heure              = InfosUser.HeureMatin;
                PrefsApp.HeureRefMesure     = InfosUser.HeureMatin;
                PrefsApp.NomHeureMessage    = "du matin";
                PrefsApp.NomMomentRefMesure = "matin";
            }

            PrefsApp.heureDeMesure = PrefsApp.Heure;

            Label Infos = new Label
            {
                HorizontalOptions       = LayoutOptions.FillAndExpand,
                FontAttributes          = FontAttributes.Bold,
                VerticalOptions         = LayoutOptions.StartAndExpand,
                HorizontalTextAlignment = TextAlignment.Center,
                StyleId         = "InfosID",
                BackgroundColor = Color.Azure,
                TextColor       = Color.Red,
                FontSize        = Device.GetNamedSize(NamedSize.Large, typeof(Label))
            };

            if (arg == "rater")
            {
                Console.WriteLine("RATER " + message);
                Infos.Text      = message;
                Infos.TextColor = Color.Red;
                //                Infos.BackgroundColor = Color.;
            }
            else if (arg == "valider")
            {
                Console.WriteLine("valider " + message);
                Infos.Text      = message;
                Infos.TextColor = Color.Green;
                //               Infos.BackgroundColor = Color.Indigo;
            }
            else
            {
                //  Console.WriteLine("ELSE");
                Infos.Text = "";
            }



            Frame HorlogeEncadrement = new Frame()
            {
                BorderColor       = Color.BlueViolet,
                Margin            = new Thickness(0, 10, 0, 10),
                HasShadow         = true,
                Padding           = 5,
                HorizontalOptions = LayoutOptions.FillAndExpand,
                VerticalOptions   = LayoutOptions.StartAndExpand
            };


            Label Horloge = new Label
            {
                Text = "",
                HorizontalOptions       = LayoutOptions.CenterAndExpand,
                FontAttributes          = FontAttributes.Bold,
                VerticalOptions         = LayoutOptions.CenterAndExpand,
                HorizontalTextAlignment = TextAlignment.Center,
                StyleId = "HorlogeID",

                TextColor = Color.Blue,
                FontSize  = Device.GetNamedSize(NamedSize.Large, typeof(Label))
            };

            HorlogeEncadrement.Content = Horloge;



            Label Bienvenue = new Label
            {
                Text = "Bonjour " + InfosUser.Prenom + " " + InfosUser.Nom + " votre prochain controle " + PrefsApp.NomHeureMessage + " est à : " + PrefsApp.Heure,
                HorizontalOptions       = LayoutOptions.FillAndExpand,
                FontAttributes          = FontAttributes.Bold,
                VerticalOptions         = LayoutOptions.StartAndExpand,
                HorizontalTextAlignment = TextAlignment.Center,
                TextColor = Color.DarkSlateBlue,
                StyleId   = "BienvenueID",
                FontSize  = Device.GetNamedSize(NamedSize.Large, typeof(Label))
            };

            Retour.Children.Add(Infos);
            Retour.Children.Add(HorlogeEncadrement);
            Retour.Children.Add(Bienvenue);



            Horloges._isRunningMainTimer = true;
            Horloges.SetTimerMain(Horloge, StackMainID, ThisLocal);


            return(Retour);
        }
コード例 #6
0
        public StackLayout StackUIMesure(MainPage mainPage, StackLayout StackMainID)
        {
            StackLayout Retour = new StackLayout();

            UserInfosObjectStruct InfosUser = FindInfos.FindInfosUser();
            DateTime dateNow = DateTime.Now;
            DateTime dNow    = DateTime.Parse(dateNow.Hour.ToString() + ":" + dateNow.Minute.ToString(), PrefsApp.cultureApp); //Peut être utiliser DateTime.TryParse pour valider l'heure
            DateTime dMatin  = DateTime.Parse(InfosUser.HeureMatin, PrefsApp.cultureApp);
            DateTime dMidi   = DateTime.Parse(InfosUser.HeureMidi, PrefsApp.cultureApp);
            DateTime dSoir   = DateTime.Parse(InfosUser.HeureSoir, PrefsApp.cultureApp);


            if (PrefsApp.NomMomentRefMesure == "midi")
            {
                PrefsApp.Heure                = InfosUser.HeureMidi;
                PrefsApp.NomHeure             = "de Midi";
                PrefsApp.NomHeureCalculUnitie = "Midi";
            }

            else if (PrefsApp.NomMomentRefMesure == "soir")
            {
                PrefsApp.Heure                = InfosUser.HeureSoir;
                PrefsApp.NomHeure             = "du Soir";
                PrefsApp.NomHeureCalculUnitie = "Soir";
            }

            else
            {
                PrefsApp.Heure                = InfosUser.HeureMatin;
                PrefsApp.NomHeure             = "du Matin";
                PrefsApp.NomHeureCalculUnitie = "Matin";
            }

            Label Alert = new Label
            {
                Text = "",
                HorizontalOptions = LayoutOptions.FillAndExpand,
                FontAttributes    = FontAttributes.Bold,

                VerticalOptions         = LayoutOptions.CenterAndExpand,
                HorizontalTextAlignment = TextAlignment.Center,
                BackgroundColor         = Color.Azure,
                TextColor = Color.Red,
                StyleId   = "AlertID",
                FontSize  = Device.GetNamedSize(NamedSize.Large, typeof(Label))
            };

            if (Horloges.isAlert == true)
            {
                Alert.Text = Horloges.AlertMessage;
            }

            Frame HorlogeEncadrement = new Frame()
            {
                BorderColor       = Color.BlueViolet,
                Margin            = new Thickness(0, 10, 0, 10),
                HasShadow         = true,
                Padding           = 5,
                HorizontalOptions = LayoutOptions.FillAndExpand,
                VerticalOptions   = LayoutOptions.StartAndExpand
            };


            Label Horloge = new Label
            {
                Text = "",
                HorizontalOptions       = LayoutOptions.CenterAndExpand,
                FontAttributes          = FontAttributes.Bold,
                VerticalOptions         = LayoutOptions.CenterAndExpand,
                HorizontalTextAlignment = TextAlignment.Center,
                StyleId = "HorlogeID",

                TextColor = Color.Blue,
                FontSize  = Device.GetNamedSize(NamedSize.Large, typeof(Label))
            };

            HorlogeEncadrement.Content = Horloge;



            Label Bienvenue = new Label
            {
                Text = "c'est l'heure de mesurer votre glycémie et de prendre vos médicaments pour le repas " + PrefsApp.NomHeure,
                HorizontalOptions       = LayoutOptions.FillAndExpand,
                FontAttributes          = FontAttributes.Bold,
                VerticalOptions         = LayoutOptions.CenterAndExpand,
                HorizontalTextAlignment = TextAlignment.Center,
                StyleId  = "BienvenueID",
                FontSize = Device.GetNamedSize(NamedSize.Large, typeof(Label))
            };


            Label GlycemieLabel = new Label
            {
                Text = "Glycémie",
                HorizontalOptions       = LayoutOptions.FillAndExpand,
                FontAttributes          = FontAttributes.None,
                VerticalOptions         = LayoutOptions.CenterAndExpand,
                HorizontalTextAlignment = TextAlignment.Center,
                StyleId  = "",
                FontSize = Device.GetNamedSize(NamedSize.Large, typeof(Label))
            };


            Entry Glycemie = new Entry
            {
                HorizontalOptions       = LayoutOptions.FillAndExpand,
                FontAttributes          = FontAttributes.None,
                VerticalOptions         = LayoutOptions.CenterAndExpand,
                HorizontalTextAlignment = TextAlignment.Center,
                StyleId  = "",
                FontSize = Device.GetNamedSize(NamedSize.Large, typeof(Label))
            };


            Label Insuline = new Label
            {
                Text = "",
                HorizontalOptions       = LayoutOptions.FillAndExpand,
                FontAttributes          = FontAttributes.None,
                VerticalOptions         = LayoutOptions.CenterAndExpand,
                HorizontalTextAlignment = TextAlignment.Center,
                StyleId  = "",
                FontSize = Device.GetNamedSize(NamedSize.Large, typeof(Label))
            };

            Glycemie.Unfocused += (sender, EventArgs) => { Glycemie_lostFocus(sender, EventArgs, Insuline, Glycemie, mainPage); };

            /*
             * Ajout switch si necessaire
             *
             */

            Button BpSave = new Button
            {
                HorizontalOptions = LayoutOptions.FillAndExpand,
                FontAttributes    = FontAttributes.None,
                VerticalOptions   = LayoutOptions.CenterAndExpand,
                Text = "Valider"
            };

            //  BpSave.Clicked += ButtonSave_Clicked;
            BpSave.Clicked += (sender, EventArgs) => { ButtonSave_Clicked(sender, EventArgs, Alert, Horloge, Bienvenue, Glycemie, Insuline, mainPage); };
            // StackMainID.Children.Add(baseStack);


            Retour.Children.Add(Alert);
            Retour.Children.Add(HorlogeEncadrement);
            Retour.Children.Add(Bienvenue);
            Retour.Children.Add(GlycemieLabel);
            Retour.Children.Add(Glycemie);
            Retour.Children.Add(Insuline);
            //   Retour.Children.Add(validateMesure);
            Retour.Children.Add(BpSave);


            Horloges._isRunningMesureTimer = true;
            Horloges.SetTimerMesure(Horloge, Alert, mainPage, StackMainID);
            // Label Timer2, Label Alert, MainPage MainPageLocal, StackLayout StackMainID



            return(Retour);
        }
コード例 #7
0
        private async Task Bp_record_ClickedAsync(object sender, EventArgs e)
        {
            Boolean FormCompleted          = true;
            Boolean DateNaissanceCompleted = true;
            Boolean HeureCompleted         = true;
            Boolean mailUserOk             = true;
            Boolean mailContactOk          = true;
            Boolean gsmOk        = true;
            Boolean gsmContactOk = true;

            string fileName = PrefsApp.fileUserPref;
            UserInfosObjectStruct UserInfos = new UserInfosObjectStruct();

            if (nom.Text == "")
            {
                FormCompleted = false;
            }
            UserInfos.Nom = nom.Text;
            if (prenom.Text == "")
            {
                FormCompleted = false;
            }
            UserInfos.Prenom = prenom.Text;
            if (mail.Text == "")
            {
                FormCompleted = false;
            }
            UserInfos.Mail = mail.Text;
            if (mail.Text == "")
            {
                FormCompleted = false;
            }
            else
            {
                if (ToolsLocal.ValidMail(UserInfos.Mail) == false)
                {
                    mailUserOk = false;
                }
            }

            UserInfos.Gsm = gsm.Text;
            if (gsm.Text == "")
            {
                FormCompleted = false;
            }
            if (ToolsLocal.ValidPhone(UserInfos.Gsm) == false)
            {
                gsmOk = false;
            }



            if (dateNaissance.Date.ToString("dd/MM/yyyy") == "20/07/2018")
            {
                DateNaissanceCompleted = false;
            }
            UserInfos.DateNaissance = dateNaissance.Date.ToString("dd/MM/yyyy");

            if (nomContact.Text == "")
            {
                FormCompleted = false;
            }
            UserInfos.NomContact = nomContact.Text;
            if (prenomContact.Text == "")
            {
                FormCompleted = false;
            }
            UserInfos.PrenomContact = prenomContact.Text;

            UserInfos.GsmContact = gsmContact.Text;
            if (gsmContact.Text == "")
            {
                FormCompleted = false;
            }
            if (ToolsLocal.ValidPhone(UserInfos.GsmContact) == false)
            {
                gsmContactOk = false;
            }



            UserInfos.MailContact = mailContact.Text;
            if (mailContact.Text == "")
            {
                FormCompleted = false;
            }
            else
            {
                if (ToolsLocal.ValidMail(mailContact.Text) == false)
                {
                    mailContactOk = false;
                }
            }



            if (heureMatin.Time.Hours.ToString() + ":" + heureMatin.Time.Minutes.ToString() == "0:0")
            {
                HeureCompleted = false;
            }
            //   Class.Tools.ConvertTime1Chiffre(heureMatin.Time.Hours)  Class.Tools.ConvertTime1Chiffre(heureMatin.Time.Minutes)
            UserInfos.HeureMatin = ToolsLocal.ConvertTime1Chiffre(heureMatin.Time.Hours).ToString() + ":" + ToolsLocal.ConvertTime1Chiffre(heureMatin.Time.Minutes).ToString();

            if (heureMidi.Time.Hours.ToString() + ":" + heureMidi.Time.Minutes.ToString() == "0:0")
            {
                HeureCompleted = false;
            }
            UserInfos.HeureMidi = ToolsLocal.ConvertTime1Chiffre(heureMidi.Time.Hours).ToString() + ":" + ToolsLocal.ConvertTime1Chiffre(heureMidi.Time.Minutes).ToString();

            if (heureSoir.Time.Hours.ToString() + ":" + heureSoir.Time.Minutes.ToString() == "0:0")
            {
                HeureCompleted = false;
            }
            UserInfos.HeureSoir = ToolsLocal.ConvertTime1Chiffre(heureSoir.Time.Hours).ToString() + ":" + ToolsLocal.ConvertTime1Chiffre(heureSoir.Time.Minutes).ToString();


            if (FormCompleted == true && DateNaissanceCompleted == true && HeureCompleted == true && mailUserOk == true && mailContactOk == true && gsmOk == true && gsmContactOk == true)
            {
                UserInfos.Recorded = "true";
                try
                {
                    string json = JsonConvert.SerializeObject(UserInfos);
                    DependencyService.Get <Class.IFileReadWrite>().WriteData(fileName, json);
                    await DisplayAlert("Info", "Préférences Utilisateur sauvegardé.: ", "ok");
                }
                catch (Exception err)
                {
                    await DisplayAlert("Erreur", "erreur: " + err.Message.ToString(), "ok");
                }
            }
            else
            {
                Boolean DateEtHeure = true;
                if (FormCompleted == false)
                {
                    await DisplayAlert("Erreur", "Tout les champs texte doivent être rempli", "OK");
                }
                else
                {
                    if (mailUserOk == false || mailContactOk == false || gsmOk == false || gsmContactOk == false)
                    {
                        if (mailUserOk == false)
                        {
                            await DisplayAlert("Erreur", "le mail utilisateur est incorrecte", "OK");
                        }
                        if (mailContactOk == false)
                        {
                            await DisplayAlert("Erreur", "le mail de la personne de contact est incorrecte", "OK");
                        }
                        if (gsmOk == false)
                        {
                            await DisplayAlert("Erreur", "le gsm de l'utilisateur est incorrecte", "OK");
                        }

                        if (gsmContactOk == false)
                        {
                            await DisplayAlert("Erreur", "le gsm de la personne de contact est incorrecte", "OK");
                        }
                    }
                    else
                    {
                        if (DateNaissanceCompleted == false)
                        {
                            Boolean answer = await DisplayAlert("Question?", "Est-ce que votre date de naissance est bien le 20/07/2018 ? si c'estnon veuillez changer la date, Merci.", "Oui", "Non");

                            if (answer == false)
                            {
                                DateEtHeure = false;
                            }
                        }
                        if (HeureCompleted == false)
                        {
                            var answer = await DisplayAlert("Question?", "Voici Vos heures de repas: Matin->" + heureMatin.Time.Hours.ToString() + ":" + heureMatin.Time.Minutes.ToString() + ", Midi->" + heureMidi.Time.Hours.ToString() + ":" + heureMidi.Time.Minutes.ToString() + "et soir->" + heureSoir.Time.Hours.ToString() + ":" + heureSoir.Time.Minutes.ToString() + ". Est-ce Correcte ? si non veuillez modifie, merci.", "Oui", "Non");

                            if (answer == false)
                            {
                                DateEtHeure = false;
                            }
                        }
                    }
                }


                if (DateEtHeure == true && FormCompleted == true && mailUserOk == true && mailContactOk == true && gsmOk == true && gsmContactOk == true)
                {
                    UserInfos.Recorded = "true";
                    try
                    {
                        string json = JsonConvert.SerializeObject(UserInfos);
                        DependencyService.Get <Class.IFileReadWrite>().WriteData(fileName, json);
                        await DisplayAlert("Info", "Préférences Utilisateur sauvegardé.: ", "ok");
                    }
                    catch (Exception err)
                    {
                        await DisplayAlert("Erreur", "erreur: " + err.Message.ToString(), "ok");
                    }
                }
            }
        }