Beispiel #1
0
    void OnWindowTouch(object target, Window.TouchEventArgs arg)
    {
        if (arg.Touch.GetState(0) != PointStateType.Down)
        {
            return;
        }

        // Prepare content to notify
        var contentView = new TextLabel()
        {
            Size                = new Size(360, 360),
            Position            = new Position(360, 0),
            CornerRadius        = 180,
            BackgroundColor     = Color.Blue,
            Text                = "Hello World!",
            TextColor           = Color.White,
            HorizontalAlignment = HorizontalAlignment.Center,
            VerticalAlignment   = VerticalAlignment.Center,
        };

        var animationOnPost = new Animation(500);

        animationOnPost.AnimateTo(contentView, "Position", new Position(0, 0));

        var animationOnDismiss = new Animation(500);

        animationOnDismiss.AnimateTo(contentView, "Position", new Position(360, 0));

        new Notification(contentView)
        .SetDismissOnTouch(true)                       // (Optional) Dismiss when user touches it.
        .SetAnimationOnPost(animationOnPost)           // (Optional) Set an animation to be played when post.
        .SetAnimationOnDismiss(animationOnDismiss)     // (Optional) Set an animation to be played when dismiss.
        .Post();
    }
Beispiel #2
0
    void OnWindowTouch(object target, Window.TouchEventArgs args)
    {
        if (args.Touch.GetState(0) != PointStateType.Down)
        {
            return;
        }

        // Prepare content to notify
        var contentView = new TextLabel()
        {
            Size                   = new Size(180, 60),
            CornerRadius           = 30,
            BackgroundColor        = Color.White,
            Opacity                = 0,
            Text                   = "Hello World!",
            PixelSize              = 24,
            ParentOrigin           = ParentOrigin.Center,
            PivotPoint             = PivotPoint.Center,
            PositionUsesPivotPoint = true,
            HorizontalAlignment    = HorizontalAlignment.Center,
            VerticalAlignment      = VerticalAlignment.Center,
            Scale                  = new Vector3(0, 0, 0),
        };

        var animationOnPost = new Animation(200);

        animationOnPost.AnimateTo(contentView, "Opacity", 0.8f);
        animationOnPost.AnimateTo(contentView, "Scale", new Vector3(1, 1, 1));

        var animationOnDismiss = new Animation(200);

        animationOnDismiss.AnimateTo(contentView, "Opacity", 0);
        animationOnDismiss.AnimateTo(contentView, "Scale", new Vector3(0, 0, 0));

        new Notification(contentView)
        .SetAnimationOnPost(animationOnPost)             // (Optional) Set an animation to be played when post.
        .SetAnimationOnDismiss(animationOnDismiss)       // (Optional) Set an animation to be played when dismiss.
        .SetPositionSize(new Rectangle(90, 20, 180, 60)) // (Optional) Set notification window boundary.
        .Post(2000);                                     // Post for 2 seconds
    }