private void InitializeProtectiveColor() { //배경 색상 브러스 및 카멜레온 효과 스토리보드 생성 LinearGradientBrush gradientBrush = new LinearGradientBrush() { EndPoint = new Point(0.5, 0), StartPoint = new Point(0.5, 1) }; bool useProtectiveColor = (bool)SettingHelper.Get(Constants.CHAMELEON_USE_PROTECTIVE_COLOR); Color beginColor; if (useProtectiveColor) { int index = new Random().Next(0, ColorItem.UintColors.Length - 1); beginColor = ColorItem.ConvertColor(ColorItem.UintColors[index]); } else { beginColor = (SettingHelper.Get(Constants.CHAMELEON_SKIN_BACKGROUND_COLOR) as ColorItem).Color; } double rc = 0.1; GradientStop stop1 = new GradientStop() { Color = (Visibility)Application.Current.Resources["PhoneDarkThemeVisibility"] == Visibility.Visible ? Color.FromArgb((byte)(beginColor.A * 0.8), (byte)(beginColor.R * rc), (byte)(beginColor.G * rc), (byte)(beginColor.B * rc)) : Colors.White, Offset = 1 }; //GradientStop stop2 = new GradientStop() { Color = (Visibility)Application.Current.Resources["PhoneDarkThemeVisibility"] == Visibility.Visible ? Colors.Black : Colors.White, Offset = 0 }; GradientStop stop2 = new GradientStop() { Color = beginColor, Offset = 0 }; //GradientStop stop1 = new GradientStop() { Color = (Visibility)Application.Current.Resources["PhoneDarkThemeVisibility"] == Visibility.Visible ? Colors.Black : Colors.White, Offset = 0 }; //GradientStop stop2 = new GradientStop() { Color = initColor, Offset = 1 }; gradientBrush.GradientStops.Add(stop1); gradientBrush.GradientStops.Add(stop2); PanoramaMainView.Background = gradientBrush; /* * // * // Animate the first gradient stop's offset from * // 0.0 to 1.0 and then back to 0.0. * // * DoubleAnimation offsetAnimation = new DoubleAnimation(); * offsetAnimation.From = 0.0; * offsetAnimation.To = 0.85; * offsetAnimation.Duration = TimeSpan.FromSeconds(1.0); * offsetAnimation.AutoReverse = true; * Storyboard.SetTarget(offsetAnimation, stop1); * Storyboard.SetTargetProperty(offsetAnimation, * new PropertyPath(GradientStop.OffsetProperty)); */ // // Animate the second gradient stop's color from // Purple to Yellow and then back to Purple. // TimeSpan duration = TimeSpan.FromSeconds(2.5); ColorAnimation gradientStopColorAnimation = new ColorAnimation(); //gradientStopColorAnimation.From = Colors.Green; gradientStopColorAnimation.To = Colors.Yellow; gradientStopColorAnimation.Duration = duration; //gradientStopColorAnimation.AutoReverse = true; Storyboard.SetTarget(gradientStopColorAnimation, stop2); Storyboard.SetTargetProperty(gradientStopColorAnimation, new PropertyPath(GradientStop.ColorProperty)); // Set the animation to begin after the first animation // ends. gradientStopColorAnimation.BeginTime = TimeSpan.FromSeconds(0.5); // Create a Storyboard to apply the animations. gradientStopAnimationStoryboard = new Storyboard(); if (useProtectiveColor) { gradientStopAnimationStoryboard.Children.Add(gradientStopColorAnimation); } else { //gradientStopAnimationStoryboard.Children.Add(offsetAnimation); } PanoramaMainView.SelectionChanged += (s, e) => { //colorStoryboard.Begin(); //날씨 설명 애니메이션 정지 HideForecastDescriptionMarquee(); String panoramaName = (e.AddedItems[0] as PanoramaItem).Name; if (panoramaName == PILivetile.Name) { ApplicationBar = IAppBarLivetile; ApplicationBar.IsVisible = true; } else if (panoramaName == PILockscreen.Name) { ApplicationBar = IAppBarLockscreen; ApplicationBar.IsVisible = true; if (LockscreenSelector.ItemsSource != null) { foreach (PhonePicture pic in LockscreenSelector.ItemsSource as ChameleonAlbum) { if (pic.CurrentLockscreen != null) { LockscreenSelector.ScrollTo(pic); break; } } } } else if (panoramaName == PIWeather.Name) { ApplicationBar = iAppBarWeather; ApplicationBar.IsVisible = true; } else if (panoramaName == PICalendar.Name) { ApplicationBar = IAppBarCalendar; ApplicationBar.IsVisible = true; } else { ApplicationBar = null; } Color newColor; if ((bool)SettingHelper.Get(Constants.CHAMELEON_USE_PROTECTIVE_COLOR)) { ColorAnimation protectiveColorAnimation = gradientStopAnimationStoryboard.Children[0] as ColorAnimation; if (protectiveColorAnimation == null) { gradientStopAnimationStoryboard.Stop(); gradientStopAnimationStoryboard.Children.Clear(); gradientStopAnimationStoryboard.Children.Add(gradientStopColorAnimation); protectiveColorAnimation = gradientStopColorAnimation; } //계속 다른 색상을 생성 do { int index = new Random().Next(0, ColorItem.UintColors.Length); newColor = ColorItem.ConvertColor(ColorItem.UintColors[index]); } while (newColor.Equals(protectiveColorAnimation.To)); //System.Diagnostics.Debug.WriteLine("random : " + newColor.ToString()); protectiveColorAnimation.To = newColor; gradientStopAnimationStoryboard.Begin(); } else { newColor = (SettingHelper.Get(Constants.CHAMELEON_SKIN_BACKGROUND_COLOR) as ColorItem).Color; ChangeBackgroundColor(newColor); // DoubleAnimation fixedColorAnimation = gradientStopAnimationStoryboard.Children[0] as DoubleAnimation; // if (fixedColorAnimation == null) // { // gradientStopAnimationStoryboard.Stop(); // gradientStopAnimationStoryboard.Children.Clear(); // gradientStopAnimationStoryboard.Children.Add(offsetAnimation); // } // gradientStopAnimationStoryboard.Begin(); } SetAppbarColor(ApplicationBar, newColor); }; //gradientStopColorAnimation.Completed += (s, e) => //{ // Color color = ApplicationBar.BackgroundColor; // ApplicationBar.BackgroundColor = Color.FromArgb(255, color.R, color.G, color.B); //}; }
private void RemoveLockscreenImage(PhonePicture picture) { var container = LockscreenSelector.ContainerFromItem(picture); Border border = FindFirstElementInVisualTree <Border>((DependencyObject)container); Storyboard sb = new Storyboard(); DoubleAnimationUsingKeyFrames timeline = new DoubleAnimationUsingKeyFrames(); timeline.KeyFrames.Add(new EasingDoubleKeyFrame() { KeyTime = KeyTime.FromTimeSpan(new TimeSpan(0, 0, 0)), Value = 1 }); timeline.KeyFrames.Add(new EasingDoubleKeyFrame() { KeyTime = KeyTime.FromTimeSpan(TimeSpan.FromMilliseconds(100)), Value = 0.1 }); timeline.KeyFrames.Add(new EasingDoubleKeyFrame() { KeyTime = KeyTime.FromTimeSpan(TimeSpan.FromMilliseconds(100)), Value = 0.01 }); sb.Children.Add(timeline); border.RenderTransformOrigin = new Point(0.5, 0.5); border.RenderTransform = new CompositeTransform(); Storyboard.SetTarget(timeline, border.RenderTransform); Storyboard.SetTargetProperty(timeline, new PropertyPath("CompositeTransform.ScaleY")); sb.Begin(); sb.Completed += (s, e) => { //다음 추가될 이미지를 위해 트랜스폼 복구 (border.RenderTransform as CompositeTransform).ScaleY = 1; //리스트에서 실제 삭제 처리 LockscreenSelector.ItemsSource.Remove(picture); //스토리지에서 파일 삭제 FileHelper.RemoveImage(picture.Name); FileHelper.RemoveImage(picture.ThumnailName); FileHelper.RemoveImage(picture.Name.Replace(Constants.LOCKSCREEN_IMAGE_POSTFIX, Constants.LOCKSCREEN_IMAGE_READY_POSTFIX)); //UI 변경 if (LockscreenSelector.ItemsSource.Count == 0) { TxtLockscreen.Visibility = System.Windows.Visibility.Visible; LockscreenSelector.EnforceIsSelectionEnabled = false; ChangeAppbarIconButtons(false); //이미지가 없고 활성화된 라이브타일이 없으면 스케쥴러 정저 if (!ExistsActiveTile) { RemoveAgent(Constants.PERIODIC_TASK_NAME); } SettingHelper.Remove(Constants.LOCKSCREEN_USE_ROTATOR); UseLockscreen.IsChecked = false; UseLockscreen.IsEnabled = false; } if (IAppBarLockscreen.Buttons.Count > 1 && LockscreenSelector.ItemsSource.Count == 0) { (IAppBarLockscreen.Buttons[0] as ApplicationBarIconButton).IsEnabled = false; } LockscreenEditWarnning = false; //편집 경고 표시 for (int i = 0; i < LockscreenSelector.ItemsSource.Count; i++) { PhonePicture pic = LockscreenSelector.ItemsSource[i] as PhonePicture; if (pic.Warnning != null) { LockscreenEditWarnning = true; break; } } //락스크린 카운드 LockscreenCount = string.Format("({0})", LockscreenSelector.ItemsSource.Count); }; }