private void Context_TimeUpdated(object sender, TimeUpdatedEventArgs e) { detailGridAnimation_FLAG[4] = false; DetailGrid4Play(); baba.ReloadTheme(); if (e.IsDayNightChanged) { 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)) { WeatherCanvas.ChangeCondition(Context.Condition, Context.IsNight, Context.IsSummer); 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); } } } }
private async void LoadingDot_DotFinish(object sender, EventArgs e) { TempraturePathAnimation.Completed += (s, v) => { RefreshCompleteAni.Begin(); }; TempraturePathAnimation.Begin(); AQIAni.Begin(); if (rootIsWideState) { DetailGrid0Play(); DetailGrid1Play(); DetailGrid2Play(); DetailGrid3Play(); DetailGrid4Play(); DetailGrid6Play(); DetailGrid7Play(); } for (int i = 0; i < detailGridAnimation_FLAG.Length; i++) { detailGridAnimation_FLAG[i] = false; } CalcDetailGridPosition(); loaded = true; ScrollableRoot.ViewChanged += ScrollableRoot_ViewChanged; if (Context.AlwaysShowBackground) { WeatherCanvas.ImmersiveIn(await Context.GetCurrentBackgroundAsync()); } LoadingDot.Visibility = Visibility.Collapsed; }
private async void ImmersiveButton_Click(object sender, RoutedEventArgs e) { if (Context.EnableFullScreen) { ApplicationView.GetForCurrentView().TryEnterFullScreenMode(); await Task.Delay(160); } isImmersiveMode = true; MainCanvas.PointerMoved += MainCanvas_PointerMoved; ImmersiveWidthIn.From = MainCanvas.ActualWidth; ImmersiveWidthIn.To = Root.ActualWidth; ImmersiveHeightIn.From = MainCanvas.ActualHeight; ImmersiveHeightIn.To = Root.ActualHeight; UIHelper.ChangeTitlebarButtonColor(Colors.Transparent, Colors.White); Application.Current.Resuming += Current_Resuming; ImmersiveTransAni.Completed += (s, args) => { MainCanvas.Width = double.NaN; MainCanvas.Height = double.NaN; if (Context.ImmersiveTimeout == 0) { if (immersiveTimer != null) { immersiveTimer.Cancel(); } return; } if (immersiveTimer != null) { immersiveTimer.Cancel(); } immersiveTimer = ThreadPoolTimer.CreateTimer(async(task) => { await GotoImmersiveAllin(); }, TimeSpan.FromSeconds(Context.ImmersiveTimeout)); }; ImmersiveTransAni.Begin(); if (fengcheTimer != null) { fengcheTimer.Cancel(); detailGridAnimation_FLAG[1] = false; } await Task.Delay(1000); WeatherCanvas.ImmersiveIn(await Context.GetCurrentBackgroundAsync()); //UserProfilePersonalizationSettings profileSettings = UserProfilePersonalizationSettings.Current; // Only support files stored in local folder }
private void ImmersiveBackButton_Click(object sender, RoutedEventArgs e) { MainCanvas.PointerMoved -= MainCanvas_PointerMoved; if (immersiveTimer != null) { immersiveTimer.Cancel(); immersiveTimer = null; } Window.Current.CoreWindow.PointerCursor = new Windows.UI.Core.CoreCursor(Windows.UI.Core.CoreCursorType.Arrow, 1); ImmersiveHeightBack.From = MainCanvas.ActualHeight; ImmersiveWidthBack.From = MainCanvas.ActualWidth; ImmersiveHeightBack.To = ScrollViewerConverter.WeatherCanvasHeight - ScrollableRoot.VerticalOffset < 160 ? 160 : ScrollViewerConverter.WeatherCanvasHeight - ScrollableRoot.VerticalOffset; ImmersiveWidthBack.To = rootIsWideState ? Root.ActualWidth / 2 : Root.ActualWidth; App.Current.Resuming -= Current_Resuming; ImmersiveBackAni.Completed += (s, args) => { if (isFadeOut) { TempratureOut.Begin(); } Binding HeightBinding = new Binding(); HeightBinding.Source = ScrollableRoot; HeightBinding.Path = new PropertyPath("VerticalOffset"); HeightBinding.Converter = new ScrollViewerConverter(); BindingOperations.SetBinding(MainCanvas, HeightProperty, HeightBinding); MainCanvas.Width = double.NaN; DetailGrid1Play(); }; ImmersiveBackAni.Completed += (s, v) => { ApplicationView.GetForCurrentView().ExitFullScreenMode(); }; ImmersiveBackAni.Begin(); isImmersiveMode = false; WeatherCanvas.ImmersiveOut(!Context.AlwaysShowBackground); }
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) { } }