public RibbonResources() { _activeHoverFadeInformation = new FadeInformation(); _activeHoverFadeInformation.BackgroundColors = new Color[] { Color.FromArgb(0xFF, 0xF0, 0xF6, 0xFE), Color.FromArgb(0xFF, 0xDB, 0xE6, 0xF5) }; _activeHoverFadeInformation.BorderColor = Colors.Orange; _activeHoverFadeInformation.ForegroundColor = Colors.Navy; _activeHoverFadeInformation.DurationMilliseconds = 100; _inactiveHoverFadeInformation = new FadeInformation(); _inactiveHoverFadeInformation.BackgroundColors = new Color[] { Color.FromArgb(0xFF, 0xC8, 0xDA, 0xED), Color.FromArgb(0xFF, 0xE4, 0xE5, 0xDD) }; _inactiveHoverFadeInformation.BorderColor = Colors.Transparent; _inactiveHoverFadeInformation.ForegroundColor = Colors.Navy; _inactiveHoverFadeInformation.DurationMilliseconds = 100; _activeFadeInformation = new FadeInformation(); _activeFadeInformation.BackgroundColors = new Color[] { Color.FromArgb(0xFF, 0xF0, 0xF6, 0xFE), Color.FromArgb(0xFF, 0xDB, 0xE6, 0xF5) }; _activeFadeInformation.BorderColor = Colors.Transparent; _activeFadeInformation.ForegroundColor = Colors.Navy; _activeFadeInformation.DurationMilliseconds = 500; _inactiveFadeInformation = new FadeInformation(); _inactiveFadeInformation.BackgroundColors = new Color[] { Colors.Transparent, Colors.Transparent }; _inactiveFadeInformation.BorderColor = Colors.Transparent; _inactiveFadeInformation.ForegroundColor = Colors.Navy; _inactiveFadeInformation.DurationMilliseconds = 500; }
void FadeClip(AudioSource source, AudioClip clip, float speed) { Debug.Log(speed < 0 ? "[Fade] adding fadeOut" : "[Fade] adding fadeIn"); if (!musicClips.Contains(clip) && !soundClips.Contains(clip)) { return; } FadeInformation info = new FadeInformation(); info.source = source; info.speed = 1 / speed; if (fadeTable.ContainsKey(clip)) { fadeTable[clip] = info; } else { fadeTable.Add(clip, info); } info.Update(); }
private void ApplyFadeAnimation(TabItem tabItem, FadeInformation fadeInfo) { Border border = (Border)tabItem.Template.FindName("_border", tabItem); TextBlock textBlock = (TextBlock)tabItem.Template.FindName("_textBlock", tabItem); Storyboard storyboard = new Storyboard(); // Initialize a color animation for every gradient stop we'll be animating. We assume the colors are passed in order. ColorAnimation[] colorAnimations = new ColorAnimation[fadeInfo.BackgroundColors.Length]; for (int i = 0; i < fadeInfo.BackgroundColors.Length; i++) { colorAnimations[i] = new ColorAnimation(); colorAnimations[i].To = fadeInfo.BackgroundColors[i]; colorAnimations[i].Duration = new Duration(TimeSpan.FromMilliseconds(fadeInfo.DurationMilliseconds)); storyboard.Children.Add(colorAnimations[i]); Storyboard.SetTargetProperty(colorAnimations[i], new PropertyPath("Background.GradientStops[" + i.ToString() + "].Color", border)); } ColorAnimation borderAnimation = new ColorAnimation(); borderAnimation.To = fadeInfo.BorderColor; borderAnimation.Duration = new Duration(TimeSpan.FromMilliseconds(fadeInfo.DurationMilliseconds)); storyboard.Children.Add(borderAnimation); Storyboard.SetTargetProperty(borderAnimation, new PropertyPath("BorderBrush.Color", border)); storyboard.Begin(border); Storyboard s2 = new Storyboard(); ColorAnimation foregroundAnimation = new ColorAnimation(); foregroundAnimation.To = fadeInfo.ForegroundColor; foregroundAnimation.Duration = new Duration(TimeSpan.FromMilliseconds(fadeInfo.DurationMilliseconds)); s2.Children.Add(foregroundAnimation); Storyboard.SetTargetProperty(foregroundAnimation, new PropertyPath("Foreground.Color", textBlock)); s2.Begin(textBlock); }
private void SelectFadeAnimation( FadeInformation selectedColors, FadeInformation nonSelectedColors, object originalSource) { if (originalSource is TabItem) { TabItem tabItem = (TabItem)originalSource; if (tabItem.IsSelected) { ApplyFadeAnimation(tabItem, selectedColors); } else { ApplyFadeAnimation(tabItem, nonSelectedColors); } } }