|
| 1 | +// Licensed to the .NET Foundation under one or more agreements. |
| 2 | +// The .NET Foundation licenses this file to you under the MIT license. |
| 3 | +// See the LICENSE file in the project root for more information. |
| 4 | + |
| 5 | +using System.Numerics; |
| 6 | + |
| 7 | +namespace CommunityToolkit.WinUI.Controls; |
| 8 | + |
| 9 | +public partial class Carousel |
| 10 | +{ |
| 11 | + /// <summary> |
| 12 | + /// The backing <see cref="DependencyProperty"/> for the <see cref="TransitionDuration"/> property. |
| 13 | + /// </summary> |
| 14 | + public static readonly DependencyProperty OrientationProperty = |
| 15 | + DependencyProperty.Register(nameof(Orientation), typeof(Orientation), typeof(Carousel), new PropertyMetadata(Orientation.Horizontal)); |
| 16 | + |
| 17 | + /// <summary> |
| 18 | + /// The backing <see cref="DependencyProperty"/> for the <see cref="SelectedIndex"/> property. |
| 19 | + /// </summary> |
| 20 | + public static readonly DependencyProperty SelectedIndexProperty = |
| 21 | + DependencyProperty.Register(nameof(SelectedIndex), typeof(int), typeof(Carousel), new PropertyMetadata(-1, OnCarouselSelectionPropertyChanged)); |
| 22 | + |
| 23 | + /// <summary> |
| 24 | + /// The backing <see cref="DependencyProperty"/> for the <see cref="SelectedItem"/> property. |
| 25 | + /// </summary> |
| 26 | + public static readonly DependencyProperty SelectedItemProperty = |
| 27 | + DependencyProperty.Register(nameof(SelectedItem), typeof(object), typeof(Carousel), new PropertyMetadata(null, OnCarouselSelectionPropertyChanged)); |
| 28 | + |
| 29 | + /// <summary> |
| 30 | + /// The backing <see cref="DependencyProperty"/> for the <see cref="TransitionDuration"/> property. |
| 31 | + /// </summary> |
| 32 | + public static readonly DependencyProperty ItemSpacingProperty = |
| 33 | + DependencyProperty.Register(nameof(ItemSpacing), typeof(double), typeof(Carousel), new PropertyMetadata(0)); |
| 34 | + |
| 35 | + /// <summary> |
| 36 | + /// The backing <see cref="DependencyProperty"/> for the <see cref="TransitionDuration"/> property. |
| 37 | + /// </summary> |
| 38 | + public static readonly DependencyProperty TransitionDurationProperty = |
| 39 | + DependencyProperty.Register(nameof(TransitionDuration), typeof(TimeSpan), typeof(Carousel), new PropertyMetadata(TimeSpan.FromMilliseconds(200))); |
| 40 | + |
| 41 | + /// <summary> |
| 42 | + /// The backing <see cref="DependencyProperty"/> for the <see cref="TransitionDuration"/> property. |
| 43 | + /// </summary> |
| 44 | + public static readonly DependencyProperty EasingFunctionProperty = |
| 45 | + DependencyProperty.Register(nameof(TransitionDuration), typeof(EasingFunctionBase), typeof(Carousel), new PropertyMetadata(null)); |
| 46 | + |
| 47 | + /// <summary> |
| 48 | + /// The backing <see cref="DependencyProperty"/> for the <see cref="TransitionDuration"/> property. |
| 49 | + /// </summary> |
| 50 | + public static readonly DependencyProperty ItemDepthProperty = |
| 51 | + DependencyProperty.Register(nameof(ItemDepth), typeof(double), typeof(Carousel), new PropertyMetadata(0)); |
| 52 | + |
| 53 | + /// <summary> |
| 54 | + /// The backing <see cref="DependencyProperty"/> for the <see cref="TransitionDuration"/> property. |
| 55 | + /// </summary> |
| 56 | + public static readonly DependencyProperty ItemRotationProperty = |
| 57 | + DependencyProperty.Register(nameof(ItemRotation), typeof(double), typeof(Carousel), new PropertyMetadata(Vector3.Zero)); |
| 58 | + |
| 59 | + /// <summary> |
| 60 | + /// The backing <see cref="DependencyProperty"/> for the <see cref="TransitionDuration"/> property. |
| 61 | + /// </summary> |
| 62 | + public static readonly DependencyProperty InvertPositiveProperty = |
| 63 | + DependencyProperty.Register(nameof(InvertPositive), typeof(bool), typeof(Carousel), new PropertyMetadata(true)); |
| 64 | + |
| 65 | + /// <summary> |
| 66 | + /// Gets or sets the orientation to render items. |
| 67 | + /// </summary> |
| 68 | + public Orientation Orientation |
| 69 | + { |
| 70 | + get => (Orientation)GetValue(OrientationProperty); |
| 71 | + set => SetValue(OrientationProperty, value); |
| 72 | + } |
| 73 | + |
| 74 | + /// <summary> |
| 75 | + /// Gets or sets the index of the selected item. |
| 76 | + /// </summary> |
| 77 | + public int SelectedIndex |
| 78 | + { |
| 79 | + get => (int)GetValue(SelectedIndexProperty); |
| 80 | + set => SetValue(SelectedIndexProperty, value); |
| 81 | + } |
| 82 | + |
| 83 | + /// <summary> |
| 84 | + /// Gets or sets the selected item. |
| 85 | + /// </summary> |
| 86 | + public object? SelectedItem |
| 87 | + { |
| 88 | + get => (object?)GetValue(SelectedItemProperty); |
| 89 | + set => SetValue(SelectedItemProperty, value); |
| 90 | + } |
| 91 | + |
| 92 | + /// <summary> |
| 93 | + /// Gets or sets the selected item. |
| 94 | + /// </summary> |
| 95 | + public double? ItemSpacing |
| 96 | + { |
| 97 | + get => (double?)GetValue(ItemSpacingProperty); |
| 98 | + set => SetValue(ItemSpacingProperty, value); |
| 99 | + } |
| 100 | + |
| 101 | + /// <summary> |
| 102 | + /// Gets or sets the transition animation duration. |
| 103 | + /// </summary> |
| 104 | + public TimeSpan TransitionDuration |
| 105 | + { |
| 106 | + get => (TimeSpan)GetValue(TransitionDurationProperty); |
| 107 | + set => SetValue(TransitionDurationProperty, value); |
| 108 | + } |
| 109 | + |
| 110 | + /// <summary> |
| 111 | + /// Gets or sets the transition animation duration. |
| 112 | + /// </summary> |
| 113 | + public EasingFunctionBase? EasingFunction |
| 114 | + { |
| 115 | + get => (EasingFunctionBase?)GetValue(EasingFunctionProperty); |
| 116 | + set => SetValue(EasingFunctionProperty, value); |
| 117 | + } |
| 118 | + |
| 119 | + /// <summary> |
| 120 | + /// Gets or sets the depth for unselected items. |
| 121 | + /// </summary> |
| 122 | + public double ItemDepth |
| 123 | + { |
| 124 | + get => (double)GetValue(TransitionDurationProperty); |
| 125 | + set => SetValue(TransitionDurationProperty, value); |
| 126 | + } |
| 127 | + |
| 128 | + /// <summary> |
| 129 | + /// Gets or sets the rotation to apply to carousel items. |
| 130 | + /// </summary> |
| 131 | + public Vector3 ItemRotation |
| 132 | + { |
| 133 | + get => (Vector3)GetValue(ItemRotationProperty); |
| 134 | + set => SetValue(ItemRotationProperty, value); |
| 135 | + } |
| 136 | + |
| 137 | + /// <summary> |
| 138 | + /// Gets or sets the rotation to apply to carousel items. |
| 139 | + /// </summary> |
| 140 | + public bool InvertPositive |
| 141 | + { |
| 142 | + get => (bool)GetValue(InvertPositiveProperty); |
| 143 | + set => SetValue(InvertPositiveProperty, value); |
| 144 | + } |
| 145 | + |
| 146 | + private static void OnCarouselSelectionPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) |
| 147 | + { |
| 148 | + if (d is not Carousel carousel) |
| 149 | + return; |
| 150 | + } |
| 151 | +} |
0 commit comments