1. C# / Говнокод #22830

    −11

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    13. 13
    14. 14
    15. 15
    16. 16
    17. 17
    18. 18
    19. 19
    20. 20
    21. 21
    22. 22
    23. 23
    24. 24
    25. 25
    26. 26
    27. 27
    28. 28
    29. 29
    30. 30
    31. 31
    32. 32
    33. 33
    34. 34
    35. 35
    36. 36
    37. 37
    38. 38
    39. 39
    40. 40
    41. 41
    42. 42
    43. 43
    44. 44
    45. 45
    private readonly ScrollViewer _gestureListener = new ScrollViewer
            {
                Background = new SolidColorBrush { Color = Colors.Transparent },
                Content = new Rectangle { Height = 5000 },
                HorizontalScrollBarVisibility = ScrollBarVisibility.Disabled,
                VerticalScrollBarVisibility = ScrollBarVisibility.Hidden,
                IsScrollInertiaEnabled = false,
            };
    
            private async void _gestureListener_ViewChanged(object sender, ScrollViewerViewChangedEventArgs e)
            {
                if (_flipLock) return;
                var threshold = ActualHeight > 320 ? 48 : 32;
                var delta = 2500 - _gestureListener.VerticalOffset;
                if (e.IsIntermediate)
                {
                    var abs = Math.Abs(delta);
                    var hit = abs > threshold;
                    var transparency = hit ? 0.5 : 1;
                    var currentDot = _counterCanvas.Children[SelectedIndex] as FrameworkElement;
                    var predictedDot = _counterCanvas.Children[delta > 0 ? PrevIndex : NextIndex] as FrameworkElement;
                    await AwaitAll(
                        _layer1Control.TranslateByYAsync(TimeSpan.Zero, null, -abs),
                        _layer1Control.ChangeOpacityAsync(MidAnimationLength, null, transparency),
                        _layer2Control.TranslateByYAsync(TimeSpan.Zero, null, abs),
                        _layer2Control.ChangeOpacityAsync(MidAnimationLength, null, transparency),
                        currentDot.ScaleAsync(QuickAnimationLength, null, hit ? 0.7 : 1.3),
                        predictedDot.ScaleAsync(QuickAnimationLength, null, hit ? 1.6 : 1),
                        currentDot.ChangeOpacityAsync(QuickAnimationLength, null, hit ? 0.5 : 1),
                        predictedDot.ChangeOpacityAsync(QuickAnimationLength, null, hit ? 1 : 0.5));
                }
                else
                {
                    HandleGesture(delta, threshold);
                }
            }
    
            private void HandleGesture(double delta, double threshold)
            {
                var down = delta < -threshold;
                var up = delta > threshold;
                if (down) FlipForward();
                if (up) FlipBackward();
                if (!down && !up) ResetPosition();
            }

    UserControl, по поведению близкий к FlipView

    Запостил: cherepets, 18 Апреля 2017

    Комментарии (0) RSS

    Добавить комментарий

    Ошибка компиляции комментария:
    1. Гости могут высказаться только в понедельник, среду, четверг или воскресение
    ava Семь раз отмерь — один отрежь, guest!
    А не использовать ли нам bbcode?
    • [b]жирный[/b] — жирный
    • [i]курсив[/i] — курсив
    • [u]подчеркнутый[/u] — подчеркнутый
    • [s]перечеркнутый[/s] — перечеркнутый
    • [blink]мигающий[/blink] — мигающий
    • [color=red]цвет[/color] — цвет (подробнее)
    • [size=20]размер[/size] — размер (подробнее)
    • [code=<language>]some code[/code] (подробнее)
    Проверочный код