示例#1
0
 public static async Task<string> GetRequestAsync(SettingsModel settings, CitySettingsModel city)
 {
     try
     {
         return await GetRequestAsync(settings, city.Id, city.Longitude, city.Latitude, city.ZMW);
     }
     catch (Exception)
     {
         return null;
     }
 }
示例#2
0
 public void Set(CitySettingsModel[] citys)
 {
     SavedCities = citys;
 }
示例#3
0
 public void Save(CitySettingsModel[] citys)
 {
     this.SavedCities = citys;
     Save();
 }
示例#4
0
 public static ToastContent CreateAlertToast(HeWeatherModel fetchresult, CitySettingsModel currentCityModel)
 {
     var lo = new ResourceLoader();
     var action = new ToastActionsCustom();
     var button = new ToastButton(lo.GetString("Known"), "Today_Alert_Dismiss");
     button.ActivationType = ToastActivationType.Background;
     action.Buttons.Add(button);
     action.Buttons.Add(new ToastButtonDismiss(lo.GetString("Dismiss")));
     var alarm = fetchresult.Alarms[0];
     ToastContent t = new ToastContent()
     {
         Scenario = ToastScenario.Reminder,
         Launch = currentCityModel.Id,
         Actions = action,
         Visual = new ToastVisual()
         {
             TitleText = new ToastText()
             {
                 Text = alarm.Title
             },
             BodyTextLine1 = new ToastText()
             {
                 Text = alarm.Text
             }
         }
     };
     return t;
 }
示例#5
0
 public static string[] CalculateWeatherAlarm(HeWeatherModel model, CitySettingsModel currentCityModel, SettingsModel settings, DateTime desiredDateTimeinThatRegion)
 {
     var l = new ResourceLoader();
     var todayIndex = Array.FindIndex(model.DailyForecast, x =>
     {
         return x.Date.Date == desiredDateTimeinThatRegion.Date;
     });
     var hourIndex = Array.FindIndex(model.HourlyForecast, x =>
     {
         return (x.DateTime - desiredDateTimeinThatRegion).TotalSeconds > 0;
     });
     if (desiredDateTimeinThatRegion.Hour < 7)
     {
         todayIndex--;
     }
     if (todayIndex < 0)
     {
         todayIndex = 0;
     }
     if (hourIndex < 0)
     {
         hourIndex = 0;
     }
     List<string> str = new List<string>();
     var ctos = new ConditiontoTextConverter();
     switch (model.DailyForecast[todayIndex + 1].Condition.DayCond)
     {
         case WeatherCondition.gale:
         case WeatherCondition.strong_gale:
         case WeatherCondition.storm:
         case WeatherCondition.violent_storm:
         case WeatherCondition.hurricane:
         case WeatherCondition.tornado:
         case WeatherCondition.tropical_storm:
             str.Add(currentCityModel.City + l.GetString("ToastGale"));
             break;
         case WeatherCondition.heavy_shower_rain:
             str.Add(currentCityModel.City + l.GetString("ToastRain"));
             break;
         case WeatherCondition.thundershower:
         case WeatherCondition.heavy_thunderstorm:
             str.Add(currentCityModel.City + l.GetString("ToastThunder"));
             break;
         case WeatherCondition.hail:
             str.Add(currentCityModel.City + l.GetString("ToastHail"));
             break;
         case WeatherCondition.heavy_rain:
         case WeatherCondition.extreme_rain:
         case WeatherCondition.storm_rain:
         case WeatherCondition.heavy_storm_rain:
         case WeatherCondition.severe_storm_rain:
             str.Add(currentCityModel.City + l.GetString("ToastRain"));
             break;
         case WeatherCondition.freezing_rain:
             str.Add(currentCityModel.City + l.GetString("ToastFreeze"));
             break;
         case WeatherCondition.heavy_snow:
         case WeatherCondition.snowstorm:
             str.Add(currentCityModel.City + l.GetString("ToastSnow"));
             break;
         case WeatherCondition.volcanic_ash:
         case WeatherCondition.duststorm:
         case WeatherCondition.sandstorm:
             str.Add(currentCityModel.City + l.GetString("ToastSand"));
             break;
         default:
             break;
     }
     if (str.IsNullorEmpty())
     {
         switch (model.DailyForecast[todayIndex + 1].Condition.NightCond)
         {
             case WeatherCondition.gale:
             case WeatherCondition.strong_gale:
             case WeatherCondition.storm:
             case WeatherCondition.violent_storm:
             case WeatherCondition.hurricane:
             case WeatherCondition.tornado:
             case WeatherCondition.tropical_storm:
                 str.Add(currentCityModel.City + l.GetString("ToastGale"));
                 break;
             case WeatherCondition.heavy_shower_rain:
                 str.Add(currentCityModel.City + l.GetString("ToastRain"));
                 break;
             case WeatherCondition.thundershower:
             case WeatherCondition.heavy_thunderstorm:
                 str.Add(currentCityModel.City + l.GetString("ToastThunder"));
                 break;
             case WeatherCondition.hail:
                 str.Add(currentCityModel.City + l.GetString("ToastHail"));
                 break;
             case WeatherCondition.heavy_rain:
             case WeatherCondition.extreme_rain:
             case WeatherCondition.storm_rain:
             case WeatherCondition.heavy_storm_rain:
             case WeatherCondition.severe_storm_rain:
                 str.Add(currentCityModel.City + l.GetString("ToastRain"));
                 break;
             case WeatherCondition.freezing_rain:
                 str.Add(currentCityModel.City + l.GetString("ToastFreeze"));
                 break;
             case WeatherCondition.heavy_snow:
             case WeatherCondition.snowstorm:
                 str.Add(currentCityModel.City + l.GetString("ToastSnow"));
                 break;
             case WeatherCondition.volcanic_ash:
             case WeatherCondition.duststorm:
             case WeatherCondition.sandstorm:
                 str.Add(currentCityModel.City + l.GetString("ToastSand"));
                 break;
             default:
                 break;
         }
     }
     if (str.IsNullorEmpty())
     {
         if ((((model.DailyForecast[todayIndex + 1].LowTemp + model.DailyForecast[todayIndex + 1].HighTemp) / 2).Celsius - ((model.DailyForecast[todayIndex].LowTemp + model.DailyForecast[todayIndex].HighTemp) / 2).Celsius) > 8)
         {
             str.Add(currentCityModel.City + l.GetString("ToastHot"));
         }
         else if ((((model.DailyForecast[todayIndex + 1].LowTemp + model.DailyForecast[todayIndex + 1].HighTemp) / 2).Celsius - ((model.DailyForecast[todayIndex].LowTemp + model.DailyForecast[todayIndex].HighTemp) / 2).Celsius) < -8)
         {
             str.Add(currentCityModel.City + l.GetString("ToastCold"));
         }
     }
     if (!str.IsNullorEmpty())
     {
         str.Add(ctos.Convert(model.DailyForecast[todayIndex + 1].Condition.DayCond, null, null, null) + "  " + model.DailyForecast[todayIndex + 1].LowTemp.Actual(settings.Preferences.TemperatureParameter).ToString() + "~" + model.DailyForecast[todayIndex + 1].HighTemp.Actual(settings.Preferences.TemperatureParameter).ToString());
     }
     return str.ToArray();
 }
示例#6
0
        public static TileContent GenerateNormalTile(HeWeatherModel model, bool isNight, string glance, string glanceFull, Uri uri, int todayIndex, CitySettingsModel currentCity, SettingsModel settings)
        {
            var ctosConverter = new ConditiontoTextConverter();
            var ctoiConverter = new ConditiontoImageConverter();
            var loader = new ResourceLoader();
            #region
            TileContent NowContent = new TileContent()
            {
                Visual = new TileVisual()
                {
                    Branding = TileBranding.Auto,
                    DisplayName = currentCity.City,
                    TileMedium = new TileBinding()
                    {
                        Content = new TileBindingContentAdaptive()
                        {
                            PeekImage = uri == null ? null : (settings.Preferences.TransparentTile ? null : new TilePeekImage()
                            {
                                Source = new TileImageSource(uri.ToString()),
                            }),
                            BackgroundImage = uri == null ? null : (settings.Preferences.TransparentTile ? null : new TileBackgroundImage()
                            {
                                Source = new TileImageSource(uri.ToString()),
                                Overlay = 70
                            }),
                            Children =
                            {
                                new TileText(),
                                new TileText()
                                {
                                    Text = (string)ctosConverter.Convert(model.NowWeather.Now.Condition,null,null,null),
                                    Align = TileTextAlign.Center
                                },


            new TileText()
            {
                Text = model.DailyForecast[todayIndex].HighTemp.Actual(settings.Preferences.TemperatureParameter).ToString(),
                Align = TileTextAlign.Center
            },

            new TileText()
            {
                Text = model.DailyForecast[todayIndex].LowTemp.Actual(settings.Preferences.TemperatureParameter).ToString(),
                Align = TileTextAlign.Center,
                Style = TileTextStyle.CaptionSubtle
            }
                                            }
                        }
                    },

                    TileWide = new TileBinding()
                    {
                        DisplayName = glance,
                        Branding = TileBranding.NameAndLogo,
                        Content = new TileBindingContentAdaptive()
                        {
                            BackgroundImage = uri == null ? null : (settings.Preferences.TransparentTile ? null : new TileBackgroundImage()
                            {
                                Source = new TileImageSource(uri.ToString()),
                                Overlay = 70
                            }),
                            Children =
                                       {
                                new TileGroup()
                                {
                                    Children=
                                    {
                                        new TileSubgroup()
                                        {
                                            Weight = 1,
                                            Children =
                                            {
                                                new TileText()
                                                {
                                                    Text = model.DailyForecast[todayIndex].Date.ToString("ddd"),
                                                    Align = TileTextAlign.Center,
                                                    Style = TileTextStyle.Caption
                                                },
                                                new TileImage()
                                                {
                                                    Source = new TileImageSource("Assets/Tile/" + (string)ctoiConverter.Convert(model.NowWeather.Now.Condition,null,isNight,null))
                                                },
                                                new TileText()
                                                {
                                                    Align = TileTextAlign.Center,
                                                    Style = TileTextStyle.Caption
                                                },
                                            }
                                        },
                                        new TileSubgroup()
                                        {
                                            Weight = 2,
                                            TextStacking = TileTextStacking.Center,
                                            Children =
                                            {
                                                new TileText()
                                                {
                                                    Style = TileTextStyle.CaptionSubtle,
                                                    Align = TileTextAlign.Center
                                                },
                                                new TileText()
                                                {
                                                    Text = (string)ctosConverter.Convert(model.NowWeather.Now.Condition,null,null,null),
                                                    Align = TileTextAlign.Center,
                                                    Style = TileTextStyle.Caption
                                                },

                                                new TileText()
                                                {
                                                    Text = model.DailyForecast[todayIndex].HighTemp.Actual(settings.Preferences.TemperatureParameter).ToString(),
                                                    Align = TileTextAlign.Center,
                                                    Style = TileTextStyle.Caption
                                                },
                                                new TileText()
                                                {
                                                    Text = model.DailyForecast[todayIndex].LowTemp.Actual(settings.Preferences.TemperatureParameter).ToString(),
                                                    Style = TileTextStyle.CaptionSubtle,
                                                    Align = TileTextAlign.Center
                                                }
                                            }
                                        },
                                        new TileSubgroup()
                                        {
                                            Weight = 1,
                                            Children =
                                            {
                                                new TileText()
                                                {
                                                    Align = TileTextAlign.Center,
                                                    Style = TileTextStyle.CaptionSubtle
                                                },
                                                new TileText()
                                                {
                                                    Text = loader.GetString("ScaleText"),
                                                    Align = TileTextAlign.Center,
                                                    Style = TileTextStyle.CaptionSubtle
                                                },
                                                new TileText()
                                                {
                                                    Align = TileTextAlign.Center,
                                                    Style = TileTextStyle.CaptionSubtle
                                                },
                                                new TileText()
                                                {
                                                    Text = loader.GetString("HumText"),
                                                    Align = TileTextAlign.Center,
                                                    Style = TileTextStyle.CaptionSubtle
                                                },
                                            }
                                        },
                                        new TileSubgroup()
                                        {
                                            Weight = 2,
                                            TextStacking = TileTextStacking.Center,
                                            Children =
                                            {
                                                new TileText()
                                                {

                                                    Style = TileTextStyle.CaptionSubtle,
                                                    Align = TileTextAlign.Left
                                                },
                                                new TileText()
                                                {
                                                    Text = model.NowWeather.Wind.Speed.Actual(settings.Preferences.SpeedParameter) +
                                                    model.NowWeather.Wind.Speed.DanWei(settings.Preferences.SpeedParameter),
                                                    Align = TileTextAlign.Left,
                                                    Style = TileTextStyle.Caption
                                                },
                                                new TileText()
                                                {

                                                    Style = TileTextStyle.CaptionSubtle,
                                                    Align = TileTextAlign.Left
                                                },
                                                new TileText()
                                                {
                                                    Text = model.DailyForecast[todayIndex].Humidity.ToString() + "%",
                                                    Align = TileTextAlign.Left,
                                                    Style = TileTextStyle.Caption
                                                },
                                            }
                                        },
                                    }
                                }
                                       },
                            PeekImage = uri == null ? null : (settings.Preferences.TransparentTile ? null : new TilePeekImage()
                            {
                                Source = new TileImageSource(uri.ToString()),
                            }),
                        }
                    },
                    TileLarge = new TileBinding()
                    {
                        Content = new TileBindingContentAdaptive()
                        {
                            BackgroundImage = uri == null ? null : (settings.Preferences.TransparentTile ? null : new TileBackgroundImage()
                            {
                                Source = new TileImageSource(uri.ToString()),
                                Overlay = 70
                            }),
                            Children =
                            {
                                            new TileGroup()
                                            {
                                             Children =
                                             {
                                                 new TileSubgroup()
                                        {
                                            Weight = 30,
                                            Children =
                                            {
                                                new TileImage()
                                                {
                                                    Source = new TileImageSource("Assets/Tile/" + (string)ctoiConverter.Convert(model.NowWeather.Now.Condition,null,isNight,null))
                                                },
                                            }
                                        },
                                        new TileSubgroup()
                                        {
                                            TextStacking = TileTextStacking.Center,
                                            Children =
                                            {
                                                new TileText()
                                                {
                                                    Text = model.DailyForecast[todayIndex].Date.ToString("ddd"),
                                                    Style = TileTextStyle.Base
                                                },
                                                new TileText()
                                                {
                                                    Text = model.DailyForecast[todayIndex].HighTemp.Actual(settings.Preferences.TemperatureParameter).ToString() + '~' + model.DailyForecast[todayIndex].LowTemp.Actual(settings.Preferences.TemperatureParameter).ToString(),
                                                    Align = TileTextAlign.Auto,
                                                    Style = TileTextStyle.Caption
                                                },
                                                new TileText()
                                                {
                                                     Text = glanceFull,
                                                     Align = TileTextAlign.Auto,
                                                     Style = TileTextStyle.CaptionSubtle,
                                                     Wrap = true
                                                }
                                            }
                                        },
                                            },
                                           },
                                            new TileText(),
                                            new TileGroup()
                                            {
                                             Children =
                                             {
                                                 new TileSubgroup()
                                        {
                                            Weight = 30,
                                            Children =
                                            {
                                                new TileImage()
                                                {
                                                    Source = new TileImageSource("Assets/Tile/" + (string)ctoiConverter.Convert(model.NowWeather.Now.Condition,null,isNight,null))
                                                },
                                            }
                                        },
                                        new TileSubgroup()
                                        {
                                            TextStacking = TileTextStacking.Center,
                                            Children =
                                            {
                                                new TileText()
                                                {
                                                    Text = model.DailyForecast[todayIndex+1].Date.ToString("ddd"),
                                                    Style = TileTextStyle.Base
                                                },
                                                new TileText()
                                                {
                                                    Text = model.DailyForecast[todayIndex + 1].HighTemp.Actual(settings.Preferences.TemperatureParameter).ToString() + '~' + model.DailyForecast[todayIndex + 1].LowTemp.Actual(settings.Preferences.TemperatureParameter).ToString(),
                                                    Align = TileTextAlign.Auto,
                                                    Style = TileTextStyle.Caption
                                                },
                                                new TileText()
                                                {
                                                     Text = loader.GetString("ScaleText")+": "+model.DailyForecast[todayIndex+1].Wind.Speed.Actual(settings.Preferences.SpeedParameter) +
                                                    model.DailyForecast[todayIndex+1].Wind.Speed.DanWei(settings.Preferences.SpeedParameter),
                                                     Align = TileTextAlign.Auto,
                                                     Style = TileTextStyle.CaptionSubtle,
                                                },
                                                new TileText()
                                                {
                                                     Text = loader.GetString("HumText")+": "+model.DailyForecast[todayIndex+1].Humidity.ToString() + "%",
                                                     Align = TileTextAlign.Auto,
                                                     Style = TileTextStyle.CaptionSubtle,
                                                     Wrap = true
                                                }
                                            }
                                        },
                                                }
                                            }

                            },
                            PeekImage = uri == null ? null : (settings.Preferences.TransparentTile ? null : new TilePeekImage()
                            {
                                Source = new TileImageSource(uri.ToString()),
                            }),
                        }
                    }
                }
            };
            #endregion
            return NowContent;
        }
示例#7
0
        private static TileContent GenerateForecastTile(HeWeatherModel model, bool isNight, Uri uri, string glanceFull, string lockdetial, int todayIndex, CitySettingsModel currentCity, SettingsModel settings)
        {
            var ctosConverter = new ConditiontoTextConverter();
            var ctoiConverter = new ConditiontoImageConverter();
            var forecaset = new TileContent()
            {
                Visual = new TileVisual()
                {
                    DisplayName = currentCity.City,
                    Branding = TileBranding.NameAndLogo,
                    LockDetailedStatus1 = currentCity.City + "  " + model.NowWeather.Temprature.Actual(settings.Preferences.TemperatureParameter) + "\r\n" + lockdetial,
                    TileLarge = new TileBinding()
                    {
                        Content = new TileBindingContentAdaptive()
                        {
                            BackgroundImage = uri == null ? null : (settings.Preferences.TransparentTile ? null : new TileBackgroundImage()
                            {
                                Source = new TileImageSource(uri.ToString()),
                                Overlay = 70
                            }),
                            Children =
                            {
                                new TileText(),
                                new TileGroup()
                                {
                                    Children =
                                    {
                                        new TileSubgroup()
                                        {
                                            Weight = 1,

                                        },
                                        new TileSubgroup()
                                        {
                                            Weight = 1,
                                            Children=
                                            {
                                                new TileText()
                                                {
                                                    Text = model.DailyForecast.Length > todayIndex + 1 ? model.DailyForecast[todayIndex+1].Date.ToString("ddd") : "",
                                                },
                                                new TileImage()
                                                {
                                                    Source = model.DailyForecast.Length > todayIndex + 1 ? new TileImageSource("Assets/Tile/" + (string)ctoiConverter.Convert(isNight?model.DailyForecast[todayIndex+1].Condition.NightCond:model.DailyForecast[todayIndex+1].Condition.DayCond,null,isNight,null)) : new TileImageSource(""),
                                                },
                                            }
                                        },
                                        new TileSubgroup()
                                        {
                                            Weight = 1,
                                            TextStacking = TileTextStacking.Bottom,
                                            Children=
                                            {
                                                new TileText()
                                                {
                                                    Text = model.DailyForecast.Length > todayIndex + 1 ? model.DailyForecast[todayIndex+1].HighTemp.Actual(settings.Preferences.TemperatureParameter) : "",
                                                    Style = TileTextStyle.Caption
                                                },
                                                new TileText()
                                                {
                                                    Text = model.DailyForecast.Length > todayIndex + 1 ? model.DailyForecast[todayIndex+1].LowTemp.Actual(settings.Preferences.TemperatureParameter) : "",
                                                    Style = TileTextStyle.CaptionSubtle
                                                },
                                            }
                                        },

                                        new TileSubgroup()
                                        {
                                            Weight = 1,
                                            Children=
                                            {
                                                new TileText()
                                                {
                                                    Text = model.DailyForecast.Length > todayIndex + 2 ? model.DailyForecast[todayIndex+2].Date.ToString("ddd") : "",
                                                },
                                                new TileImage()
                                                {
                                                    Source = model.DailyForecast.Length > todayIndex + 2 ? new TileImageSource("Assets/Tile/" + (string)ctoiConverter.Convert(isNight?model.DailyForecast[todayIndex+2].Condition.NightCond:model.DailyForecast[todayIndex+2].Condition.DayCond,null,isNight,null)) : new TileImageSource(""),
                                                },
                                            }

                                        },
                                        new TileSubgroup()
                                        {
                                            Weight = 1,
                                            TextStacking = TileTextStacking.Bottom,
                                            Children=
                                            {
                                                new TileText()
                                                {
                                                    Text = model.DailyForecast.Length > todayIndex + 2 ? model.DailyForecast[todayIndex+2].HighTemp.Actual(settings.Preferences.TemperatureParameter) : "",
                                                    Style = TileTextStyle.Caption
                                                },
                                                new TileText()
                                                {
                                                    Text = model.DailyForecast.Length > todayIndex + 2 ? model.DailyForecast[todayIndex+2].LowTemp.Actual(settings.Preferences.TemperatureParameter) : "",
                                                    Style = TileTextStyle.CaptionSubtle
                                                },
                                            }
                                        },
                                        new TileSubgroup()
                                        {
                                            Weight = 1,

                                        },
                                    }
                                },
                                new TileText(),
                                new TileGroup()
                                {
                                    Children =
                                    {
                                        new TileSubgroup()
                                        {
                                            Weight = 1,

                                        },
                                        new TileSubgroup()
                                        {
                                            Weight = 1,
                                            Children=
                                            {
                                                new TileText()
                                                {
                                                    Text = model.DailyForecast.Length > todayIndex + 3 ? model.DailyForecast[todayIndex+3].Date.ToString("ddd") : "",
                                                },
                                                new TileImage()
                                                {
                                                    Source = model.DailyForecast.Length > todayIndex + 3 ? new TileImageSource("Assets/Tile/" + (string)ctoiConverter.Convert(isNight?model.DailyForecast[todayIndex+3].Condition.NightCond:model.DailyForecast[todayIndex+3].Condition.DayCond,null,isNight,null)) : new TileImageSource(""),
                                                },
                                            }
                                        },
                                        new TileSubgroup()
                                        {
                                            Weight = 1,
                                            TextStacking = TileTextStacking.Bottom,
                                            Children=
                                            {
                                                new TileText()
                                                {
                                                    Text = model.DailyForecast.Length > todayIndex + 3 ? model.DailyForecast[todayIndex+3].HighTemp.Actual(settings.Preferences.TemperatureParameter) : "",
                                                    Style = TileTextStyle.Caption
                                                },
                                                new TileText()
                                                {
                                                    Text = model.DailyForecast.Length > todayIndex + 3 ? model.DailyForecast[todayIndex+3].LowTemp.Actual(settings.Preferences.TemperatureParameter) : "",
                                                    Style = TileTextStyle.CaptionSubtle
                                                },
                                            }
                                        },

                                        new TileSubgroup()
                                        {
                                            Weight = 1,
                                            Children=
                                            {
                                                new TileText()
                                                {
                                                    Text = model.DailyForecast.Length > todayIndex + 4 ? model.DailyForecast[todayIndex+4].Date.ToString("ddd") : "",

                                                },
                                                new TileImage()
                                                {
                                                    Source = model.DailyForecast.Length > todayIndex + 4 ?  new TileImageSource("Assets/Tile/" + (string)ctoiConverter.Convert(isNight ? model.DailyForecast[todayIndex+4].Condition.NightCond : model.DailyForecast[todayIndex+4].Condition.DayCond, null, isNight, null)) : new TileImageSource(""),
                                                },
                                            }

                                        },
                                        new TileSubgroup()
                                        {
                                            Weight = 1,
                                            TextStacking = TileTextStacking.Bottom,
                                            Children=
                                            {
                                                new TileText()
                                                {
                                                    Text = model.DailyForecast.Length > todayIndex + 4 ? model.DailyForecast[todayIndex+4].HighTemp.Actual(settings.Preferences.TemperatureParameter) : "",
                                                    Style = TileTextStyle.Caption
                                                },
                                                new TileText()
                                                {
                                                    Text = model.DailyForecast.Length > todayIndex + 4 ? model.DailyForecast[todayIndex+4].LowTemp.Actual(settings.Preferences.TemperatureParameter) : "",
                                                    Style = TileTextStyle.CaptionSubtle
                                                },
                                            }
                                        },
                                        new TileSubgroup()
                                        {
                                            Weight = 1,

                                        },
                                    }
                                }
                            }
                        }
                    },
                    TileMedium = new TileBinding()
                    {
                        Content = new TileBindingContentAdaptive()
                        {
                            BackgroundImage = uri == null ? null : (settings.Preferences.TransparentTile ? null : new TileBackgroundImage()
                            {
                                Source = new TileImageSource(uri.ToString()),
                                Overlay = 70
                            }),
                            Children =
                            {
                                new TileText()
                                {

                                },
                                new TileText()
                                {
                                    Text = model.DailyForecast.Length > todayIndex + 1 ? model.DailyForecast[todayIndex+1].Date.ToString("ddd") : "",
                                    Align = TileTextAlign.Center
                                },
                                 new TileText()
                                                {
                                                    Text = model.DailyForecast.Length > todayIndex + 1 ? model.DailyForecast[todayIndex+1].HighTemp.Actual(settings.Preferences.TemperatureParameter) : "",
                                                    Style = TileTextStyle.Caption
                                                },
                                                new TileText()
                                                {
                                                    Text = model.DailyForecast.Length > todayIndex + 1 ? model.DailyForecast[todayIndex+1].LowTemp.Actual(settings.Preferences.TemperatureParameter) : "",
                                                    Style = TileTextStyle.CaptionSubtle
                                                },
                            }
                        }
                    },
                    TileWide = new TileBinding()
                    {

                        Content = new TileBindingContentAdaptive()
                        {
                            BackgroundImage = uri == null ? null : (settings.Preferences.TransparentTile ? null : new TileBackgroundImage()
                            {
                                Source = new TileImageSource(uri.ToString()),
                                Overlay = 70
                            }),
                            Children =
                            {
                                new TileGroup()
                                {
                                    Children =
                                    {
                                        new TileSubgroup()
                                        {
                                            Weight = 1,
                                            Children =
                                            {
                                                new TileText()
                                                {
                                                    Text = model.DailyForecast.Length > todayIndex + 1 ? model.DailyForecast[todayIndex+1].Date.ToString("ddd") : "",

                                                },
                                                new TileImage()
                                                {
                                                    Source = model.DailyForecast.Length > todayIndex + 1 ?  new TileImageSource("Assets/Tile/" + (string)ctoiConverter.Convert(isNight ? model.DailyForecast[todayIndex+1].Condition.NightCond : model.DailyForecast[todayIndex+1].Condition.DayCond, null, isNight, null)) : new TileImageSource(""),
                                                },
                                            }
                                        },
                                        new TileSubgroup()
                                        {
                                            Weight = 1,
                                            TextStacking = TileTextStacking.Bottom,
                                            Children =
                                            {
                                                new TileText()
                                                {
                                                    Text = model.DailyForecast.Length > todayIndex + 1 ? model.DailyForecast[todayIndex+1].HighTemp.Actual(settings.Preferences.TemperatureParameter) : "",
                                                    Style = TileTextStyle.Caption
                                                },
                                                new TileText()
                                                {
                                                    Text = model.DailyForecast.Length > todayIndex + 1 ? model.DailyForecast[todayIndex+1].LowTemp.Actual(settings.Preferences.TemperatureParameter) : "",
                                                    Style = TileTextStyle.CaptionSubtle
                                                },
                                            }
                                        },
                                       new TileSubgroup()
                                        {
                                            Weight = 1,
                                            Children =
                                            {
                                                new TileText()
                                                {
                                                    Text = model.DailyForecast.Length > todayIndex + 2 ? model.DailyForecast[todayIndex+2].Date.ToString("ddd") : "",

                                                },
                                                new TileImage()
                                                {
                                                    Source = model.DailyForecast.Length > todayIndex + 2 ?  new TileImageSource("Assets/Tile/" + (string)ctoiConverter.Convert(isNight ? model.DailyForecast[todayIndex+2].Condition.NightCond : model.DailyForecast[todayIndex+2].Condition.DayCond, null, isNight, null)) : new TileImageSource(""),
                                                },
                                            }
                                        },
                                        new TileSubgroup()
                                        {
                                            Weight = 1,
                                            TextStacking = TileTextStacking.Bottom,
                                            Children =
                                            {
                                                new TileText()
                                                {
                                                    Text = model.DailyForecast.Length > todayIndex + 2 ? model.DailyForecast[todayIndex+2].HighTemp.Actual(settings.Preferences.TemperatureParameter) : "",
                                                    Style = TileTextStyle.Caption
                                                },
                                                new TileText()
                                                {
                                                    Text = model.DailyForecast.Length > todayIndex + 2 ? model.DailyForecast[todayIndex+2].LowTemp.Actual(settings.Preferences.TemperatureParameter) : "",
                                                    Style = TileTextStyle.CaptionSubtle
                                                },
                                            }
                                        },
                                        new TileSubgroup()
                                        {
                                            Weight = 1,
                                            Children =
                                            {
                                                new TileText()
                                                {
                                                    Text = model.DailyForecast.Length > todayIndex + 3 ? model.DailyForecast[todayIndex+3].Date.ToString("ddd") : "",

                                                },
                                                new TileImage()
                                                {
                                                    Source = model.DailyForecast.Length > todayIndex + 3 ?  new TileImageSource("Assets/Tile/" + (string)ctoiConverter.Convert(isNight ? model.DailyForecast[todayIndex+3].Condition.NightCond : model.DailyForecast[todayIndex+3].Condition.DayCond, null, isNight, null)) : new TileImageSource(""),
                                                },
                                            }
                                        },
                                        new TileSubgroup()
                                        {
                                            Weight = 1,
                                            TextStacking = TileTextStacking.Bottom,
                                            Children =
                                            {
                                                new TileText()
                                                {
                                                    Text = model.DailyForecast.Length > todayIndex + 3 ? model.DailyForecast[todayIndex+3].HighTemp.Actual(settings.Preferences.TemperatureParameter) : "",
                                                    Style = TileTextStyle.Caption
                                                },
                                                new TileText()
                                                {
                                                    Text = model.DailyForecast.Length > todayIndex + 3 ? model.DailyForecast[todayIndex+3].LowTemp.Actual(settings.Preferences.TemperatureParameter) : "",
                                                    Style = TileTextStyle.CaptionSubtle
                                                },
                                            }
                                        },
                                    }
                                },
                            }
                        }
                    }
                }
            };
            return forecaset;
        }
示例#8
0
        public static async Task<List<TileContent>> CreateAll(CitySettingsModel currentCity, HeWeatherModel model, DateTime desiredDateTimeinThatRegion)
        {
            var todayIndex = Array.FindIndex(model.DailyForecast, x =>
            {
                return x.Date.Date == desiredDateTimeinThatRegion.Date;
            });
            var hourIndex = Array.FindIndex(model.HourlyForecast, x =>
            {
                return (x.DateTime - desiredDateTimeinThatRegion).TotalSeconds > 0;
            });
            if (desiredDateTimeinThatRegion.Hour < 7)
            {
                todayIndex--;
            }
            if (todayIndex < 0)
            {
                todayIndex = 0;
            }
            if (hourIndex < 0)
            {
                hourIndex = 0;
            }
            var sunRise = model.DailyForecast[todayIndex].SunRise;
            var sunSet = model.DailyForecast[todayIndex].SunSet;
            var currentTime = desiredDateTimeinThatRegion;

            var settings = SettingsModel.Current;
            var isNight = CalcIsNight(currentTime, sunRise, sunSet, new Models.Location(currentCity.Latitude, currentCity.Longitude));
            Uri uri = await settings.Immersive.GetCurrentBackgroundAsync(model.NowWeather.Now.Condition, isNight);

            var glance = Glance.GenerateShortDescription(model, isNight);
            var glanceFull = Glance.GenerateGlanceDescription(model, isNight, settings.Preferences.TemperatureParameter, desiredDateTimeinThatRegion);
            var lockdetial = Glance.GenerateLockDetailDescription(model, isNight, settings.Preferences.TemperatureParameter, desiredDateTimeinThatRegion);
            var noramlTile = GenerateNormalTile(model, isNight, glance, glanceFull, uri, todayIndex, currentCity, settings);
            var nowTile = GenerateNowTile(model, isNight, uri, glanceFull, lockdetial, todayIndex, currentCity, settings);
            var forecastTile = GenerateForecastTile(model, isNight, uri, glanceFull, lockdetial, todayIndex, currentCity, settings);
            var list = new List<TileContent>();
            list.Add(nowTile);
            list.Add(noramlTile);
            list.Add(forecastTile);
            return list;
        }
示例#9
0
        public static async Task<XmlDocument> CreateToast(HeWeatherModel model, CitySettingsModel currentCity, SettingsModel settings, DateTime DueTime)
        {
            var glance = Glance.GenerateGlanceDescription(model, false, settings.Preferences.TemperatureParameter, DueTime);
            var ctos = new ConditiontoTextConverter();

            var dueIndex = Array.FindIndex(model.DailyForecast, x =>
            {
                return x.Date.Date == DueTime.Date;
            });
            var uri = await settings.Immersive.GetCurrentBackgroundAsync(model.DailyForecast[dueIndex].Condition.DayCond, false);
            var loader = new ResourceLoader();
            var toast = new ToastContent()
            {
                Scenario = ToastScenario.Default,
                ActivationType = ToastActivationType.Foreground,
                Duration = ToastDuration.Long,
                Launch = currentCity.Id,
                Visual = new ToastVisual()
                {
                    TitleText = new ToastText()
                    {
                        Text = string.Format(loader.GetString("Today_Weather"), currentCity.City)
                    },
                    BodyTextLine1 = new ToastText()
                    {
                        Text = ctos.Convert(model.DailyForecast[dueIndex].Condition.DayCond, null, null, null) + ", "
                        + ((model.DailyForecast[dueIndex].HighTemp + model.DailyForecast[dueIndex].LowTemp) / 2).Actual(settings.Preferences.TemperatureParameter)
                    },
                    BodyTextLine2 = new ToastText()
                    {
                        Text = glance
                    },
                }
            };
            var xml = toast.GetXml();
            var e = xml.CreateElement("image");
            e.SetAttribute("placement", "hero");
            e.SetAttribute("src", uri.AbsoluteUri);
            var b = xml.GetElementsByTagName("binding");
            b.Item(0).AppendChild(e);
            return xml;
        }
示例#10
0
        private static TileContent GenerateNowTile(HeWeatherModel model, bool isNight, Uri uri, string glanceFull, string lockdetial, int todayIndex, CitySettingsModel currentCity, SettingsModel settings)
        {
            var ctosConverter = new ConditiontoTextConverter();
            var ctoiConverter = new ConditiontoImageConverter();
            var loader = new ResourceLoader();
            var now = new TileContent()
            {
                Visual = new TileVisual()
                {
                    LockDetailedStatus1 = currentCity.City + "  " + model.NowWeather.Temprature.Actual(settings.Preferences.TemperatureParameter) + "\r\n" + lockdetial,
                    DisplayName = currentCity.City,
                    Branding = TileBranding.NameAndLogo,
                    TileMedium = new TileBinding()
                    {
                        Content = new TileBindingContentAdaptive()
                        {
                            BackgroundImage = uri == null ? null : (settings.Preferences.TransparentTile ? null : new TileBackgroundImage()
                            {
                                Source = new TileImageSource(uri.ToString()),
                                Overlay = 70
                            }),
                            Children =
                            {
                                new TileText(),
                                new TileGroup()
                                {
                                    Children =
                                    {
                                        new TileSubgroup()
                                        {
                                            Weight = 1,
                                        },
                                        new TileSubgroup()
                                        {
                                            Weight = 1,
                                            Children =
                                            {
                                                new TileImage()
                                                {
                                                    Source = new TileImageSource("Assets/Tile/" + (string)ctoiConverter.Convert(model.NowWeather.Now.Condition,null,isNight,null)),
                                                },
                                            }
                                        },
                                        new TileSubgroup()
                                        {
                                            Weight = 1,
                                        }
                                    }
                                },
                                new TileText()
                                {
                                    Text = model.NowWeather.Temprature.Actual(settings.Preferences.TemperatureParameter),
                                    Style = TileTextStyle.Body,
                                    Align = TileTextAlign.Center
                                }
                            }
                        },
                    },
                    TileLarge = new TileBinding()
                    {
                        Content = new TileBindingContentAdaptive()
                        {
                            BackgroundImage = uri == null ? null : (settings.Preferences.TransparentTile ? null : new TileBackgroundImage()
                            {
                                Source = new TileImageSource(uri.ToString()),
                                Overlay = 70
                            }),
                            Children =
                            {
                                new TileText(),
                                new TileGroup()
                                {
                                    Children =
                                    {
                                        new TileSubgroup()
                                        {
                                            Weight = 3,
                                        },
                                        new TileSubgroup()
                                        {
                                            Weight = 2,
                                            Children =
                                            {
                                                new TileImage()
                                                {
                                                    Source = new TileImageSource("Assets/Tile/" + (string)ctoiConverter.Convert(model.NowWeather.Now.Condition,null,isNight,null)),
                                                },
                                            }
                                        },
                                        new TileSubgroup()
                                        {
                                            Weight = 3,
                                        }
                                    }
                                },
                                new TileText()
                                {
                                    Text = model.NowWeather.Temprature.Actual(settings.Preferences.TemperatureParameter),
                                    Style = TileTextStyle.Subheader,
                                    Align = TileTextAlign.Center
                                },
                                new TileText()
                                {
                                    Text = glanceFull,
                                    Align = TileTextAlign.Center,
                                    Style = TileTextStyle.CaptionSubtle,
                                    Wrap = true
                                }
                            }
                        }
                    },
                    TileSmall = new TileBinding()
                    {
                        Content = new TileBindingContentAdaptive()
                        {
                            TextStacking = TileTextStacking.Center,
                            Children =
                            {
                                new TileText()
                                {
                                    Text = model.NowWeather.Temprature.Actual(settings.Preferences.TemperatureParameter),
                                    Align = TileTextAlign.Center,
                                    Style = TileTextStyle.Body
                                }
                            }
                        }
                    },
                    TileWide = new TileBinding()
                    {
                        DisplayName = currentCity.City,
                        Branding = TileBranding.NameAndLogo,
                        Content = new TileBindingContentAdaptive()
                        {
                            BackgroundImage = uri == null ? null : (settings.Preferences.TransparentTile ? null : new TileBackgroundImage()
                            {
                                Source = new TileImageSource(uri.ToString()),
                                Overlay = 70
                            }),
                            Children =
                                       {
                                new TileGroup()
                                {
                                    Children=
                                    {
                                        new TileSubgroup()
                                        {
                                            Weight = 1,
                                            Children =
                                            {
                                                new TileText()
                                                {
                                                    Text = model.DailyForecast[todayIndex+1].Date.ToString("ddd"),
                                                    Align = TileTextAlign.Center,
                                                    Style = TileTextStyle.Caption
                                                },
                                                new TileImage()
                                                {
                                                    Source = new TileImageSource("Assets/Tile/" + (string)ctoiConverter.Convert(model.DailyForecast[todayIndex+1].Condition.DayCond,null,isNight,null))
                                                },
                                                new TileText()
                                                {
                                                    Align = TileTextAlign.Center,
                                                    Style = TileTextStyle.Caption
                                                },
                                            }
                                        },
                                        new TileSubgroup()
                                        {
                                            Weight = 2,
                                            TextStacking = TileTextStacking.Center,
                                            Children =
                                            {
                                                new TileText()
                                                {
                                                    Style = TileTextStyle.CaptionSubtle,
                                                    Align = TileTextAlign.Center
                                                },
                                                new TileText()
                                                {
                                                    Text = (string)ctosConverter.Convert(model.DailyForecast[todayIndex+1].Condition.DayCond,null,null,null),
                                                    Align = TileTextAlign.Center,
                                                    Style = TileTextStyle.Caption
                                                },

                                                new TileText()
                                                {
                                                    Text = model.DailyForecast[todayIndex+1].HighTemp.Actual(settings.Preferences.TemperatureParameter).ToString(),
                                                    Align = TileTextAlign.Center,
                                                    Style = TileTextStyle.Caption
                                                },
                                                new TileText()
                                                {
                                                    Text = model.DailyForecast[todayIndex+1].LowTemp.Actual(settings.Preferences.TemperatureParameter).ToString(),
                                                    Style = TileTextStyle.CaptionSubtle,
                                                    Align = TileTextAlign.Center
                                                }
                                            }
                                        },
                                        new TileSubgroup()
                                        {
                                            Weight = 1,
                                            Children =
                                            {
                                                new TileText()
                                                {
                                                    Align = TileTextAlign.Center,
                                                    Style = TileTextStyle.CaptionSubtle
                                                },
                                                new TileText()
                                                {
                                                    Text = loader.GetString("ScaleText"),
                                                    Align = TileTextAlign.Center,
                                                    Style = TileTextStyle.CaptionSubtle
                                                },
                                                new TileText()
                                                {
                                                    Align = TileTextAlign.Center,
                                                    Style = TileTextStyle.CaptionSubtle
                                                },
                                                new TileText()
                                                {
                                                    Text = loader.GetString("HumText"),
                                                    Align = TileTextAlign.Center,
                                                    Style = TileTextStyle.CaptionSubtle
                                                },
                                            }
                                        },
                                        new TileSubgroup()
                                        {
                                            Weight = 2,
                                            TextStacking = TileTextStacking.Center,
                                            Children =
                                            {
                                                new TileText()
                                                {

                                                    Style = TileTextStyle.CaptionSubtle,
                                                    Align = TileTextAlign.Left
                                                },
                                                new TileText()
                                                {
                                                    Text = model.DailyForecast[todayIndex+1].Wind.Speed.Actual(settings.Preferences.SpeedParameter) +
                                                    model.NowWeather.Wind.Speed.DanWei(settings.Preferences.SpeedParameter),
                                                    Align = TileTextAlign.Left,
                                                    Style = TileTextStyle.Caption
                                                },
                                                new TileText()
                                                {

                                                    Style = TileTextStyle.CaptionSubtle,
                                                    Align = TileTextAlign.Left
                                                },
                                                new TileText()
                                                {
                                                    Text = model.DailyForecast[todayIndex+1].Humidity.ToString() + "%",
                                                    Align = TileTextAlign.Left,
                                                    Style = TileTextStyle.Caption
                                                },
                                            }
                                        },
                                    }
                                }
                                       },
                        }
                    },
                }
            };
            return now;
        }
示例#11
0
 public static ToastContent CreateAlarmToast(string[] str, CitySettingsModel currentCityModel)
 {
     var lo = new ResourceLoader();
     var action = new ToastActionsCustom();
     var button = new ToastButton(lo.GetString("Known"), "Today_Alarm_Dismiss");
     button.ActivationType = ToastActivationType.Background;
     action.Buttons.Add(button);
     action.Buttons.Add(new ToastButtonDismiss(lo.GetString("Okay")));
     ToastContent t = new ToastContent()
     {
         Scenario = ToastScenario.Reminder,
         Launch = currentCityModel.Id,
         Actions = action,
         Visual = new ToastVisual()
         {
             TitleText = new ToastText()
             {
                 Text = str[0]
             },
             BodyTextLine1 = new ToastText()
             {
                 Text = str[1]
             }
         }
     };
     return t;
 }
 private void ReadSettings()
 {
     settings = SettingsModel.Current;
     currentCityModel = settings.Cities.GetCurrentCity();
     InitialConverterParameter(settings);
 }
        private async Task Init(SettingsModel settings, CitySettingsModel currentCity)
        {
            string resstr = await Request.GetRequestAsync(settings, currentCity);
            if (!resstr.IsNullorEmpty())
            {
                var fetchresult = HeWeatherModel.Generate(resstr, settings.Preferences.DataSource);
                if (fetchresult == null || fetchresult.DailyForecast == null || fetchresult.HourlyForecast == null)
                {
                    return;
                }
                var utcOffset = fetchresult.Location.UpdateTime - fetchresult.Location.UtcTime;
                var current = DateTimeHelper.ReviseLoc(utcOffset);
                try
                {
                    Sender.CreateMainTileQueue(await Generator.CreateAll(currentCity, fetchresult, current));
                }
                catch (Exception)
                {

                }

                try
                {
                    if (UserProfilePersonalizationSettings.IsSupported() && settings.Preferences.SetWallPaper)
                    {
                        var todayIndex = Array.FindIndex(fetchresult.DailyForecast, x =>
                        {
                            return x.Date.Date == current.Date;
                        });
                        if (current.Hour <= 7)
                        {
                            todayIndex--;
                        }
                        if (todayIndex < 0)
                        {
                            todayIndex = 0;
                        }
                        TimeSpan sunRise, sunSet;
                        if (fetchresult.DailyForecast[todayIndex].SunRise == default(TimeSpan) || fetchresult.DailyForecast[todayIndex].SunSet == default(TimeSpan))
                        {
                            sunRise = Core.LunarCalendar.SunRiseSet.GetRise(new Models.Location(currentCity.Latitude, currentCity.Longitude), current);
                            sunSet = Core.LunarCalendar.SunRiseSet.GetSet(new Models.Location(currentCity.Latitude, currentCity.Longitude), current);
                        }
                        else
                        {
                            sunRise = fetchresult.DailyForecast[todayIndex].SunRise;
                            sunSet = fetchresult.DailyForecast[todayIndex].SunSet;
                        }
                        var file = await FileIOHelper.GetFilebyUriAsync(await settings.Immersive.GetCurrentBackgroundAsync(fetchresult.NowWeather.Now.Condition, WeatherModel.CalculateIsNight(current, sunRise, sunSet)));
                        var lFile = await FileIOHelper.CreateWallPaperFileAsync(Guid.NewGuid().ToString() + ".png");
                        var d = PointerDevice.GetPointerDevices();
                        var m = d.ToArray();
                        var scaleFactor = DisplayInformation.GetForCurrentView().RawPixelsPerViewPixel;
                        var size = new Size(m[0].PhysicalDeviceRect.Width, m[0].PhysicalDeviceRect.Height);
                        var ratio = size.Height / size.Width;
                        var cropSize = new Size();
                        double scale;
                        var startPoint = new Point();
                        using (var stream = await file.OpenReadAsync())
                        {
                            var bitmap = new BitmapImage();
                            await bitmap.SetSourceAsync(stream);
                            var width = bitmap.PixelWidth;
                            var height = bitmap.PixelHeight;
                            var center = new Point(width / 2, height / 2);
                            if (width * ratio >= height)
                            {
                                cropSize.Width = height / ratio;
                                cropSize.Height = height;
                                scale = size.Height / height;
                            }
                            else
                            {
                                cropSize.Width = width;
                                cropSize.Height = width * ratio;
                                scale = size.Width / width;
                            }

                            startPoint.X = center.X - cropSize.Width / 2;
                            startPoint.Y = center.Y - cropSize.Height / 2;
                        }
                        await ImagingHelper.CropandScaleAsync(file, lFile, startPoint, cropSize, scale);
                        var uc = await ImagingHelper.SetWallpaperAsync(lFile);
                    }
                }
                catch (Exception)
                {
                }

                if (settings.Preferences.EnableMorning)
                {
                    var shu1 = settings.Preferences.MorningNoteTime.TotalHours;

                    var tomorrow8 = DateTime.Now.Hour > shu1 ? (DateTime.Today.AddDays(1)).AddHours(shu1) : (DateTime.Today.AddHours(shu1));

                    try
                    {
                        Sender.CreateScheduledToastNotification(await (Generator.CreateToast(fetchresult, currentCity, settings, DateTimeHelper.ReviseLoc(tomorrow8, utcOffset))), tomorrow8, "MorningToast");
                    }
                    catch (Exception)
                    {

                    }
                }
                if (settings.Preferences.EnableEvening)
                {
                    var shu2 = settings.Preferences.EveningNoteTime.TotalHours;
                    var tomorrow20 = DateTime.Now.Hour > shu2 ? (DateTime.Today.AddDays(1)).AddHours(shu2) : (DateTime.Today.AddHours(shu2));
                    try
                    {
                        Sender.CreateScheduledToastNotification(await (Generator.CreateToast(fetchresult, currentCity, settings, DateTimeHelper.ReviseLoc(tomorrow20, utcOffset))), tomorrow20, "EveningToast");
                    }
                    catch (Exception)
                    {

                    }
                }
                if (settings.Preferences.EnableAlarm)
                {
                    if (!fetchresult.Alarms.IsNullorEmpty() && (DateTime.Now - settings.Preferences.LastAlertTime).TotalDays > 1)
                    {
                        Sender.CreateBadge(Generator.GenerateAlertBadge());
                        Sender.CreateToast(Generator.CreateAlertToast(fetchresult, currentCity).GetXml());
                    }
                    else
                    {
                        Sender.ClearBadge();
                    }
                    var str = Generator.CalculateWeatherAlarm(fetchresult, currentCity, settings, DateTimeHelper.ReviseLoc(DateTime.Now, utcOffset));
                    if (!str.IsNullorEmpty() && str.Length > 1 && (DateTime.Now - settings.Preferences.LastAlarmTime).TotalDays > 1)
                    {
                        Sender.CreateToast(Generator.CreateAlarmToast(str, currentCity).GetXml());
                    }
                }
                await settings.Cities.SaveDataAsync(currentCity.Id, resstr, settings.Preferences.DataSource);
                currentCity.Update();
                if (settings.Cities.CurrentIndex != -1)
                {
                    settings.Cities.SavedCities[settings.Cities.CurrentIndex] = currentCity;
                }
                else
                {
                    settings.Cities.LocatedCity = currentCity;
                }
                settings.Cities.Save();
            }
        }
示例#14
0
 public void ChangeRoute(LocateRoute[] locateRoute, City city)
 {
     this.Routes = locateRoute;
     LocatedCity = new CitySettingsModel(city);
 }
        private async void SendWeatherForecastIn(CitySettingsModel where)
        {
            // Take action and determine when the next trip to destination
            // Insert code here.

            // Replace the hardcoded strings used here with strings 
            // appropriate for your application.

            // First, create the VoiceCommandUserMessage with the strings 
            // that Cortana will show and speak.
            var userMessage = new VoiceCommandUserMessage();
            userMessage.DisplayMessage = where.City + "的天气状况:";
            userMessage.SpokenMessage = "这是" + where.City + "的天气状况";

            // Optionally, present visual information about the answer.
            // For this example, create a VoiceCommandContentTile with an 
            // icon and a string.
            var destinationsContentTiles = new List<VoiceCommandContentTile>();

            var destinationTile = new VoiceCommandContentTile();
            destinationTile.ContentTileType = VoiceCommandContentTileType.TitleWithText;
            // The user can tap on the visual content to launch the app. 
            // Pass in a launch argument to enable the app to deep link to a 
            // page relevant to the item displayed on the content tile.
            destinationTile.AppLaunchArgument = where.Id;
            destinationTile.Title = where.City;
            destinationTile.TextLine1 = "August 3rd 2015";
            destinationsContentTiles.Add(destinationTile);

            // Create the VoiceCommandResponse from the userMessage and list    
            // of content tiles.
            var response = VoiceCommandResponse.CreateResponse(userMessage, destinationsContentTiles);

            // Cortana will present a “Go to app_name” link that the user 
            // can tap to launch the app. 
            // Pass in a launch to enable the app to deep link to a page 
            // relevant to the voice command.
            response.AppLaunchArgument = where.Id;

            // Ask Cortana to display the user message and content tile and 
            // also speak the user message.
            await voiceServiceConnection.ReportSuccessAsync(response);
        }
 private void SendTemperatureIn(CitySettingsModel where)
 {
     throw new NotImplementedException();
 }