예제 #1
0
        //Download Weather Forecast and Bing Wallpaper
        async Task DownloadBackground()
        {
            try
            {
                Debug.WriteLine("Checking if background download is needed.");

                //Check if background download is enabled
                if (setBackgroundDownload)
                {
                    if (setDownloadBingWallpaper && (BgStatusDownloadBing == "Never" || DateTimeNow.Subtract(DateTime.Parse(BgStatusDownloadBing, vCultureInfoEng)).TotalMinutes >= setBackgroundDownloadIntervalMin))
                    {
                        await DownloadBingWallpaper();
                    }
                    if (setDownloadWeather && (BgStatusDownloadLocation == "Never" || BgStatusDownloadLocation == "Failed" || BgStatusDownloadWeather == "Never" || BgStatusDownloadWeather == "Failed" || DateTimeNow.Subtract(DateTime.Parse(BgStatusDownloadWeather, vCultureInfoEng)).TotalMinutes >= setBackgroundDownloadIntervalMin))
                    {
                        //Load and set Download variables
                        if (setFahrenheitCelsius == 1)
                        {
                            DownloadWeatherUnits = "?units=C";
                        }
                        if (setDisplayRegionLanguage)
                        {
                            DownloadWeatherLanguage = vCultureInfoReg.Name;
                        }

                        //Start downloading weather information
                        bool LocationResult = await DownloadLocation();

                        if (LocationResult)
                        {
                            await DownloadWeather();

                            //Force live tile update
                            TileLive_ForceUpdate = true;
                        }
                    }
                }
            }
            catch { }
        }
예제 #2
0
        public async Task <IViewComponentResult> InvokeAsync(Models.Patient currentPatient)
        {
            //List<Models.PatientData.ActivitySummary> summariesMonth = await ActivitySummaryController.Read(currentPatient.Id, DateTimeNow.ToString(italianDateFormat), "1m");
            //List<Models.PatientData.ActivitySummary> summariesWeek = await ActivitySummaryController.Read(currentPatient.Id, DateTimeNow.ToString(italianDateFormat), "1w");

            var data = new PatientPersonalData
            {
                Patient = currentPatient
            };

            //data.TotalSteps.Month = (from s in summariesMonth select s.Steps).Sum();
            //data.TotalSteps.Week = (from s in summariesWeek select s.Steps).Sum();

            //data.TotalCalories.Month = (from s in summariesMonth select s.CaloriesCategory.OutCalories).Sum();
            //data.TotalCalories.Week = (from s in summariesWeek select s.CaloriesCategory.OutCalories).Sum();

            //data.AverageFloors.Month = (from s in summariesMonth select s.Floors).Average();
            //data.AverageFloors.Week = (from s in summariesWeek select s.Floors).Average();

            data.WeightComparison.Today = await WeightController.Read(currentPatient.Id, DateTimeNow.ToString(italianDateFormat));

            data.WeightComparison.Yesterday = await WeightController.Read(currentPatient.Id, DateTimeNow.Subtract(TimeSpan.FromDays(1)).ToString(italianDateFormat));

            return(View(data));
        }
예제 #3
0
        //Load first other used data
        async Task <bool> LoadOtherDataFirst()
        {
            try
            {
                Debug.WriteLine("Loading first other miscellaneous data.");

                //Load and set time splitter character
                if (setDisplayCurrentTime)
                {
                    switch (setDisplayTimeSplitter)
                    {
                    case 0: { TextTimeSplit = ":"; break; }

                    case 1: { TextTimeSplit = "."; break; }

                    case 2: { TextTimeSplit = ","; break; }

                    case 3: { TextTimeSplit = "_"; break; }

                    case 4: { TextTimeSplit = "-"; break; }

                    case 5: { TextTimeSplit = "+"; break; }

                    case 6: { TextTimeSplit = "x"; break; }

                    case 7: { TextTimeSplit = "|"; break; }

                    case 8: { TextTimeSplit = "!"; break; }

                    case 9: { TextTimeSplit = "*"; break; }

                    case 10: { TextTimeSplit = "@"; break; }

                    case 11: { TextTimeSplit = "#"; break; }

                    case 12: { TextTimeSplit = "&"; break; }

                    case 13: { TextTimeSplit = "̥"; break; }

                    case 14: { TextTimeSplit = "͓"; break; }

                    case 15: { TextTimeSplit = " "; break; }
                    }
                }

                //Check and set the weather icon style
                if (setDisplayWeatherWhiteIcons)
                {
                    WeatherIconStyle = "White";
                }

                //Check if current weather icon is available
                string WeatherIconFormat = "WeatherSquare" + WeatherIconStyle;
                if (await AVFunctions.AppFileExists("Assets/" + WeatherIconFormat + "/" + BgStatusWeatherCurrentIcon + ".png"))
                {
                    WeatherIconCurrent = BgStatusWeatherCurrentIcon;
                }
                else
                {
                    WeatherIconCurrent = "0";
                }

                //Check for active alarms and timers
                if ((setDisplayAlarm || setLockAlarm) && Toast_UpdateManager.GetScheduledToastNotifications().Any(x => x.DeliveryTime > DateTimeNow))
                {
                    TimerAlarmActive = true;
                }

                //Load and set current battery text
                if (TextPositionUsed(Setting_TextPositions.Battery) || setLockBattery || setLockBatteryDetailed || setNotiBattery || setNotiLowBattery || TileBattery_Pinned || setDisplayTimeCustomText)
                {
                    await LoadBatteryLevel();
                }

                //Load and set current network name
                if (TextPositionUsed(Setting_TextPositions.Network) || setLockNetwork || setNotiNetworkChange || setDisplayTimeCustomText)
                {
                    //Get and set the current network name
                    TextNetworkName = await AVFunctions.GetNetworkName();

                    //Set the network name to tile text
                    TextPositionSet(Setting_TextPositions.Network, TextNetworkName);

                    //Check if the network has changed
                    if (TextNetworkName != BgStatusNetworkName)
                    {
                        vApplicationSettings["BgStatusNetworkName"] = TextNetworkName;
                        //Notification - Network change
                        ShowNotiNetworkChange();
                    }
                }

                //Load current week number
                if (TextPositionUsed(Setting_TextPositions.WeekNumber) || setLockWeekNumber || setDisplayDateWeekNumber || setNotiWeekNumber || setLiveTileSizeName == "WideWords")
                {
                    DateTime  DateTimeWeekNow = DateTimeNow;
                    DayOfWeek DateTimeDay     = CultureInfo.InvariantCulture.Calendar.GetDayOfWeek(DateTimeWeekNow);
                    if (DateTimeDay >= DayOfWeek.Monday && DateTimeDay <= DayOfWeek.Wednesday)
                    {
                        DateTimeWeekNow = DateTimeWeekNow.AddDays(3);
                    }
                    WeekNumberCurrent = CultureInfo.InvariantCulture.Calendar.GetWeekOfYear(DateTimeWeekNow, CalendarWeekRule.FirstFourDayWeek, DayOfWeek.Monday);

                    //Notification - Current week number
                    ShowNotiWeekNumber();
                }

                //Load and set day time progression
                if (TextPositionUsed(Setting_TextPositions.DayProgress) || setNotiDayTime)
                {
                    DayTimeProgress = Convert.ToInt32(100 - (((1440 - DateTimeNow.Subtract(DateTime.Today).TotalMinutes) / 1440) * 100));

                    //Set day time progression to tile text
                    if (DayTimeProgress < 25)
                    {
                        TextPositionSet(Setting_TextPositions.DayProgress, "🕛 " + DayTimeProgress + " %");
                    }
                    else if (DayTimeProgress < 50)
                    {
                        TextPositionSet(Setting_TextPositions.DayProgress, "🕒 " + DayTimeProgress + " %");
                    }
                    else if (DayTimeProgress < 75)
                    {
                        TextPositionSet(Setting_TextPositions.DayProgress, "🕕 " + DayTimeProgress + " %");
                    }
                    else
                    {
                        TextPositionSet(Setting_TextPositions.DayProgress, "🕘 " + DayTimeProgress + " %");
                    }

                    //Notification - Day time progression
                    ShowNotiDayTime();
                }

                //Load Next calendar time
                if (TextPositionUsed(Setting_TextPositions.CalendarName) || TextPositionUsed(Setting_TextPositions.CalendarDateTime) || setLockCalendar || setNotiCalendarTime)
                {
                    await LoadCalendarEvent();

                    //Notification - Next calendar time
                    ShowNotiCalendarTime();
                }

                //Load countdown event information
                if (TextPositionUsed(Setting_TextPositions.Countdown) || setLockCountdown || setNotiCountdownTime)
                {
                    //Load first countdown event from XML
                    using (Stream OpenStreamForReadAsync = await ApplicationData.Current.LocalFolder.OpenStreamForReadAsync("TimeMeCountdown.xml"))
                    {
                        XDocument XDocument = XDocument.Load(OpenStreamForReadAsync);
                        OpenStreamForReadAsync.Dispose();

                        IEnumerable <XElement> XmlCountdownEvents = XDocument.Descendants("TimeMeCountdown").Elements("Count");
                        if (XmlCountdownEvents.Any())
                        {
                            XElement FirstEvent = XmlCountdownEvents.Last();
                            DateTime LoadedDate = DateTime.Parse(FirstEvent.Attribute("CountDate").Value);

                            //Datetime to string
                            string ConvertedDate = "";
                            if ((bool)vApplicationSettings["DisplayRegionLanguage"])
                            {
                                ConvertedDate = AVFunctions.ToTitleCase(LoadedDate.Date.ToString("d MMMM yyyy", vCultureInfoReg));
                            }
                            else
                            {
                                ConvertedDate = LoadedDate.Date.ToString("d MMMM yyyy", vCultureInfoEng);
                            }

                            //Calculate the days left
                            CountdownEventDate = (LoadedDate.Date.Subtract(DateTimeNow.Date).Days).ToString();
                            if (CountdownEventDate == "0")
                            {
                                CountdownEventDate = "today";
                            }

                            //Set the countdown name
                            CountdownEventName = FirstEvent.Attribute("CountName").Value;
                        }
                    }

                    //Notification - Countdown Time
                    ShowNotiCountdownTime();
                }
                return(true);
            }
            catch { return(false); }
        }