private async void Context_FetchDataComplete(object sender, FetchDataCompleteEventArgs e)
 {
     await Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.High, new Windows.UI.Core.DispatchedHandler(async () =>
     {
         LocateOnSwitch.IsEnabled = true;
         LocateOnSwitch.IsEnabled = true;
         await AccesstoLocate();
     }));
 }
 private async void Context_FetchDataComplete(object sender, FetchDataCompleteEventArgs e)
 {
     await Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.High, new Windows.UI.Core.DispatchedHandler(async () =>
     {
         LocateOnSwitch.Toggled += LocateOnSwitch_Toggled;
         SearchBox.TextChanged += SearchBox_TextChanged;
         //SearchBox.SuggestionChosen += SearchBox_SuggestionChosen;
         SearchBox.QuerySubmitted += SearchBox_QuerySubmitted;
         SearchBox.IsEnabled = true;
         LocateOnSwitch.IsEnabled = true;
         FetchComplete.Begin();
         CitiesList.ItemsSource = Context.Info;
         await AccesstoLocate();
     }));
 }
        private async void MModel_FetchDataComplete(object sender, FetchDataCompleteEventArgs e)
        {
            var loader = new ResourceLoader();
            UpdateIndText.Text = loader.GetString("RefreshComplete");
            LoadingDot.IsActive = false;
            Forecast0.SetCondition(Context.Forecast0, Context.IsNight);
            Forecast1.SetCondition(Context.Forecast1, Context.IsNight);
            Forecast2.SetCondition(Context.Forecast2, Context.IsNight);
            Forecast3.SetCondition(Context.Forecast3, Context.IsNight);
            Forecast4.SetCondition(Context.Forecast4, Context.IsNight);
            if ((Context.Condition == WeatherCondition.sunny) || (Context.Condition == WeatherCondition.windy)
                || (Context.Condition == WeatherCondition.calm) ||
                (Context.Condition == WeatherCondition.light_breeze) ||
                (Context.Condition == WeatherCondition.moderate) ||
                (Context.Condition == WeatherCondition.fresh_breeze) ||
                (Context.Condition == WeatherCondition.strong_breeze) ||
                (Context.Condition == WeatherCondition.high_wind) ||
                (Context.Condition == WeatherCondition.gale))
            {
                if (!Context.IsNight)
                {
                    var s = new SolidColorBrush(Colors.Black);
                    baba.ChangeColor(s);
                    RefreshButton.Foreground = s;
                }
                else
                {
                    baba.ChangeColor(new SolidColorBrush(Colors.White));
                    RefreshButton.Foreground = new SolidColorBrush(Colors.White);
                }
            }
            else
            {
                baba.ChangeColor(new SolidColorBrush(Colors.White));
                RefreshButton.Foreground = new SolidColorBrush(Colors.White);
            }
            WeatherCanvas.ChangeCondition(Context.Condition, Context.IsNight, Context.IsSummer);
            if (Context.Aqi == null)
            {
                AQIPanel.Visibility = Visibility.Collapsed;
            }
            if (Context.Comf == null && Context.Cw == null && Context.Drsg == null)
            {
                SuggestionPanel.Visibility = Visibility.Collapsed;
            }
            switch (Context.source)
            {
                case DataSource.HeWeather:
                    DataSourceImage.Source = new BitmapImage(new Uri("http://heweather.com/weather/images/logo.jpg"));
                    DataSourceContent.Text = loader.GetString("HeWeather");
                    break;
                case DataSource.Caiyun:
                    DataSourceImage.Source = new BitmapImage(new Uri("ms-appx:///Assets/Logos/Caiyun.png"));
                    DataSourceContent.Text = loader.GetString("CaiyunWeather");
                    break;
                case DataSource.Wunderground:
                    DataSourceImage.Source = new BitmapImage(new Uri("ms-appx:///Assets/Logos/Wunder.png"));
                    DataSourceContent.Text = string.Empty;
                    break;
                default:
                    break;
            }
            baba.ChangeCondition(Context.Condition, Context.IsNight, Context.City, Context.NowL, Context.NowH);
            ScrollableRoot.RefreshComplete();
            if(LoadingDot.Visibility == Visibility.Collapsed)
            {
                TempraturePathAnimation.Completed += (s, v) =>
                {
                    RefreshCompleteAni.Begin();
                };
                TempraturePathAnimation.Begin();
                AQIAni.Begin();
                DetailGrid0Play();
                DetailGrid1Play();
                DetailGrid2Play();
                DetailGrid3Play();
                DetailGrid4Play();
                DetailGrid6Play();
                DetailGrid7Play();
            }

            try
            {
                if (Windows.System.UserProfile.UserProfilePersonalizationSettings.IsSupported() && Context.SetWallPaper)
                {
                    var file = await FileIOHelper.GetFilebyUriAsync(await Context.GetCurrentBackgroundAsync());
                    var lFile = await FileIOHelper.CreateWallPaperFileAsync(Guid.NewGuid().ToString() + ".png");
                    var d = Windows.Devices.Input.PointerDevice.GetPointerDevices();
                    var m = d.ToArray();
                    var scaleFactor = Windows.Graphics.Display.DisplayInformation.GetForCurrentView().RawPixelsPerViewPixel;
                    var size = new Size(m[0].PhysicalDeviceRect.Width, m[0].PhysicalDeviceRect.Height);
                    var ratio = size.Height / size.Width;
                    size.Height *= scaleFactor;
                    size.Width *= scaleFactor;
                    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)
            {
            }

        }
예제 #4
0
 private void Context_FetchDataCompleted(object sender, ViewModels.Events.FetchDataCompleteEventArgs e)
 {
 }
 private void Context_LocateComplete(object sender, FetchDataCompleteEventArgs e)
 {
     LocatingOut.Begin();
     updated = true;
 }
 private void Context_LocateComplete(object sender, FetchDataCompleteEventArgs e)
 {
     updated = true;
 }
        private void Context_FetchDataComplete(object sender, FetchDataCompleteEventArgs e)
        {
            var task = Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.High, new Windows.UI.Core.DispatchedHandler(() =>
               {
                   Temp.ItemsSource = Context.Temperature;
                   Wind.ItemsSource = Context.Wind;
                   Speed.ItemsSource = Context.Speed;
                   Length.ItemsSource = Context.Length;
                   Pressure.ItemsSource = Context.Pressure;
                   Year.ItemsSource = Context.Year;
                   Month.ItemsSource = Context.Month;
                   Day.ItemsSource = Context.Day;
                   Hour.ItemsSource = Context.Hour;
                   Minute.ItemsSource = Context.Minute;
                   Week.ItemsSource = Context.Week;
                   Theme.ItemsSource = Context.Theme;
                   LanguageBox.ItemsSource = Context.Languages;

                   Temp.SelectedIndex = Context.Temperature.SelectedIndex;
                   Wind.SelectedIndex = Context.Wind.SelectedIndex;
                   Speed.SelectedIndex = Context.Speed.SelectedIndex;
                   Length.SelectedIndex = Context.Length.SelectedIndex;
                   Pressure.SelectedIndex = Context.Pressure.SelectedIndex;
                   Year.SelectedIndex = Context.Year.SelectedIndex;
                   Hour.SelectedIndex = Context.Hour.SelectedIndex;
                   Month.SelectedIndex = Context.Month.SelectedIndex;
                   Day.SelectedIndex = Context.Day.SelectedIndex;
                   Minute.SelectedIndex = Context.Minute.SelectedIndex;
                   Week.SelectedIndex = Context.Week.SelectedIndex;
                   Theme.SelectedIndex = Context.Theme.SelectedIndex;
                   RefreshFreqSlider.Value = Context.RefreshFreq;
                   LanguageBox.SelectedIndex = Context.Languages.SelectedIndex;
                   var span = TimeSpan.FromMinutes(Context.RefreshFreq);
                   RefreshFreq.Text = span.TotalHours + " hours";

                   Temp.SelectionChanged += Enum_SelectionChanged;
                   Wind.SelectionChanged += Enum_SelectionChanged;
                   Speed.SelectionChanged += Enum_SelectionChanged;
                   Length.SelectionChanged += Enum_SelectionChanged;
                   Pressure.SelectionChanged += Enum_SelectionChanged;
                   Theme.SelectionChanged += Theme_SelectionChanged;
                   Year.SelectionChanged += Format_SelectionChanged;
                   Month.SelectionChanged += Format_SelectionChanged;
                   Day.SelectionChanged += Format_SelectionChanged;
                   Hour.SelectionChanged += Format_SelectionChanged;
                   Minute.SelectionChanged += Format_SelectionChanged;
                   Week.SelectionChanged += Format_SelectionChanged;
                   LanguageBox.SelectionChanged += Language_SelectionChanged;

                   if (Context.Theme.SelectedIndex == 1)
                   {
                       AutoThemeSwitch.Visibility = Visibility.Visible;
                   }
                   if (Context.Theme.SelectedIndex == 0)
                   {
                       AccentColorGrid.Visibility = Visibility.Visible;
                   }

                   switch ((DataSource)Context.Data[Context.Data.SelectedIndex].Value)
                   {
                       case DataSource.HeWeather:
                           HeWeatherRadio.IsChecked = true;
                           break;
                       case DataSource.Caiyun:
                           CaiyunRadio.IsChecked = true;
                           break;
                       case DataSource.Wunderground:
                           WundergroundRadio.IsChecked = true;
                           break;
                       default:
                           HeWeatherRadio.IsChecked = true;
                           break;
                   }

                   if (!license.IsPurchased)
                   {
                       EnableEveryDay.IsEnabled = false;
                       EnableAlarm.IsEnabled = false;
                       RefreshFreq.Text = "N/A";
                       RefreshFreqSlider.IsEnabled = false;
                       LockText.Visibility = Visibility.Visible;
                       WundergroundRadio.IsEnabled = false;
                       NeedDonation.Visibility = Visibility.Visible;
                       Context.EnableEveryDay = false;
                       Context.EnableAlarm = false;
                       Context.EnableEvening = false;
                       Context.EnableMorning = false;
                       Context.NowPanelHeight = 320;
                       Context.AQIHide = false;
                       Context.DetailsHide = false;
                       Context.ForecastHide = false;
                       Context.SuggestHide = false;
                       CustomLayout.IsEnabled = false;
                   }
                   CaiyunRadio.Checked += CaiyunRadio_Checked;
                   HeWeatherRadio.Checked += HeWeatherRadio_Checked;
                   WundergroundRadio.Checked += WundergroundRadio_Checked;
               }));
        }