public void Fade_MiddlePopup(bool fade, string text = "", bool progress = true) { Application.Current.Dispatcher.BeginInvoke(DispatcherPriority.Normal, new Action(() => { if (progress) { PopupProgress.Visibility = Visibility.Visible; } else { PopupProgress.Visibility = Visibility.Collapsed; } if (fade) { Storyboard sb = PopupBorder.FindResource("FadeOnEvent") as Storyboard; BeginStoryboard(sb); } else { Storyboard sb = PopupBorder.FindResource("FadeOffEvent") as Storyboard; BeginStoryboard(sb); } if (text != "") { PopupText.Text = text; } })); }
public void Hide() { DoubleAnimation animation = new DoubleAnimation(); animation.From = DefaultHeight; animation.To = 0; animation.Duration = Duration; PopupBorder.BeginAnimation(Border.HeightProperty, animation); IsFallOut = false; }
private void OnOpened(object sender, EventArgs e) { Keyboard.Focus(SearchBox); switch (taskbarEdge) { case Edge.Top: Placement = PlacementMode.Bottom; PopupBorder.BorderThickness = new Thickness(1); PopupMarginBorder.Margin = new Thickness(10, 0, 10, 10); break; case Edge.Left: Placement = PlacementMode.Right; PopupBorder.BorderThickness = new Thickness(1); PopupMarginBorder.Margin = new Thickness(0, 10, 10, 10); break; case Edge.Right: Placement = PlacementMode.Left; PopupBorder.BorderThickness = new Thickness(1); PopupMarginBorder.Margin = new Thickness(10, 10, 0, 10); break; case Edge.Bottom: Placement = PlacementMode.Top; PopupBorder.BorderThickness = new Thickness(1, 1, 1, 0); PopupMarginBorder.Margin = new Thickness(10, 10, 10, 0); break; } Height = Properties.Settings.Default.popupSize.Height; Width = Properties.Settings.Default.popupSize.Width; QuinticEase ease = new QuinticEase { EasingMode = EasingMode.EaseOut }; int modifier = taskbarEdge == Edge.Right || taskbarEdge == Edge.Bottom ? 1 : -1; Duration duration = TimeSpan.FromSeconds(Properties.Settings.Default.isAnimationsDisabled ? 0 : 0.4); DoubleAnimation outer = new DoubleAnimation(modifier * 150, 0, duration) { EasingFunction = ease }; DependencyProperty outerProp = taskbarEdge == Edge.Bottom || taskbarEdge == Edge.Top ? TranslateTransform.YProperty : TranslateTransform.XProperty; translateTransform?.BeginAnimation(outerProp, outer); DoubleAnimation opacity = new DoubleAnimation(0, 1, duration) { EasingFunction = ease }; PopupBorder?.BeginAnimation(OpacityProperty, opacity); duration = TimeSpan.FromSeconds(Properties.Settings.Default.isAnimationsDisabled ? 0 : 0.8); ThicknessAnimation inner = new ThicknessAnimation(new Thickness(0), duration) { EasingFunction = ease }; if (taskbarEdge == Edge.Top) { inner.From = new Thickness(0, -50, 0, 50); } else if (taskbarEdge == Edge.Right) { inner.From = new Thickness(50, 0, -50, 0); } else if (taskbarEdge == Edge.Bottom) { inner.From = new Thickness(0, 50, 0, -50); } else if (taskbarEdge == Edge.Left) { inner.From = new Thickness(-50, 0, 50, 0); } ContentGrid?.BeginAnimation(MarginProperty, inner); }