Table of Contents

Class FortuneWheel

Namespace
Nova.Avalonia.UI.Controls
Assembly
Nova.Avalonia.UI.dll

A circular fortune wheel control that can be spun to select random items. Supports keyboard interaction (Space or Enter to spin) and full accessibility.

public class FortuneWheel : TemplatedControl, INotifyPropertyChanged, IDataContextProvider, ILogical, IThemeVariantHost, IResourceHost, IResourceNode, IStyleHost, ISetLogicalParent, ISetInheritanceParent, ISupportInitialize, IStyleable, INamed, IInputElement, IDataTemplateHost, ISetterValue
Inheritance
AvaloniaObject
Animatable
StyledElement
Visual
Layoutable
Interactive
InputElement
Control
TemplatedControl
FortuneWheel
Implements
IDataContextProvider
ILogical
IThemeVariantHost
IResourceHost
IResourceNode
IStyleHost
ISetLogicalParent
ISetInheritanceParent
IStyleable
INamed
IInputElement
IDataTemplateHost
ISetterValue
Inherited Members
TemplatedControl.BackgroundProperty
TemplatedControl.BackgroundSizingProperty
TemplatedControl.BorderBrushProperty
TemplatedControl.BorderThicknessProperty
TemplatedControl.CornerRadiusProperty
TemplatedControl.FontFamilyProperty
TemplatedControl.FontFeaturesProperty
TemplatedControl.FontSizeProperty
TemplatedControl.FontStyleProperty
TemplatedControl.FontWeightProperty
TemplatedControl.FontStretchProperty
TemplatedControl.ForegroundProperty
TemplatedControl.PaddingProperty
TemplatedControl.TemplateProperty
TemplatedControl.IsTemplateFocusTargetProperty
TemplatedControl.TemplateAppliedEvent
TemplatedControl.GetIsTemplateFocusTarget(Control)
TemplatedControl.ApplyTemplate()
TemplatedControl.GetTemplateFocusTarget()
TemplatedControl.OnAttachedToLogicalTree(LogicalTreeAttachmentEventArgs)
TemplatedControl.OnDetachedFromLogicalTree(LogicalTreeAttachmentEventArgs)
TemplatedControl.OnApplyTemplate(TemplateAppliedEventArgs)
TemplatedControl.OnTemplateChanged(AvaloniaPropertyChangedEventArgs)
TemplatedControl.Background
TemplatedControl.BackgroundSizing
TemplatedControl.BorderBrush
TemplatedControl.BorderThickness
TemplatedControl.CornerRadius
TemplatedControl.FontFamily
TemplatedControl.FontFeatures
TemplatedControl.FontSize
TemplatedControl.FontStyle
TemplatedControl.FontWeight
TemplatedControl.FontStretch
TemplatedControl.Foreground
TemplatedControl.Padding
TemplatedControl.Template
TemplatedControl.TemplateApplied
Control.FocusAdornerProperty
Control.TagProperty
Control.ContextMenuProperty
Control.ContextFlyoutProperty
Control.RequestBringIntoViewEvent
Control.ContextRequestedEvent
Control.LoadedEvent
Control.UnloadedEvent
Control.SizeChangedEvent
Control.OnLoaded(RoutedEventArgs)
Control.OnUnloaded(RoutedEventArgs)
Control.OnSizeChanged(SizeChangedEventArgs)
Control.OnAttachedToVisualTreeCore(VisualTreeAttachmentEventArgs)
Control.OnDetachedFromVisualTreeCore(VisualTreeAttachmentEventArgs)
Control.OnGotFocus(GotFocusEventArgs)
Control.OnLostFocus(RoutedEventArgs)
Control.OnCreateAutomationPeer()
Control.OnPointerReleased(PointerReleasedEventArgs)
Control.OnKeyUp(KeyEventArgs)
Control.FocusAdorner
Control.DataTemplates
Control.ContextMenu
Control.ContextFlyout
Control.IsLoaded
Control.Tag
Control.ContextRequested
Control.Loaded
Control.Unloaded
Control.SizeChanged
InputElement.FocusableProperty
InputElement.IsEnabledProperty
InputElement.IsEffectivelyEnabledProperty
InputElement.CursorProperty
InputElement.IsKeyboardFocusWithinProperty
InputElement.IsFocusedProperty
InputElement.IsHitTestVisibleProperty
InputElement.IsPointerOverProperty
InputElement.IsTabStopProperty
InputElement.GotFocusEvent
InputElement.LostFocusEvent
InputElement.KeyDownEvent
InputElement.KeyUpEvent
InputElement.TabIndexProperty
InputElement.TextInputEvent
InputElement.TextInputMethodClientRequestedEvent
InputElement.PointerEnteredEvent
InputElement.PointerExitedEvent
InputElement.PointerMovedEvent
InputElement.PointerPressedEvent
InputElement.PointerReleasedEvent
InputElement.PointerCaptureLostEvent
InputElement.PointerWheelChangedEvent
InputElement.TappedEvent
InputElement.HoldingEvent
InputElement.DoubleTappedEvent
InputElement.Focus(NavigationMethod, KeyModifiers)
InputElement.OnAccessKey(RoutedEventArgs)
InputElement.OnTextInput(TextInputEventArgs)
InputElement.OnPointerEntered(PointerEventArgs)
InputElement.OnPointerExited(PointerEventArgs)
InputElement.OnPointerMoved(PointerEventArgs)
InputElement.OnPointerPressed(PointerPressedEventArgs)
InputElement.OnPointerCaptureLost(PointerCaptureLostEventArgs)
InputElement.OnPointerWheelChanged(PointerWheelEventArgs)
InputElement.UpdateIsEffectivelyEnabled()
InputElement.Focusable
InputElement.IsEnabled
InputElement.Cursor
InputElement.IsKeyboardFocusWithin
InputElement.IsFocused
InputElement.IsHitTestVisible
InputElement.IsPointerOver
InputElement.IsTabStop
InputElement.IsEffectivelyEnabled
InputElement.TabIndex
InputElement.KeyBindings
InputElement.IsEnabledCore
InputElement.GestureRecognizers
InputElement.GotFocus
InputElement.LostFocus
InputElement.KeyDown
InputElement.KeyUp
InputElement.TextInput
InputElement.TextInputMethodClientRequested
InputElement.PointerEntered
InputElement.PointerExited
InputElement.PointerMoved
InputElement.PointerPressed
InputElement.PointerReleased
InputElement.PointerCaptureLost
InputElement.PointerWheelChanged
InputElement.Tapped
InputElement.Holding
InputElement.DoubleTapped
Interactive.RaiseEvent(RoutedEventArgs)
Interactive.BuildEventRoute(RoutedEvent)
Layoutable.DesiredSizeProperty
Layoutable.WidthProperty
Layoutable.HeightProperty
Layoutable.MinWidthProperty
Layoutable.MaxWidthProperty
Layoutable.MinHeightProperty
Layoutable.MaxHeightProperty
Layoutable.MarginProperty
Layoutable.HorizontalAlignmentProperty
Layoutable.VerticalAlignmentProperty
Layoutable.UseLayoutRoundingProperty
Layoutable.UpdateLayout()
Layoutable.Measure(Size)
Layoutable.Arrange(Rect)
Layoutable.InvalidateMeasure()
Layoutable.InvalidateArrange()
Layoutable.AffectsMeasure<T>(params AvaloniaProperty[])
Layoutable.AffectsArrange<T>(params AvaloniaProperty[])
Layoutable.MeasureCore(Size)
Layoutable.MeasureOverride(Size)
Layoutable.ArrangeCore(Rect)
Layoutable.ArrangeOverride(Size)
Layoutable.OnMeasureInvalidated()
Layoutable.OnVisualParentChanged(Visual, Visual)
Layoutable.Width
Layoutable.Height
Layoutable.MinWidth
Layoutable.MaxWidth
Layoutable.MinHeight
Layoutable.MaxHeight
Layoutable.Margin
Layoutable.HorizontalAlignment
Layoutable.VerticalAlignment
Layoutable.DesiredSize
Layoutable.IsMeasureValid
Layoutable.IsArrangeValid
Layoutable.UseLayoutRounding
Layoutable.EffectiveViewportChanged
Layoutable.LayoutUpdated
Visual.BoundsProperty
Visual.ClipToBoundsProperty
Visual.ClipProperty
Visual.IsVisibleProperty
Visual.OpacityProperty
Visual.OpacityMaskProperty
Visual.EffectProperty
Visual.HasMirrorTransformProperty
Visual.RenderTransformProperty
Visual.RenderTransformOriginProperty
Visual.FlowDirectionProperty
Visual.VisualParentProperty
Visual.ZIndexProperty
Visual.GetFlowDirection(Visual)
Visual.SetFlowDirection(Visual, FlowDirection)
Visual.InvalidateVisual()
Visual.AffectsRender<T>(params AvaloniaProperty[])
Visual.OnAttachedToVisualTree(VisualTreeAttachmentEventArgs)
Visual.InvalidateMirrorTransform()
Visual.Bounds
Visual.ClipToBounds
Visual.Clip
Visual.IsEffectivelyVisible
Visual.IsVisible
Visual.Opacity
Visual.OpacityMask
Visual.Effect
Visual.HasMirrorTransform
Visual.RenderTransform
Visual.RenderTransformOrigin
Visual.FlowDirection
Visual.ZIndex
Visual.VisualChildren
Visual.VisualRoot
Visual.BypassFlowDirectionPolicies
Visual.AttachedToVisualTree
Visual.DetachedFromVisualTree
StyledElement.DataContextProperty
StyledElement.NameProperty
StyledElement.ParentProperty
StyledElement.TemplatedParentProperty
StyledElement.ThemeProperty
StyledElement.BeginInit()
StyledElement.EndInit()
StyledElement.ApplyStyling()
StyledElement.InitializeIfNeeded()
StyledElement.OnDataContextBeginUpdate()
StyledElement.OnDataContextEndUpdate()
StyledElement.OnInitialized()
StyledElement.Name
StyledElement.Classes
StyledElement.DataContext
StyledElement.IsInitialized
StyledElement.Styles
StyledElement.StyleKey
StyledElement.Resources
StyledElement.TemplatedParent
StyledElement.Theme
StyledElement.LogicalChildren
StyledElement.PseudoClasses
StyledElement.StyleKeyOverride
StyledElement.Parent
StyledElement.ActualThemeVariant
StyledElement.AttachedToLogicalTree
StyledElement.DetachedFromLogicalTree
StyledElement.DataContextChanged
StyledElement.Initialized
StyledElement.ResourcesChanged
StyledElement.ActualThemeVariantChanged
Animatable.TransitionsProperty
Animatable.OnPropertyChangedCore(AvaloniaPropertyChangedEventArgs)
Animatable.Transitions
AvaloniaObject.CheckAccess()
AvaloniaObject.VerifyAccess()
AvaloniaObject.ClearValue(AvaloniaProperty)
AvaloniaObject.ClearValue<T>(AvaloniaProperty<T>)
AvaloniaObject.ClearValue<T>(StyledProperty<T>)
AvaloniaObject.ClearValue<T>(DirectPropertyBase<T>)
AvaloniaObject.GetHashCode()
AvaloniaObject.GetValue(AvaloniaProperty)
AvaloniaObject.GetValue<T>(StyledProperty<T>)
AvaloniaObject.GetValue<T>(DirectPropertyBase<T>)
AvaloniaObject.GetBaseValue<T>(StyledProperty<T>)
AvaloniaObject.IsAnimating(AvaloniaProperty)
AvaloniaObject.IsSet(AvaloniaProperty)
AvaloniaObject.SetValue<T>(StyledProperty<T>, T, BindingPriority)
AvaloniaObject.SetValue<T>(DirectPropertyBase<T>, T)
AvaloniaObject.SetCurrentValue<T>(StyledProperty<T>, T)
AvaloniaObject.Bind(AvaloniaProperty, IBinding)
AvaloniaObject.CoerceValue(AvaloniaProperty)
AvaloniaObject.RaisePropertyChanged<T>(DirectPropertyBase<T>, T, T)
AvaloniaObject.SetAndRaise<T>(DirectPropertyBase<T>, ref T, T)
AvaloniaObject.InheritanceParent
AvaloniaObject.this[AvaloniaProperty]
AvaloniaObject.this[IndexerDescriptor]
AvaloniaObject.PropertyChanged

Constructors

FortuneWheel()

Initializes a new instance of the FortuneWheel class.

public FortuneWheel()

Fields

AnimationDurationProperty

Defines the AnimationDuration property.

public static readonly StyledProperty<TimeSpan> AnimationDurationProperty

Field Value

StyledProperty<TimeSpan>

CenterFillProperty

Defines the CenterFill property.

public static readonly StyledProperty<IBrush?> CenterFillProperty

Field Value

StyledProperty<IBrush>

CenterRadiusProperty

Defines the CenterRadius property.

public static readonly StyledProperty<double> CenterRadiusProperty

Field Value

StyledProperty<double>

IndicatorFillProperty

Defines the IndicatorFill property.

public static readonly StyledProperty<IBrush?> IndicatorFillProperty

Field Value

StyledProperty<IBrush>

IndicatorPositionProperty

Defines the IndicatorPosition property.

public static readonly StyledProperty<IndicatorPosition> IndicatorPositionProperty

Field Value

StyledProperty<IndicatorPosition>

IndicatorSizeProperty

Defines the IndicatorSize property.

public static readonly StyledProperty<double> IndicatorSizeProperty

Field Value

StyledProperty<double>

IsSpinningProperty

Defines the IsSpinning property.

public static readonly DirectProperty<FortuneWheel, bool> IsSpinningProperty

Field Value

DirectProperty<FortuneWheel, bool>

ItemsProperty

Defines the Items property.

public static readonly StyledProperty<ObservableCollection<FortuneItem>> ItemsProperty

Field Value

StyledProperty<ObservableCollection<FortuneItem>>

MinimumSpinsProperty

Defines the MinimumSpins property.

public static readonly StyledProperty<int> MinimumSpinsProperty

Field Value

StyledProperty<int>

RotationAngleProperty

Defines the RotationAngle property.

public static readonly StyledProperty<double> RotationAngleProperty

Field Value

StyledProperty<double>

SelectedIndexProperty

Defines the SelectedIndex property.

public static readonly StyledProperty<int> SelectedIndexProperty

Field Value

StyledProperty<int>

ShowIndicatorProperty

Defines the ShowIndicator property.

public static readonly StyledProperty<bool> ShowIndicatorProperty

Field Value

StyledProperty<bool>

StyleStrategyProperty

Defines the StyleStrategy property.

public static readonly StyledProperty<IStyleStrategy> StyleStrategyProperty

Field Value

StyledProperty<IStyleStrategy>

Properties

AnimationDuration

Gets or sets the duration of the spin animation.

public TimeSpan AnimationDuration { get; set; }

Property Value

TimeSpan

CenterFill

Gets or sets the fill brush for the center circle.

public IBrush? CenterFill { get; set; }

Property Value

IBrush

CenterRadius

Gets or sets the radius of the center circle.

public double CenterRadius { get; set; }

Property Value

double

IndicatorFill

Gets or sets the fill brush for the indicator.

public IBrush? IndicatorFill { get; set; }

Property Value

IBrush

IndicatorPosition

Gets or sets the position of the indicator.

public IndicatorPosition IndicatorPosition { get; set; }

Property Value

IndicatorPosition

IndicatorSize

Gets or sets the size of the indicator.

public double IndicatorSize { get; set; }

Property Value

double

IsSpinning

Gets a value indicating whether the wheel is currently spinning.

public bool IsSpinning { get; }

Property Value

bool

Items

Gets or sets the collection of items to display on the wheel.

public ObservableCollection<FortuneItem> Items { get; set; }

Property Value

ObservableCollection<FortuneItem>

MinimumSpins

Gets or sets the minimum number of full rotations during a spin.

public int MinimumSpins { get; set; }

Property Value

int

RotationAngle

Gets or sets the current rotation angle of the wheel in degrees.

public double RotationAngle { get; set; }

Property Value

double

SelectedIndex

Gets or sets the index of the currently selected item.

public int SelectedIndex { get; set; }

Property Value

int

ShowIndicator

Gets or sets whether to show the indicator pointer.

public bool ShowIndicator { get; set; }

Property Value

bool

StyleStrategy

Gets or sets the strategy used to style individual items.

public IStyleStrategy StyleStrategy { get; set; }

Property Value

IStyleStrategy

Methods

CancelAnimation()

Cancels any running animation and cleans up resources.

public void CancelAnimation()

OnDetachedFromVisualTree(VisualTreeAttachmentEventArgs)

Called when the control is removed from a rooted visual tree.

protected override void OnDetachedFromVisualTree(VisualTreeAttachmentEventArgs e)

Parameters

e VisualTreeAttachmentEventArgs

The event args.

OnKeyDown(KeyEventArgs)

Invoked when an unhandled Avalonia.Input.InputElement.KeyDownEvent reaches an element in its route that is derived from this class. Implement this method to add class handling for this event.

protected override void OnKeyDown(KeyEventArgs e)

Parameters

e KeyEventArgs

Data about the event.

OnPropertyChanged(AvaloniaPropertyChangedEventArgs)

Called when a avalonia property changes on the object.

protected override void OnPropertyChanged(AvaloniaPropertyChangedEventArgs change)

Parameters

change AvaloniaPropertyChangedEventArgs

The property change details.

Render(DrawingContext)

Renders the visual to a Avalonia.Media.DrawingContext.

public override void Render(DrawingContext context)

Parameters

context DrawingContext

The drawing context.

SpinAsync()

Spins the wheel to a random item.

public Task SpinAsync()

Returns

Task

A task that completes when the spin animation finishes.

SpinToAsync(int)

Spins the wheel to a specific item index.

public Task SpinToAsync(int targetIndex)

Parameters

targetIndex int

The index of the target item.

Returns

Task

A task that completes when the spin animation finishes.

Events

SpinCompleted

Occurs when a spin animation completes.

public event EventHandler<FortuneSelectionEventArgs>? SpinCompleted

Event Type

EventHandler<FortuneSelectionEventArgs>

SpinStarted

Occurs when a spin animation starts.

public event EventHandler<FortuneSelectionEventArgs>? SpinStarted

Event Type

EventHandler<FortuneSelectionEventArgs>