示例#1
0
        public void TransitionGroupAddTransition()
        {
            tlog.Debug(tag, $"TransitionGroupAddTransition START");

            var testingTarget = new TransitionGroup();

            Assert.IsNotNull(testingTarget, "Return a null object of FontClient");
            Assert.IsInstanceOf <TransitionGroup>(testingTarget, "Should be an instance of TransitionGroup type.");

            try
            {
                using (TransitionBase tb = new TransitionBase())
                {
                    tb.TimePeriod    = new TimePeriod(300);
                    tb.AlphaFunction = new AlphaFunction(AlphaFunction.BuiltinFunctions.Bounce);

                    testingTarget.AddTransition(tb);
                }
            }
            catch (Exception e)
            {
                tlog.Debug(tag, e.Message.ToString());
                Assert.Fail("Caught Exception : Failed!");
            }

            testingTarget.Dispose();
            tlog.Debug(tag, $"TransitionGroupAddTransition END (OK)");
        }
示例#2
0
        private Page CreatePage(Color color, string colorTag, string greyTag)
        {
            View pageRoot = new View()
            {
                WidthResizePolicy  = ResizePolicyType.FillToParent,
                HeightResizePolicy = ResizePolicyType.FillToParent
            };

            View pageBackground = CreatePageScene(color, colorTag, greyTag);

            pageBackground.TouchEvent += (object sender, View.TouchEventArgs e) =>
            {
                if (e.Touch.GetState(0) == PointStateType.Down)
                {
                    navigator?.PopWithTransition();
                }
                return(true);
            };
            pageRoot.Add(pageBackground);

            TransitionGroup transitionGroup = new TransitionGroup();
            FadeTransition  slide           = new FadeTransition()
            {
                TimePeriod    = new TimePeriod(500),
                AlphaFunction = new AlphaFunction(AlphaFunction.BuiltinFunctions.Default),
            };

            transitionGroup.AddTransition(slide);

            Page page = new ContentPage()
            {
                AppBar = new AppBar()
                {
                    Title = "Second Page",
                },
                BackgroundColor = new Color(0.7f, 0.9f, 0.8f, 1.0f),
                Content         = pageRoot,

                AppearingTransition    = transitionGroup,
                DisappearingTransition = new SlideTransition()
                {
                    TimePeriod    = new TimePeriod(500),
                    AlphaFunction = new AlphaFunction(AlphaFunction.BuiltinFunctions.Default),
                    Direction     = SlideTransitionDirection.Left
                },
            };

            return(page);
        }
        public void Activate()
        {
            Window  window     = NUIApplication.GetDefaultWindow();
            Vector2 windowSize = new Vector2((float)(window.Size.Width), (float)(window.Size.Height));

            magnification = Math.Min(windowSize.X / baseSize.X, windowSize.Y / baseSize.Y);
            contentSize   = baseSize * magnification;

            navigator = new Navigator()
            {
                WidthResizePolicy  = ResizePolicyType.FillToParent,
                HeightResizePolicy = ResizePolicyType.FillToParent,
                Transition         = new Transition()
                {
                    TimePeriod    = new TimePeriod(400),
                    AlphaFunction = new AlphaFunction(AlphaFunction.BuiltinFunctions.EaseInOutSine),
                },
            };
            window.Add(navigator);

            View mainRoot = new View()
            {
                WidthResizePolicy  = ResizePolicyType.FillToParent,
                HeightResizePolicy = ResizePolicyType.FillToParent
            };

            View layoutView = new View()
            {
                PositionUsesPivotPoint = true,
                PivotPoint             = PivotPoint.BottomCenter,
                ParentOrigin           = ParentOrigin.BottomCenter,
                Layout = new LinearLayout()
                {
                    LinearAlignment   = LinearLayout.Alignment.Center,
                    LinearOrientation = LinearLayout.Orientation.Horizontal,
                    CellPadding       = new Size(convertSize(60), convertSize(60)),
                },
                Position = new Position(0, -convertSize(30))
            };

            mainRoot.Add(layoutView);

            View redButton   = CreateButton(TileColor[0], Keywords[0, 0], Keywords[0, 1], redPage);
            View greenButton = CreateButton(TileColor[1], Keywords[1, 0], Keywords[1, 1], greenPage);
            View blueButton  = CreateButton(TileColor[2], Keywords[2, 0], Keywords[2, 1], bluePage);

            layoutView.Add(redButton);
            layoutView.Add(greenButton);
            layoutView.Add(blueButton);


            TransitionGroup transitionGroup = new TransitionGroup()
            {
                UseGroupAlphaFunction = true,
                AlphaFunction         = new AlphaFunction(AlphaFunction.BuiltinFunctions.EaseInOut),
            };
            SlideTransition slide = new SlideTransition()
            {
                TimePeriod    = new TimePeriod(400),
                AlphaFunction = new AlphaFunction(AlphaFunction.BuiltinFunctions.Default),
                Direction     = SlideTransitionDirection.Top
            };

            transitionGroup.AddTransition(slide);
            FadeTransition fade = new FadeTransition()
            {
                Opacity       = 0.3f,
                TimePeriod    = new TimePeriod(400),
                AlphaFunction = new AlphaFunction(AlphaFunction.BuiltinFunctions.Default)
            };

            transitionGroup.AddTransition(fade);
            ScaleTransition scale = new ScaleTransition()
            {
                ScaleFactor   = new Vector2(0.3f, 0.3f),
                TimePeriod    = new TimePeriod(400),
                AlphaFunction = new AlphaFunction(AlphaFunction.BuiltinFunctions.Default)
            };

            transitionGroup.AddTransition(scale);

            mainPage = new ContentPage()
            {
                BackgroundColor        = Color.Transparent,
                Content                = mainRoot,
                DisappearingTransition = new ScaleTransition()
                {
                    TimePeriod    = new TimePeriod(500),
                    AlphaFunction = new AlphaFunction(AlphaFunction.BuiltinFunctions.Default),
                    ScaleFactor   = new Vector2(0.5f, 1.5f)
                },
                AppearingTransition = transitionGroup,
            };
            navigator.Push(mainPage);

            View totalGreyView = new View()
            {
                Size              = new Size(convertSize(50), convertSize(50)),
                CornerRadius      = convertSize(25),
                BackgroundColor   = ColorGrey,
                TransitionOptions = new TransitionOptions()
                {
                    TransitionTag = totalGreyTag,
                }
            };

            totalGreyView.TouchEvent += (object sender, View.TouchEventArgs e) =>
            {
                if (e.Touch.GetState(0) == PointStateType.Down)
                {
                    navigator.PushWithTransition(totalPage);
                }
                return(true);
            };
            layoutView.Add(totalGreyView);


            // ------------------------------------------------------


            View totalPageRoot = new View()
            {
                WidthResizePolicy = ResizePolicyType.FillToParent,
                SizeHeight        = contentSize.Height,
            };

            View totalLayoutView = new View()
            {
                Layout = new GridLayout()
                {
                    Rows            = 2,
                    GridOrientation = GridLayout.Orientation.Vertical,
                },
                PositionUsesPivotPoint = true,
                PivotPoint             = PivotPoint.Center,
                ParentOrigin           = ParentOrigin.Center,
            };

            totalPageRoot.Add(totalLayoutView);

            for (int i = 0; i < 3; ++i)
            {
                View sizeView = new View()
                {
                    Size = new Size(contentSize.Width / 2.0f, contentSize.Height / 2.0f),
                };
                View smallView = CreatePageScene(TileColor[i], Keywords[i, 0], Keywords[i, 1]);
                smallView.Scale = new Vector3(0.45f, 0.45f, 1.0f);
                smallView.PositionUsesPivotPoint = true;
                smallView.PivotPoint             = PivotPoint.Center;
                smallView.ParentOrigin           = ParentOrigin.Center;
                sizeView.Add(smallView);
                totalLayoutView.Add(sizeView);
            }

            View sizeGreyView = new View()
            {
                Size = new Size(contentSize.Width / 2.0f, contentSize.Height / 2.0f),
            };

            View totalGreyReturnView = new View()
            {
                PositionUsesPivotPoint = true,
                PivotPoint             = PivotPoint.Center,
                ParentOrigin           = ParentOrigin.Center,
                Size              = new Size(convertSize(70), convertSize(70)),
                CornerRadius      = convertSize(20),
                BackgroundColor   = ColorGrey,
                TransitionOptions = new TransitionOptions()
                {
                    TransitionTag = totalGreyTag,
                }
            };

            sizeGreyView.Add(totalGreyReturnView);
            totalLayoutView.Add(sizeGreyView);

            totalGreyReturnView.TouchEvent += (object sender, View.TouchEventArgs e) =>
            {
                if (e.Touch.GetState(0) == PointStateType.Down)
                {
                    navigator.PopWithTransition();
                }
                return(true);
            };

            totalPage = new ContentPage()
            {
                BackgroundColor     = Color.Transparent,
                Content             = totalPageRoot,
                AppearingTransition = new FadeTransition()
                {
                    TimePeriod    = new TimePeriod(500),
                    AlphaFunction = new AlphaFunction(AlphaFunction.BuiltinFunctions.Default),
                },
                DisappearingTransition = new FadeTransition()
                {
                    TimePeriod    = new TimePeriod(500),
                    AlphaFunction = new AlphaFunction(AlphaFunction.BuiltinFunctions.Default),
                },
            };
        }