Exemplo n.º 1
0
        public void TransitionSetConstructor()
        {
            tlog.Debug(tag, $"TransitionSetConstructor START");

            var testingTarget = new TransitionSet();

            Assert.IsNotNull(testingTarget, "Should be not null!");
            Assert.IsInstanceOf <TransitionSet>(testingTarget, "Should be an Instance of TransitionSet!");

            testingTarget.Dispose();
            // diposed
            testingTarget.Dispose();
            tlog.Debug(tag, $"TransitionSetConstructor END (OK)");
        }
Exemplo n.º 2
0
        public void TransitionSetConstructorWithTransitionSet()
        {
            tlog.Debug(tag, $"TransitionSetConstructorWithTransitionSet START");

            using (TransitionSet transition = new TransitionSet())
            {
                var testingTarget = new TransitionSet(transition);
                Assert.IsNotNull(testingTarget, "Should be not null!");
                Assert.IsInstanceOf <TransitionSet>(testingTarget, "Should be an Instance of TransitionSet!");

                testingTarget.Dispose();
                // disposed
                testingTarget.Dispose();
            }

            tlog.Debug(tag, $"TransitionSetConstructorWithTransitionSet END (OK)");
        }
Exemplo n.º 3
0
        public void TransitionSetFinished()
        {
            tlog.Debug(tag, $"TransitionSetFinished START");

            var testingTarget = new TransitionSet();

            Assert.IsNotNull(testingTarget, "Should be not null!");
            Assert.IsInstanceOf <TransitionSet>(testingTarget, "Should be an Instance of TransitionSet!");

            testingTarget.Finished += OnFinished;
            testingTarget.Finished -= OnFinished;

            testingTarget.Dispose();
            tlog.Debug(tag, $"TransitionSetFinished END (OK)");
        }
Exemplo n.º 4
0
        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)");
        }
Exemplo n.º 5
0
        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)");
        }
Exemplo n.º 6
0
        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)");
        }
Exemplo n.º 7
0
        public void TransitionSetDispose()
        {
            tlog.Debug(tag, $"TransitionSetDispose START");

            var testingTarget = new TransitionSet();

            Assert.IsNotNull(testingTarget, "Should be not null!");
            Assert.IsInstanceOf <TransitionSet>(testingTarget, "Should be an Instance of TransitionSet!");

            try
            {
                testingTarget.Dispose();
            }
            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());
            }

            tlog.Debug(tag, $"TransitionSetDispose END (OK)");
        }
Exemplo n.º 8
0
        /// <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);
        }
Exemplo n.º 9
0
        /// <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);
        }
Exemplo n.º 10
0
        /// <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);
        }
Exemplo n.º 11
0
        /// <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);
        }