private void OnTransitioning(object sender, bool transitioning) { var container = Container; if (container == null) { return; } if (!transitioning) { return; } #pragma warning disable CA2000 // Dispose objects before losing scope var trans = new TransitionSet(); trans.SetOrdering(TransitionOrdering.Together); trans.AddListener(new TransitionCompletion(this, container)); #pragma warning restore CA2000 // Dispose objects before losing scope foreach (var t in BuildTransitions(_transition?.Element)) { trans.AddTransition(t); } TransitionManager.BeginDelayedTransition(container, trans); }
private void OnTransitioning(object sender, bool transitioning) { var container = Container; if (container == null) { return; } if (!transitioning) { return; } var trans = new TransitionSet(); trans.SetOrdering(TransitionOrdering.Together); trans.AddListener(new TransitionCompletion(this, container)); foreach (var t in BuildTransitions(_transition?.Element)) { trans.AddTransition(t); } TransitionManager.BeginDelayedTransition(container, trans); }
private void AnimateButtonClick(object sender, EventArgs e) { _currentSceneNumber = _currentSceneNumber == 1 ? 2 : 1; var scene = _currentSceneNumber switch { 1 => _scene1, 2 => _scene2, _ => throw new NotImplementedException() }; var set = new TransitionSet(); set.AddTransition(new Explode()); set.AddTransition(new ChangeBounds()); set.AddTransition(new CustomTransition()); set.SetOrdering(TransitionOrdering.Together); set.SetDuration(500); set.SetInterpolator(new DecelerateInterpolator()); TransitionManager.Go(scene, set); }
public void TransitionSetAddTransition() { tlog.Debug(tag, $"TransitionSetAddTransition START"); View view = new View() { Name = "view", TransitionOptions = new TransitionOptions(Window.Instance) }; view.TransitionOptions.TransitionTag = "Transition"; view.TransitionOptions.EnableTransition = true; TransitionItemBase transitionItemBase = null; using (TimePeriod timePeriod = new TimePeriod(500)) { using (AlphaFunction alphaFunction = new AlphaFunction(AlphaFunction.BuiltinFunctions.Default)) { transitionItemBase = new TransitionItemBase(view, true, timePeriod, alphaFunction); } } var testingTarget = new TransitionSet(); Assert.IsNotNull(testingTarget, "Should be not null!"); Assert.IsInstanceOf <TransitionSet>(testingTarget, "Should be an Instance of TransitionSet!"); testingTarget.Finished += OnFinished; try { testingTarget.AddTransition(transitionItemBase); } catch (Exception e) { tlog.Error(tag, "Caught Exception" + e.ToString()); LogUtils.Write(LogUtils.DEBUG, LogUtils.TAG, "Caught Exception" + e.ToString()); Assert.Fail("Caught Exception" + e.ToString()); } view.Dispose(); transitionItemBase.Dispose(); testingTarget.Dispose(); tlog.Debug(tag, $"TransitionSetAddTransition END (OK)"); }
public void TransitionSetSignalDisconnect() { tlog.Debug(tag, $"TransitionSetSignalDisconnect START"); View view = new View() { Name = "view", TransitionOptions = new TransitionOptions(Window.Instance) }; view.TransitionOptions.TransitionTag = "Transition"; view.TransitionOptions.EnableTransition = true; TransitionItemBase transitionItemBase = null; using (TimePeriod timePeriod = new TimePeriod(500)) { using (AlphaFunction alphaFunction = new AlphaFunction(AlphaFunction.BuiltinFunctions.Default)) { transitionItemBase = new TransitionItemBase(view, true, timePeriod, alphaFunction); } } var testingTarget = new TransitionSet(); Assert.IsNotNull(testingTarget, "Should be not null!"); Assert.IsInstanceOf <TransitionSet>(testingTarget, "Should be an Instance of TransitionSet!"); testingTarget.AddTransition(transitionItemBase); var transitionSetSignal = testingTarget.FinishedSignal(); Assert.IsNotNull(transitionSetSignal, "Should be not null!"); Assert.IsInstanceOf <TransitionSetFinishedSignal>(transitionSetSignal, "Should be an Instance of TransitionSet!"); dummyCallback callback = OnDummyCallback; transitionSetSignal.Connect(callback); transitionSetSignal.Disconnect(callback); view.Dispose(); testingTarget.Dispose(); tlog.Debug(tag, $"TransitionSetSignalDisconnect END (OK)"); }
public void TransitionSetAssign() { tlog.Debug(tag, $"TransitionSetAssign START"); View view = new View() { Name = "view", TransitionOptions = new TransitionOptions(Window.Instance) }; view.TransitionOptions.TransitionTag = "Transition"; view.TransitionOptions.EnableTransition = true; TransitionItemBase transitionItemBase = null; using (TimePeriod timePeriod = new TimePeriod(500)) { using (AlphaFunction alphaFunction = new AlphaFunction(AlphaFunction.BuiltinFunctions.Default)) { transitionItemBase = new TransitionItemBase(view, true, timePeriod, alphaFunction); } } var transitionSet = new TransitionSet(); Assert.IsNotNull(transitionSet, "Should be not null!"); Assert.IsInstanceOf <TransitionSet>(transitionSet, "Should be an Instance of TransitionSet!"); transitionSet.AddTransition(transitionItemBase); var testingTarget = new TransitionSet(); var result = transitionSet.Assign(testingTarget); Assert.IsNotNull(result, "Should be not null!"); Assert.IsInstanceOf <TransitionSet>(result, "Should be an Instance of TransitionSet!"); view.Dispose(); transitionItemBase.Dispose(); testingTarget.Dispose(); tlog.Debug(tag, $"TransitionSetAssign END (OK)"); }
/// <summary> /// Create Transitions between currentTopPage and newTopPage /// </summary> /// <param name="currentTopPage">The top page of Navigator.</param> /// <param name="newTopPage">The new top page after transition.</param> /// <param name="pushTransition">True if this transition is for push new page</param> private TransitionSet CreateTransitions(Page currentTopPage, Page newTopPage, bool pushTransition) { currentTopPage.SetVisible(true); // Set Content visible because it was hidden by HideContentOfPage. (currentTopPage as ContentPage)?.Content?.SetVisible(true); newTopPage.SetVisible(true); // Set Content visible because it was hidden by HideContentOfPage. (newTopPage as ContentPage)?.Content?.SetVisible(true); List <View> taggedViewsInNewTopPage = new List <View>(); RetrieveTaggedViews(taggedViewsInNewTopPage, newTopPage, true); List <View> taggedViewsInCurrentTopPage = new List <View>(); RetrieveTaggedViews(taggedViewsInCurrentTopPage, currentTopPage, true); List <KeyValuePair <View, View> > sameTaggedViewPair = new List <KeyValuePair <View, View> >(); foreach (View currentTopPageView in taggedViewsInCurrentTopPage) { bool findPair = false; foreach (View newTopPageView in taggedViewsInNewTopPage) { if ((currentTopPageView.TransitionOptions != null) && (newTopPageView.TransitionOptions != null) && currentTopPageView.TransitionOptions?.TransitionTag == newTopPageView.TransitionOptions?.TransitionTag) { sameTaggedViewPair.Add(new KeyValuePair <View, View>(currentTopPageView, newTopPageView)); findPair = true; break; } } if (findPair) { taggedViewsInNewTopPage.Remove(sameTaggedViewPair[sameTaggedViewPair.Count - 1].Value); } } foreach (KeyValuePair <View, View> pair in sameTaggedViewPair) { taggedViewsInCurrentTopPage.Remove(pair.Key); } TransitionSet newTransitionSet = new TransitionSet(); foreach (KeyValuePair <View, View> pair in sameTaggedViewPair) { TransitionItem pairTransition = transition.CreateTransition(pair.Key, pair.Value, pushTransition); if (pair.Value.TransitionOptions?.TransitionWithChild ?? false) { pairTransition.TransitionWithChild = true; } newTransitionSet.AddTransition(pairTransition); } newTransitionSet.Finished += (object sender, EventArgs e) => { if (newTopPage.Layout != null) { newTopPage.Layout.RequestLayout(); } if (currentTopPage.Layout != null) { currentTopPage.Layout.RequestLayout(); } transitionFinished = true; InvokeTransitionFinished(); transitionSet.Dispose(); }; if (!pushTransition || newTopPage is DialogPage == false) { View transitionView = (currentTopPage is ContentPage) ? (currentTopPage as ContentPage).Content : (currentTopPage as DialogPage).Content; if (currentTopPage.DisappearingTransition != null && transitionView != null) { TransitionItemBase disappearingTransition = currentTopPage.DisappearingTransition.CreateTransition(transitionView, false); disappearingTransition.TransitionWithChild = true; newTransitionSet.AddTransition(disappearingTransition); } else { currentTopPage.SetVisible(false); } } if (pushTransition || currentTopPage is DialogPage == false) { View transitionView = (newTopPage is ContentPage) ? (newTopPage as ContentPage).Content : (newTopPage as DialogPage).Content; if (newTopPage.AppearingTransition != null && transitionView != null) { TransitionItemBase appearingTransition = newTopPage.AppearingTransition.CreateTransition(transitionView, true); appearingTransition.TransitionWithChild = true; newTransitionSet.AddTransition(appearingTransition); } } newTransitionSet.Play(); return(newTransitionSet); }
/// <summary> /// Create Transition between currentTopPage and newTopPage /// </summary> /// <param name="currentTopPage">The top page of Navigator.</param> /// <param name="newTopPage">The new top page after transition.</param> /// <param name="pushTransition">True if this transition is for push new page</param> private TransitionSet CreateTransition(Page currentTopPage, Page newTopPage, bool pushTransition) { currentTopPage.SetVisible(true); newTopPage.SetVisible(true); List <View> taggedViewsInNewTopPage = new List <View>(); RetrieveTaggedViews(taggedViewsInNewTopPage, newTopPage); List <View> taggedViewsInCurrentTopPage = new List <View>(); RetrieveTaggedViews(taggedViewsInCurrentTopPage, currentTopPage); List <KeyValuePair <View, View> > sameTaggedViewPair = new List <KeyValuePair <View, View> >(); foreach (View currentTopPageView in taggedViewsInCurrentTopPage) { bool findPair = false; foreach (View newTopPageView in taggedViewsInNewTopPage) { if ((currentTopPageView.TransitionOptions != null) && (newTopPageView.TransitionOptions != null) && currentTopPageView.TransitionOptions?.TransitionTag == newTopPageView.TransitionOptions?.TransitionTag) { sameTaggedViewPair.Add(new KeyValuePair <View, View>(currentTopPageView, newTopPageView)); findPair = true; break; } } if (findPair) { taggedViewsInNewTopPage.Remove(sameTaggedViewPair[sameTaggedViewPair.Count - 1].Value); } } foreach (KeyValuePair <View, View> pair in sameTaggedViewPair) { taggedViewsInCurrentTopPage.Remove(pair.Key); } TransitionSet newTransitionSet = new TransitionSet(); foreach (KeyValuePair <View, View> pair in sameTaggedViewPair) { TransitionItem pairTransition = transition.CreateTransition(pair.Key, pair.Value); if (pair.Value.TransitionOptions?.TransitionWithChild ?? false) { pairTransition.TransitionWithChild = true; } newTransitionSet.AddTransition(pairTransition); } newTransitionSet.Play(); newTransitionSet.Finished += (object sender, EventArgs e) => { transitionFinished = true; InvokeTransitionFinished(); transitionSet.Dispose(); currentTopPage.Opacity = 1.0f; }; // default entering/exit transition - fast fade (half duration compaired with that of view pair transition) int duration = (transition.TimePeriod.DurationMilliseconds + transition.TimePeriod.DelayMilliseconds); float durationSeconds = (float)duration / 1000.0f; Animation fade = new Animation(0.8f * durationSeconds); fade.AnimateTo(currentTopPage, "Opacity", 0.0f); KeyFrames keyframes = new KeyFrames(); keyframes.Add(0.0f, 0.0f); keyframes.Add(1.0f, 1.0f); fade.AnimateBetween(newTopPage, "Opacity", keyframes); fade.Play(); return(newTransitionSet); }
/// <summary> /// Create Transitions between currentTopPage and newTopPage /// </summary> /// <param name="currentTopPage">The top page of Navigator.</param> /// <param name="newTopPage">The new top page after transition.</param> /// <param name="pushTransition">True if this transition is for push new page</param> private TransitionSet CreateTransitions(Page currentTopPage, Page newTopPage, bool pushTransition) { currentTopPage.SetVisible(true); newTopPage.SetVisible(true); List <View> taggedViewsInNewTopPage = new List <View>(); RetrieveTaggedViews(taggedViewsInNewTopPage, newTopPage, true); List <View> taggedViewsInCurrentTopPage = new List <View>(); RetrieveTaggedViews(taggedViewsInCurrentTopPage, currentTopPage, true); List <KeyValuePair <View, View> > sameTaggedViewPair = new List <KeyValuePair <View, View> >(); foreach (View currentTopPageView in taggedViewsInCurrentTopPage) { bool findPair = false; foreach (View newTopPageView in taggedViewsInNewTopPage) { if ((currentTopPageView.TransitionOptions != null) && (newTopPageView.TransitionOptions != null) && currentTopPageView.TransitionOptions?.TransitionTag == newTopPageView.TransitionOptions?.TransitionTag) { sameTaggedViewPair.Add(new KeyValuePair <View, View>(currentTopPageView, newTopPageView)); findPair = true; break; } } if (findPair) { taggedViewsInNewTopPage.Remove(sameTaggedViewPair[sameTaggedViewPair.Count - 1].Value); } } foreach (KeyValuePair <View, View> pair in sameTaggedViewPair) { taggedViewsInCurrentTopPage.Remove(pair.Key); } TransitionSet newTransitionSet = new TransitionSet(); foreach (KeyValuePair <View, View> pair in sameTaggedViewPair) { TransitionItem pairTransition = transition.CreateTransition(pair.Key, pair.Value); if (pair.Value.TransitionOptions?.TransitionWithChild ?? false) { pairTransition.TransitionWithChild = true; } newTransitionSet.AddTransition(pairTransition); } newTransitionSet.Finished += (object sender, EventArgs e) => { transitionFinished = true; InvokeTransitionFinished(); transitionSet.Dispose(); currentTopPage.Opacity = 1.0f; }; if (!pushTransition || newTopPage is DialogPage == false) { if (currentTopPage.DisappearingTransition != null) { TransitionItemBase disappearingTransition = currentTopPage.DisappearingTransition.CreateTransition(currentTopPage, false); disappearingTransition.TransitionWithChild = true; newTransitionSet.AddTransition(disappearingTransition); } else { currentTopPage.SetVisible(false); } } if (pushTransition || currentTopPage is DialogPage == false) { if (newTopPage.AppearingTransition != null) { TransitionItemBase appearingTransition = newTopPage.AppearingTransition.CreateTransition(newTopPage, true); appearingTransition.TransitionWithChild = true; newTransitionSet.AddTransition(appearingTransition); } } newTransitionSet.Play(); return(newTransitionSet); }
/// <summary> /// Loads the new constraint layout and adds the animation operation. /// </summary> private void PageTransition() { // Disable the See More / Hide button so we can't trigger another animation while this one is happening // It will get re-enabled in OnTransitionEnd seeMoreHideButton.Enabled = false; seeMoreModeEnabled = !seeMoreModeEnabled; if (seeMoreModeEnabled) { // Current: Results // Transition To: See More // The original x-ray view (that only appears in See More) is hidden to begin with so that // TalkBack doesn't narrate its elements xRayDisplayViewOriginal.Visibility = ViewStates.Visible; Transition transition = new AutoTransition(); transition.AddListener(this); // This listener will hide the conditionListSecondary when the transition is done (and re-enable the See More / Hide button) TransitionManager.BeginDelayedTransition(root, transition); seeMoreConstraints.ApplyTo(root); seeMoreHideButton.SetText(Resource.String.see_all_btn_hide); layoutManagerPrimary.ScrollEnabled = true; xRayDisplayView.TextDisplayMode = XRayDisplayView.DisplayMode.Small; xRayDisplayView.FilenameLabel = GetString(Resource.String.see_all_image_label_analyzed); } else { // Current: See More // Transition To: Results // We need a little bit of a custom transition here: // We want to fade in the conditionListSecondary and move it at the same time // We also want to keep the origin x-ray view visible during the transition then hide it afterwards // This transition takes care of the fade in + move for all elements TransitionSet mainTransitions = new TransitionSet(); mainTransitions.SetOrdering(TransitionSet.OrderingTogether); mainTransitions.AddTransition(new ChangeBounds()); mainTransitions.AddTransition(new Fade(Fade.In)); // This transition takes care of fading out the original x-ray view Transition fadeOut = new Fade(Fade.Out); fadeOut.AddTarget(Resource.Id.img_xray_original); // We can then run the two transition sequentially to make sure the fade out happens after everything else TransitionSet transitions = new TransitionSet(); transitions.SetOrdering(TransitionSet.OrderingSequential); transitions.AddTransition(mainTransitions); transitions.AddTransition(fadeOut); transitions.AddListener(this); // This listener will re-enable the See More / Hide button when the transition is done TransitionManager.BeginDelayedTransition(root, transitions); resultsConstraints.ApplyTo(root); seeMoreHideButton.SetText(Resource.String.results_btn_see_more); // Need to reset the scroll of conditionListPrimary to the top layoutManagerPrimary.ScrollToPositionWithOffset(0, 0); layoutManagerPrimary.ScrollEnabled = false; xRayDisplayView.TextDisplayMode = XRayDisplayView.DisplayMode.Large; xRayDisplayView.FilenameLabel = GetString(Resource.String.results_image_label); } }
/// <summary> /// Create Transition between currentTopPage and newTopPage /// </summary> /// <param name="currentTopPage">The top page of Navigator.</param> /// <param name="newTopPage">The new top page after transition.</param> /// <param name="pushTransition">True if this transition is for push new page</param> private TransitionSet CreateTransition(Page currentTopPage, Page newTopPage, bool pushTransition) { currentTopPage.SetVisible(true); newTopPage.SetVisible(true); List <View> taggedViewsInNewTopPage = new List <View>(); RetrieveTaggedViews(taggedViewsInNewTopPage, newTopPage, true); List <View> taggedViewsInCurrentTopPage = new List <View>(); RetrieveTaggedViews(taggedViewsInCurrentTopPage, currentTopPage, true); List <KeyValuePair <View, View> > sameTaggedViewPair = new List <KeyValuePair <View, View> >(); foreach (View currentTopPageView in taggedViewsInCurrentTopPage) { bool findPair = false; foreach (View newTopPageView in taggedViewsInNewTopPage) { if ((currentTopPageView.TransitionOptions != null) && (newTopPageView.TransitionOptions != null) && currentTopPageView.TransitionOptions?.TransitionTag == newTopPageView.TransitionOptions?.TransitionTag) { sameTaggedViewPair.Add(new KeyValuePair <View, View>(currentTopPageView, newTopPageView)); findPair = true; break; } } if (findPair) { taggedViewsInNewTopPage.Remove(sameTaggedViewPair[sameTaggedViewPair.Count - 1].Value); } } foreach (KeyValuePair <View, View> pair in sameTaggedViewPair) { taggedViewsInCurrentTopPage.Remove(pair.Key); } TransitionSet newTransitionSet = new TransitionSet(); sameTaggedViewPair.Reverse(); foreach (KeyValuePair <View, View> pair in sameTaggedViewPair) { TransitionItem pairTransition = transition.CreateTransition(pair.Key, pair.Value); if (pair.Value.TransitionOptions?.TransitionWithChild ?? false) { pairTransition.TransitionWithChild = true; } newTransitionSet.AddTransition(pairTransition); } newTransitionSet.Finished += (object sender, EventArgs e) => { transitionFinished = true; InvokeTransitionFinished(); transitionSet.Dispose(); currentTopPage.Opacity = 1.0f; }; // default appearing/disappearing transition - fast fade (half duration compaired with that of view pair transition) int duration = (transition.TimePeriod.DurationMilliseconds + transition.TimePeriod.DelayMilliseconds); float durationSeconds = (float)duration / 1000.0f; if (!pushTransition || newTopPage is DialogPage == false) { TransitionItemBase disappearingTransition = currentTopPage.DisappearingTransition.CreateTransition(currentTopPage, false); newTransitionSet.AddTransition(disappearingTransition); disappearingTransition.TransitionWithChild = true; } if (pushTransition || currentTopPage is DialogPage == false) { TransitionItemBase appearingTransition = newTopPage.AppearingTransition.CreateTransition(newTopPage, true); appearingTransition.TransitionWithChild = true; newTransitionSet.AddTransition(appearingTransition); } newTransitionSet.Play(); return(newTransitionSet); }