|
| 1 | +namespace DevWinUI; |
| 2 | + |
| 3 | +public partial class BannerView |
| 4 | +{ |
| 5 | + public bool IsPerspectiveEnable |
| 6 | + { |
| 7 | + get { return (bool)GetValue(IsPerspectiveEnableProperty); } |
| 8 | + set { SetValue(IsPerspectiveEnableProperty, value); } |
| 9 | + } |
| 10 | + public static readonly DependencyProperty IsPerspectiveEnableProperty = |
| 11 | + DependencyProperty.Register("IsPerspectiveEnable", typeof(bool), typeof(BannerView), new PropertyMetadata(false, (s, a) => |
| 12 | + { |
| 13 | + if (a.NewValue != a.OldValue) |
| 14 | + { |
| 15 | + if (s is BannerView sender) |
| 16 | + { |
| 17 | + sender.UpdatePerspective(); |
| 18 | + } |
| 19 | + } |
| 20 | + })); |
| 21 | + |
| 22 | + public bool IsScaleEnable |
| 23 | + { |
| 24 | + get { return (bool)GetValue(IsScaleEnableProperty); } |
| 25 | + set { SetValue(IsScaleEnableProperty, value); } |
| 26 | + } |
| 27 | + public static readonly DependencyProperty IsScaleEnableProperty = |
| 28 | + DependencyProperty.Register("IsScaleEnable", typeof(bool), typeof(BannerView), new PropertyMetadata(false, (s, a) => |
| 29 | + { |
| 30 | + if (a.NewValue != a.OldValue) |
| 31 | + { |
| 32 | + if (s is BannerView sender) |
| 33 | + { |
| 34 | + sender.UpdateScale(); |
| 35 | + } |
| 36 | + } |
| 37 | + })); |
| 38 | + |
| 39 | + public double ItemsSpacing |
| 40 | + { |
| 41 | + get { return (double)GetValue(ItemsSpacingProperty); } |
| 42 | + set { SetValue(ItemsSpacingProperty, value); } |
| 43 | + } |
| 44 | + |
| 45 | + public static readonly DependencyProperty ItemsSpacingProperty = |
| 46 | + DependencyProperty.Register("ItemsSpacing", typeof(double), typeof(BannerView), new PropertyMetadata(0d, (s, a) => |
| 47 | + { |
| 48 | + if (a.NewValue != a.OldValue) |
| 49 | + { |
| 50 | + if (s is BannerView sender) |
| 51 | + { |
| 52 | + sender.UpdateItemSpacing(); |
| 53 | + } |
| 54 | + } |
| 55 | + })); |
| 56 | + |
| 57 | + public bool AutoShuffle |
| 58 | + { |
| 59 | + get { return (bool)GetValue(AutoShuffleProperty); } |
| 60 | + set { SetValue(AutoShuffleProperty, value); } |
| 61 | + } |
| 62 | + |
| 63 | + public static readonly DependencyProperty AutoShuffleProperty = |
| 64 | + DependencyProperty.Register(nameof(AutoShuffle), typeof(bool), typeof(BannerView), new PropertyMetadata(false, OnAutoShuffleChanged)); |
| 65 | + |
| 66 | + private static void OnAutoShuffleChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) |
| 67 | + { |
| 68 | + var ctl = (BannerView)d; |
| 69 | + if (ctl != null) |
| 70 | + { |
| 71 | + ctl.OnAutoShuffleChanged(); |
| 72 | + } |
| 73 | + } |
| 74 | + |
| 75 | + public TimeSpan Interval |
| 76 | + { |
| 77 | + get { return (TimeSpan)GetValue(IntervalProperty); } |
| 78 | + set { SetValue(IntervalProperty, value); } |
| 79 | + } |
| 80 | + |
| 81 | + public static readonly DependencyProperty IntervalProperty = |
| 82 | + DependencyProperty.Register(nameof(Interval), typeof(TimeSpan), typeof(BannerView), new PropertyMetadata(TimeSpan.FromSeconds(1), OnIntervalChanged)); |
| 83 | + |
| 84 | + private static void OnIntervalChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) |
| 85 | + { |
| 86 | + var ctl = (BannerView)d; |
| 87 | + if (ctl != null && e.NewValue is TimeSpan timeSpan) |
| 88 | + { |
| 89 | + ctl.timer?.Interval = timeSpan; |
| 90 | + } |
| 91 | + } |
| 92 | +} |
0 commit comments