Пример #1
0
        async Task <bool> ShowAsync(EWidget target, Easing easing = null, uint length = 300, CancellationToken cancelltaionToken = default(CancellationToken))
        {
            var tcs = new TaskCompletionSource <bool>();

            await Task.Delay(1000);

            if (cancelltaionToken.IsCancellationRequested)
            {
                cancelltaionToken.ThrowIfCancellationRequested();
            }

            target.Show();
            var opacity = target.Opacity;

            if (opacity == 255 || opacity == -1)
            {
                return(true);
            }

            new Animation((progress) =>
            {
                target.Opacity = opacity + (int)((255 - opacity) * progress);
            }).Commit(this, "FadeIn", length: length, finished: (p, e) =>
            {
                target.Opacity = 255;
                tcs.SetResult(true);
            });

            return(await tcs.Task);
        }
Пример #2
0
        async Task <bool> HideAsync(EWidget target, Easing easing = null, uint length = 300)
        {
            var tcs = new TaskCompletionSource <bool>();

            var opacity = target.Opacity;

            if (opacity == -1)
            {
                opacity = 255;
            }

            new Animation((progress) =>
            {
                target.Opacity = opacity - (int)(progress * opacity);
            }).Commit(this, "FadeOut", length: length, finished: (p, e) =>
            {
                target.Opacity = 0;
                target.Hide();
                tcs.SetResult(true);
            });

            return(await tcs.Task);
        }