示例#1
0
 /// <summary>
 /// Creates and initializes a new instance of Label class.
 /// </summary>
 /// <param name="parent">The parent is a given container which will be attached by Label as a child. It's <see cref="EvasObject"/> type.</param>
 /// <since_tizen> preview </since_tizen>
 public Label(EvasObject parent) : base(parent)
 {
     _slideCompleted     = new SmartEvent(this, this.RealHandle, "slide,end");
     _slideCompleted.On += (s, e) =>
     {
         SlideCompleted?.Invoke(this, EventArgs.Empty);
     };
 }
示例#2
0
        async void OnPanGestureUpdated(object sender, PanUpdatedEventArgs e)
        {
            if (Thumb == null | TrackBar == null)
            {
                return;
            }

            switch (e.StatusType)
            {
            case GestureStatus.Started:
                break;

            case GestureStatus.Running:
                var velocityX = e.TotalX;
                if ((posX + velocityX) > (Width - Thumb.Width - Thumb.Margin.Right))
                {
                    Thumb.TranslationX = Width - Thumb.Width - 2 * Thumb.Margin.Right;
                }
                else if (posX + velocityX <= 0)
                {
                    Thumb.TranslationX = 0;
                }
                else
                {
                    Thumb.TranslationX = posX + velocityX;
                }

                break;

            case GestureStatus.Completed:
                if ((Thumb.TranslationX + Thumb.Width / 2) > Width / 2)
                {
                    await Thumb.TranslateTo(Width / 2, 0, _animLength * 2, Easing.CubicIn);

                    IsToggled = true;
                }
                else
                {
                    await Thumb.TranslateTo(0, 0, _animLength * 2, Easing.CubicIn);

                    IsToggled = false;
                }

                posX = Thumb.TranslationX;

                if (posX >= (Width - Thumb.Width - 10))
                {
                    SlideCompleted?.Invoke(this, EventArgs.Empty);
                }
                break;
            }
        }
        internal async void OnPanGestureUpdated(object sender, PanUpdatedEventArgs e)
        {
            if (Thumb == null || TrackBar == null || FillBar == null)
            {
                return;
            }

            switch (e.StatusType)
            {
            case GestureStatus.Started:
                await TrackBar.FadeTo(FadeEffect, AnimLength);

                break;

            case GestureStatus.Running:
                // Translate and ensure we don't pan beyond the wrapped user interface element bounds.
                var x = Math.Max(0, e.TotalX);
                if (x > (Width - Thumb.Width))
                {
                    x = (Width - Thumb.Width);
                }

                // Uncomment this if you want only forward dragging.
                // if (e.TotalX < Thumb.TranslationX)
                //    return;
                Thumb.TranslationX = x;
                SetLayoutBounds(FillBar, new Rectangle(0, 0, x + Thumb.Width / 2, Height));
                break;

            case GestureStatus.Completed:
                var posX = Thumb.TranslationX;
                SetLayoutBounds(FillBar, new Rectangle(0, 0, 0, Height));

                // Reset translation applied during the pan
                await Task.WhenAll(new Task[]
                {
                    TrackBar.FadeTo(1, AnimLength),
                    Thumb.TranslateTo(0, 0, AnimLength * 2, Easing.CubicIn),
                });

                if (posX >= (Width - Thumb.Width - 10 /* keep some margin for error*/))
                {
                    SlideCompleted?.Invoke(this, EventArgs.Empty);
                }
                break;
            }
        }