diff options
| author | LukePulverenti <luke.pulverenti@gmail.com> | 2013-02-23 10:58:08 -0500 |
|---|---|---|
| committer | LukePulverenti <luke.pulverenti@gmail.com> | 2013-02-23 10:58:08 -0500 |
| commit | 17c1fd576057bdd2d6aea517d733fe8af6e6b2ba (patch) | |
| tree | 660f47e816a8599aabdb7ee47f3cde64c72c3f4d /MediaBrowser.UI.Controls/TransitionFrame.cs | |
| parent | 33ed929b526acbda696f00f5966917ebd6a9ded2 (diff) | |
moved ui to it's own repo
Diffstat (limited to 'MediaBrowser.UI.Controls/TransitionFrame.cs')
| -rw-r--r-- | MediaBrowser.UI.Controls/TransitionFrame.cs | 194 |
1 files changed, 0 insertions, 194 deletions
diff --git a/MediaBrowser.UI.Controls/TransitionFrame.cs b/MediaBrowser.UI.Controls/TransitionFrame.cs deleted file mode 100644 index e6f8325cc..000000000 --- a/MediaBrowser.UI.Controls/TransitionFrame.cs +++ /dev/null @@ -1,194 +0,0 @@ -using Microsoft.Expression.Media.Effects; -using System; -using System.Windows; -using System.Windows.Controls; -using System.Windows.Media; -using System.Windows.Media.Animation; - -namespace MediaBrowser.UI.Controls -{ - /// <summary> - /// Class TransitionFrame - /// </summary> - public class TransitionFrame : Frame - { - /// <summary> - /// The _content presenter - /// </summary> - private ContentPresenter _contentPresenter = null; - - #region DP TransitionType - - /// <summary> - /// Gets or sets the type of the transition. - /// </summary> - /// <value>The type of the transition.</value> - public TransitionEffect TransitionType - { - get { return (TransitionEffect)GetValue(TransitionTypeProperty); } - set { SetValue(TransitionTypeProperty, value); } - } - - // Using a DependencyProperty as the backing store for TransitionType. This enables animation, styling, binding, etc... - /// <summary> - /// The transition type property - /// </summary> - public static readonly DependencyProperty TransitionTypeProperty = - DependencyProperty.Register("TransitionType", typeof(TransitionEffect), typeof(TransitionFrame), - new UIPropertyMetadata(new BlindsTransitionEffect())); - - #endregion DP TransitionType - - #region DP Transition Animation - - /// <summary> - /// Gets or sets the transition animation. - /// </summary> - /// <value>The transition animation.</value> - public DoubleAnimation TransitionAnimation - { - get { return (DoubleAnimation)GetValue(TransitionAnimationProperty); } - set { SetValue(TransitionAnimationProperty, value); } - } - - // Using a DependencyProperty as the backing store for TransitionAnimation. This enables animation, styling, binding, etc... - /// <summary> - /// The transition animation property - /// </summary> - public static readonly DependencyProperty TransitionAnimationProperty = - DependencyProperty.Register("TransitionAnimation", typeof(DoubleAnimation), typeof(TransitionFrame), new UIPropertyMetadata(null)); - - #endregion DP Transition Animation - - /// <summary> - /// Called when the template generation for the visual tree is created. - /// </summary> - public override void OnApplyTemplate() - { - // get a reference to the frame's content presenter - // this is the element we will fade in and out - _contentPresenter = GetTemplateChild("PART_FrameCP") as ContentPresenter; - base.OnApplyTemplate(); - } - - /// <summary> - /// Animates the content. - /// </summary> - /// <param name="navigationAction">The navigation action.</param> - /// <param name="checkContent">if set to <c>true</c> [check content].</param> - /// <param name="isBack">if set to <c>true</c> [is back].</param> - private void AnimateContent(Action navigationAction, bool checkContent = true, bool isBack = false) - { - if (TransitionType == null || (checkContent && Content == null)) - { - CommandBindings.Clear(); - navigationAction(); - CommandBindings.Clear(); - return; - } - - var oldContentVisual = this as FrameworkElement; - - _contentPresenter.IsHitTestVisible = false; - - var da = TransitionAnimation.Clone(); - da.From = 0; - da.To = 1; - da.FillBehavior = FillBehavior.HoldEnd; - - var transitionEffect = TransitionType.Clone() as TransitionEffect; - - if (isBack) - { - ReverseDirection(transitionEffect); - } - - transitionEffect.OldImage = new VisualBrush(oldContentVisual); - transitionEffect.BeginAnimation(TransitionEffect.ProgressProperty, da); - - _contentPresenter.Effect = transitionEffect; - _contentPresenter.IsHitTestVisible = true; - - // Remove base class bindings to remote buttons - CommandBindings.Clear(); - - navigationAction(); - - CommandBindings.Clear(); - } - - /// <summary> - /// Navigates the with transition. - /// </summary> - /// <param name="page">The page.</param> - public void NavigateWithTransition(Page page) - { - AnimateContent(() => Navigate(page)); - } - - /// <summary> - /// Navigates the with transition. - /// </summary> - /// <param name="page">The page.</param> - public void NavigateWithTransition(Uri page) - { - AnimateContent(() => Navigate(page)); - } - - /// <summary> - /// Goes the back with transition. - /// </summary> - public void GoBackWithTransition() - { - if (CanGoBack) - { - AnimateContent(GoBack, false, true); - } - } - - /// <summary> - /// Goes the forward with transition. - /// </summary> - public void GoForwardWithTransition() - { - if (CanGoForward) - { - AnimateContent(GoForward, false); - } - } - - /// <summary> - /// Reverses the direction. - /// </summary> - /// <param name="transitionEffect">The transition effect.</param> - private void ReverseDirection(TransitionEffect transitionEffect) - { - var circleRevealTransitionEffect = transitionEffect as CircleRevealTransitionEffect; - - if (circleRevealTransitionEffect != null) - { - circleRevealTransitionEffect.Reverse = true; - return; - } - - var slideInTransitionEffect = transitionEffect as SlideInTransitionEffect; - if (slideInTransitionEffect != null) - { - if (slideInTransitionEffect.SlideDirection == SlideDirection.RightToLeft) - { - slideInTransitionEffect.SlideDirection = SlideDirection.LeftToRight; - } - return; - } - - var wipeTransitionEffect = transitionEffect as WipeTransitionEffect; - if (wipeTransitionEffect != null) - { - if (wipeTransitionEffect.WipeDirection == WipeDirection.RightToLeft) - { - wipeTransitionEffect.WipeDirection = WipeDirection.LeftToRight; - } - } - } - } -} |
