Ejemplo n.º 1
0
        private async void ButtonSubmit_OnClick(object sender, RoutedEventArgs e)
        {
            // TODO: Gumb za pocistis intervale
            // TODO: preglej da je vse vpisano sele pol idi dalje. Fali za datum

            if (!IsEverythingValid())
            {
                return;
            }

            Interval interval = new Interval();
            //List<Interval> seznamIntervalov = new List<Interval>();

            var coll = grid_instruction.Children.OfType <ComboBox>().ToList();

            for (int i = 0; i < coll.Count(); i++)
            {
                interval.Dan  = int.Parse(coll[i].SelectedValue.ToString());
                interval.Ure  = int.Parse(coll[i + 1].SelectedValue.ToString());
                interval.Doza = int.Parse(coll[i + 2].SelectedValue.ToString());

                seznamIntervalov.Add(interval);

                interval = new Interval();
                i        = i + 2;
            }

            Opomnik  opomnik    = new Opomnik();
            int      IdZdravila = int.Parse(comboBoxZdravilo.SelectedValue.ToString());
            DateTime dt         = new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day, timePickZdravilo.Time.Hours, timePickZdravilo.Time.Minutes, timePickZdravilo.Time.Seconds);

            //alarm_n1.Zdravilo1 = Baza.GetFirstZdraviloById(IdZdravila);
            //IzracunajKonecJemanja(seznamIntervalov, dt);
            //alarm_n1.KonecJemanja = seznamUrZaToastNotificatione[seznamUrZaToastNotificatione.Count() - 1];

            opomnik.IdZdravilo     = IdZdravila;
            opomnik.ZacetekJemanja = dt;
            opomnik.Intervali      = seznamIntervalov;
            opomnik.IzracunajCasovneTermine();


            // TODO: preglej melodijo ce je default
            var localSettings = Windows.Storage.ApplicationData.Current.LocalSettings;

            opomnik.Melodija = localSettings.Values["DefaultMelodie"].ToString();

            //TODO:this here is a fuckfest
            //int OpomnikId = await Baza.AddOpomnikAsync(opomnik);
            int idOpomnika = Baza.ShraniOpomnik(opomnik);
            var k          = await Baza.GetOpomnikById(idOpomnika);

            MakeToastNotifications(k);
            Frame.Navigate(typeof(MainPage));
        }
Ejemplo n.º 2
0
        static void MakeToastNotifications(Opomnik opomnik)
        {
            foreach (var x in opomnik.Intervali)
            {
                foreach (var y in x.SeznamTerminovZaAlarm)
                {
                    Windows.Data.Xml.Dom.XmlDocument toastXml = new Windows.Data.Xml.Dom.XmlDocument();
                    string toastXmlTemplate = "<toast scenario=\'alarm\' launch=\'app-defined-string\'>" +
                                              "<visual>" +
                                              "<binding template =\'ToastGeneric\'>" +
                                              "<text>" + opomnik.Zdravilo1.Naziv + "</text>" +
                                              "<text>" +
                                              "Vzeti je potrebno: " + x.Doza + " " + opomnik.Zdravilo1.Enota +
                                              "</text>" +
                                              "</binding>" +
                                              "</visual>" +
                                              "<audio src=\'" + opomnik.Melodija + "\'" + "/>" +
                                              "<actions>" +
                                              "<action activationType=\'foreground\' content =\'yes\' arguments=\'" + y.Id + "\'" +
                                              "/>" +
                                              "</actions>" +
                                              "</toast>";

                    toastXml.LoadXml(toastXmlTemplate);
                    //y.TerminZazvonenje = DateTime.Now.AddSeconds(10);
                    var    toast = new Windows.UI.Notifications.ScheduledToastNotification(toastXml, y.TerminZazvonenje);
                    Random rnd   = new Random();
                    toast.Id = rnd.Next(10000).ToString();
                    if (Windows.UI.Notifications.ToastNotificationManager.CreateToastNotifier().Setting ==
                        NotificationSetting.Enabled)
                    {
                        Windows.UI.Notifications.ToastNotificationManager.CreateToastNotifier().AddToSchedule(toast);
                    }
                }
            }
        }
Ejemplo n.º 3
0
        static void MakeToastNotifications(Opomnik opomnik)
        {
            foreach (var x in opomnik.Intervali)
            {
                foreach (var y in x.SeznamTerminovZaAlarm)
                {
                    Windows.Data.Xml.Dom.XmlDocument toastXml = new Windows.Data.Xml.Dom.XmlDocument();
                    string toastXmlTemplate = "<toast scenario=\'alarm\' launch=\'app-defined-string\'>" +
                                              "<visual>" +
                                              "<binding template =\'ToastGeneric\'>" +
                                              "<text>" + opomnik.Zdravilo1.Naziv + "</text>" +
                                              "<text>" +
                                              "Vzeti je potrebno: " + x.Doza + " " + opomnik.Zdravilo1.Enota +
                                              "</text>" +
                                              "</binding>" +
                                              "</visual>" +
                                              "<audio src=\'" + opomnik.Melodija + "\'" + "/>" + 
                                              "<actions>" +
                                              "<action activationType=\'foreground\' content =\'yes\' arguments=\'" + y.Id + "\'" +
                                              "/>" +
                                              "</actions>" +
                                              "</toast>";

                    toastXml.LoadXml(toastXmlTemplate);
                    //y.TerminZazvonenje = DateTime.Now.AddSeconds(10);
                    var toast = new Windows.UI.Notifications.ScheduledToastNotification(toastXml, y.TerminZazvonenje);
                    Random rnd = new Random();
                    toast.Id = rnd.Next(10000).ToString();
                    if (Windows.UI.Notifications.ToastNotificationManager.CreateToastNotifier().Setting ==
                        NotificationSetting.Enabled)
                    {
                        Windows.UI.Notifications.ToastNotificationManager.CreateToastNotifier().AddToSchedule(toast);
                    }
                }
            }
        }
Ejemplo n.º 4
0
        private async void ButtonSubmit_OnClick(object sender, RoutedEventArgs e)
        {
            // TODO: Gumb za pocistis intervale
            // TODO: preglej da je vse vpisano sele pol idi dalje. Fali za datum

            if (!IsEverythingValid())
                return;

            Interval interval = new Interval();
            //List<Interval> seznamIntervalov = new List<Interval>();

            var coll = grid_instruction.Children.OfType<ComboBox>().ToList();

            for (int i = 0; i < coll.Count(); i++)
            {
                interval.Dan = int.Parse(coll[i].SelectedValue.ToString());
                interval.Ure = int.Parse(coll[i + 1].SelectedValue.ToString());
                interval.Doza = int.Parse(coll[i + 2].SelectedValue.ToString());

                seznamIntervalov.Add(interval);

                interval = new Interval();
                i = i + 2;
            }

            Opomnik opomnik = new Opomnik();
            int IdZdravila = int.Parse(comboBoxZdravilo.SelectedValue.ToString());
            DateTime dt = new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day, timePickZdravilo.Time.Hours, timePickZdravilo.Time.Minutes, timePickZdravilo.Time.Seconds);
            //alarm_n1.Zdravilo1 = Baza.GetFirstZdraviloById(IdZdravila);
            //IzracunajKonecJemanja(seznamIntervalov, dt);
            //alarm_n1.KonecJemanja = seznamUrZaToastNotificatione[seznamUrZaToastNotificatione.Count() - 1];

            opomnik.IdZdravilo = IdZdravila;
            opomnik.ZacetekJemanja = dt;
            opomnik.Intervali = seznamIntervalov;
            opomnik.IzracunajCasovneTermine();


            // TODO: preglej melodijo ce je default
            var localSettings = Windows.Storage.ApplicationData.Current.LocalSettings;

            opomnik.Melodija = localSettings.Values["DefaultMelodie"].ToString();

            //TODO:this here is a fuckfest
            //int OpomnikId = await Baza.AddOpomnikAsync(opomnik);
            int idOpomnika = Baza.ShraniOpomnik(opomnik);
            var k = await Baza.GetOpomnikById(idOpomnika);
            MakeToastNotifications(k);
            Frame.Navigate(typeof (MainPage));

        }