Skip to content

Commit

Permalink
Add bindings Avalonia v11.0.0 (#422)
Browse files Browse the repository at this point in the history
* add Type Alias: SubscriptionFactory<'arg>

* add SelectingItemsControl bindings.

* add ComboBox bindings.

* add HeaderedSelectingItemsControl bindings.

* add MenuItem bindings.

* add NumericUpDown bindings.

* add TreeView bindings.

* add HeaderedItemsControl bindings.

* add CalendarItem bindings.

* move CalendarItem.fs to DSL\Primitives

* add PickerPresenterBase bindings.

* add DatePickerPresenter bindings.

* add TimePickerPresenter bindings.

* add ProgressBar bindings.

* add Slider bindings.

* add ScrollBar bindings.

* add RemoteWidget bindings.

* fix Shape bindings

- fix strokeDashArray<'t>(value: double list) implementation
- rename binding name: strokeJoinCap -> strokeJoin

* add Arc bindings.

* add Rectangle bindings.

* add Sector bindings.

* update Sector bindings.

- remove create function ... TextElement is AbstractClass.
- add AttachedProperty bindings.

* add BindingEvaluator bindings.

* add LightDismissOverlayLayer bindings.

* add ExperimentalAcrylicBorder bindings.

* add ThemeVariantScope bindings.

* add VisualLayerManager bindings.

* add NativeControlHost bindings.

* add AdornerLayer bindings.

* add OverlayLayer bindings.

* add DataGridFrozenGrid bindings.

* add StackPanel bindings.

* add ReversibleStackPanel bindings.

* add VirtualizingCarouselPanel bindings.

* add VirtualizingStackPanel bindings.

* add ChromeOverlayLayer bindings.

* add SelectableTextBlock bindings.

* fix TickBar.ticks(value: seq<float>) binding implementation.

* add ContentPresenter bindings.

* add ScrollContentPresenter bindings.

* add ItemsPresenter bindings.

* add TextPresenter bindings.

* add Popup bindings.

* add AutoCompleteBox bindings.

* add Calendar bindings.

* add CalendarDatePicker bindings.

* add Button bindings.

* add DropDownButton bindings.

* add CalendarButton bindings.

* add CalendarDayButton bindings.

* add ToggleSwitch bindings.

* add DataValidationErrors bindings.

* add RefreshContainer bindings.

* add RefreshVisualizer bindings.

* update ScrollViewer bindings.

- add missing bindings.
- change attached bindings
  - allowAutoHide
- remove bindings that setter is not accessible.
  - extent
  - viewport
  - isExpanded
  - smallChange
  - largeChange

* add ToggleSplitButton bindings.

* add SplitView bindings.

* add Expander bindings.
  • Loading branch information
SilkyFowl committed Jun 4, 2024
1 parent 1c7686e commit 28e60d4
Show file tree
Hide file tree
Showing 58 changed files with 1,608 additions and 116 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ module CanvasDemo =
Line.startPoint (120.0, 185.0)
Line.endPoint (30.0, 115.0)
Line.strokeLineCap PenLineCap.Round
Line.strokeJoinCap PenLineJoin.Bevel
Line.strokeJoin PenLineJoin.Bevel
Line.stroke "red"
Line.strokeThickness 2.0
]
Expand Down
30 changes: 29 additions & 1 deletion src/Avalonia.FuncUI/Avalonia.FuncUI.fsproj
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,16 @@
<Compile Include="DSL\Base\StyledElement.fs" />
<Compile Include="DSL\Base\Panel.fs" />
<Compile Include="DSL\Base\ContentPresenter.fs" />
<Compile Include="DSL\Base\ScrollContentPresenter.fs" />
<Compile Include="DSL\Base\ItemsPresenter.fs" />
<Compile Include="DSL\Base\TextPresenter.fs" />
<Compile Include="DSL\Base\Animatable.fs" />
<Compile Include="DSL\Base\RenderOptions.fs" />
<Compile Include="DSL\Primitives\LightDismissOverlayLayer.fs" />
<Compile Include="DSL\Primitives\VisualLayerManager.fs" />
<Compile Include="DSL\Primitives\AdornerLayer.fs" />
<Compile Include="DSL\Primitives\OverlayLayer.fs" />
<Compile Include="DSL\Primitives\ChromeOverlayLayer.fs" />
<Compile Include="DSL\Primitives\TemplatedControl.fs" />
<Compile Include="DSL\Primitives\HeaderedContentControl.fs" />
<Compile Include="DSL\Primitives\HeaderedSelectingItemsControl.fs" />
Expand All @@ -83,19 +91,28 @@
<Compile Include="DSL\Primitives\Thumb.fs" />
<Compile Include="DSL\Primitives\AccessText.fs" />
<Compile Include="DSL\Primitives\ScrollBar.fs" />
<Compile Include="DSL\Primitives\CalendarItem.fs" />
<Compile Include="DSL\Primitives\PickerPresenterBase.fs" />
<Compile Include="DSL\Primitives\TextElement.fs" />
<Compile Include="DSL\Panels\Canvas.fs" />
<Compile Include="DSL\Panels\DockPanel.fs" />
<Compile Include="DSL\Panels\Grid.fs" />
<Compile Include="DSL\Panels\StackPanel.fs" />
<Compile Include="DSL\Panels\ReversibleStackPanel.fs" />
<Compile Include="DSL\Panels\VirtualizingCarouselPanel.fs" />
<Compile Include="DSL\Panels\VirtualizingStackPanel.fs" />
<Compile Include="DSL\Panels\WrapPanel.fs" />
<Compile Include="DSL\Shapes\Shape.fs" />
<Compile Include="DSL\Shapes\Arc.fs" />
<Compile Include="DSL\Shapes\Rectangle.fs" />
<Compile Include="DSL\Shapes\Ellipse.fs" />
<Compile Include="DSL\Shapes\Line.fs" />
<Compile Include="DSL\Shapes\Polyline.fs" />
<Compile Include="DSL\Shapes\Polygon.fs" />
<Compile Include="DSL\Shapes\Path.fs" />
<Compile Include="DSL\Shapes\Sector.fs" />
<Compile Include="DSL\Calendar\CalendarButton.fs" />
<Compile Include="DSL\Calendar\CalendarDayButton.fs" />
<Compile Include="DSL\Calendar\Calendar.fs" />
<Compile Include="DSL\Calendar\CalendarDatePicker.fs" />
<Compile Include="DSL\Documents\TextDecoration.fs" />
Expand All @@ -108,27 +125,36 @@
<Compile Include="DSL\Documents\Underline.fs" />
<Compile Include="DSL\Documents\InlineUIContainer.fs" />
<Compile Include="DSL\Buttons\Button.fs" />
<Compile Include="DSL\Buttons\DropDownButton.fs" />
<Compile Include="DSL\Buttons\ButtonSpinner.fs" />
<Compile Include="DSL\Buttons\SplitButton.fs" />
<Compile Include="DSL\Buttons\RadioButton.fs" />
<Compile Include="DSL\Buttons\ToggleButton.fs" />
<Compile Include="DSL\Buttons\ToggleSplitButton.fs" />
<Compile Include="DSL\Buttons\ToggleSwitch.fs" />
<Compile Include="DSL\Buttons\CheckBox.fs" />
<Compile Include="DSL\Remote\RemoteWidget.fs" />
<Compile Include="DSL\RepeatButton.fs" />
<Compile Include="DSL\DatePicker.fs" />
<Compile Include="DSL\TimePicker.fs" />
<Compile Include="DSL\Flyout.fs" />
<Compile Include="DSL\ItemsControl.fs" />
<Compile Include="DSL\ContentControl.fs" />
<Compile Include="DSL\TransitioningContentControl.fs" />
<Compile Include="DSL\BindingEvaluator.fs" />
<Compile Include="DSL\AutoCompleteBox.fs" />
<Compile Include="DSL\NumericUpDown.fs" />
<Compile Include="DSL\Border.fs" />
<Compile Include="DSL\Decorator.fs" />
<Compile Include="DSL\Border.fs" />
<Compile Include="DSL\ExperimentalAcrylicBorder.fs" />
<Compile Include="DSL\ThemeVariantScope.fs" />
<Compile Include="DSL\DataValidationErrors.fs" />
<Compile Include="DSL\ComboBoxItem.fs" />
<Compile Include="DSL\ComboBox.fs" />
<Compile Include="DSL\RefreshContainer.fs" />
<Compile Include="DSL\RefreshVisualizer.fs" />
<Compile Include="DSL\Carousel.fs" />
<Compile Include="DSL\NativeControlHost.fs" />
<Compile Include="DSL\Image.fs" />
<Compile Include="DSL\ListBox.fs" />
<Compile Include="DSL\RangeBase.fs" />
Expand All @@ -138,6 +164,8 @@
<Compile Include="DSL\ContextMenu.fs" />
<Compile Include="DSL\MenuItem.fs" />
<Compile Include="DSL\GridSplitter.fs" />
<Compile Include="DSL\DatePickerPresenter.fs" />
<Compile Include="DSL\TimePickerPresenter.fs" />
<Compile Include="DSL\ProgressBar.fs" />
<Compile Include="DSL\ScrollViewer.fs" />
<Compile Include="DSL\Separator.fs" />
Expand Down
90 changes: 90 additions & 0 deletions src/Avalonia.FuncUI/DSL/AutoCompleteBox.fs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ module AutoCompleteBox =
open Avalonia.Controls.Templates
open Avalonia.FuncUI.Types
open Avalonia.FuncUI.Builder
open System.ComponentModel
open Avalonia.Data

let create (attrs: IAttr<AutoCompleteBox> list): IView<AutoCompleteBox> =
ViewBuilder.Create<AutoCompleteBox>(attrs)
Expand Down Expand Up @@ -44,6 +46,13 @@ module AutoCompleteBox =
static member isDropDownOpen<'t when 't :> AutoCompleteBox>(value: bool) : IAttr<'t> =
AttrBuilder<'t>.CreateProperty<bool>(AutoCompleteBox.IsDropDownOpenProperty, value, ValueNone)

static member valueMemberBinding<'t when 't :> AutoCompleteBox>(binding: IBinding) : IAttr<'t> =
let name = nameof Unchecked.defaultof<'t>.ValueMemberBinding
let getter: 't -> IBinding = (fun control -> control.ValueMemberBinding)
let setter: 't * IBinding -> unit = (fun (control, value) -> control.ValueMemberBinding <- value)

AttrBuilder<'t>.CreateProperty<IBinding>(name, binding, ValueSome getter, ValueSome setter, ValueNone)

static member selectedItem<'t when 't :> AutoCompleteBox>(value: obj) : IAttr<'t> =
AttrBuilder<'t>.CreateProperty<obj>(AutoCompleteBox.SelectedItemProperty, value, ValueNone)

Expand All @@ -56,9 +65,87 @@ module AutoCompleteBox =
static member onTextChanged<'t when 't :> AutoCompleteBox>(func: string -> unit, ?subPatchOptions) =
AttrBuilder<'t>.CreateSubscription<string>(AutoCompleteBox.TextProperty, func, ?subPatchOptions = subPatchOptions)

static member onPopulating<'t when 't :> AutoCompleteBox>(func: PopulatingEventArgs -> unit, ?subPatchOptions) =
let name = nameof Unchecked.defaultof<'t>.Populating
let factory: SubscriptionFactory<PopulatingEventArgs> =
fun (control, func, token) ->
let control = control :?> 't
let handler = EventHandler<PopulatingEventArgs>(fun sender args -> func args)
let event = control.Populating

event.AddHandler(handler)
token.Register(fun () -> event.RemoveHandler(handler)) |> ignore

AttrBuilder<'t>.CreateSubscription<PopulatingEventArgs>(name, factory, func, ?subPatchOptions = subPatchOptions)

static member onPopulated<'t when 't :> AutoCompleteBox>(func: PopulatedEventArgs -> unit, ?subPatchOptions) =
let name = nameof Unchecked.defaultof<'t>.Populated
let factory: SubscriptionFactory<PopulatedEventArgs> =
fun (control, func, token) ->
let control = control :?> 't
let handler = EventHandler<PopulatedEventArgs>(fun sender args -> func args)
let event = control.Populated

event.AddHandler(handler)
token.Register(fun () -> event.RemoveHandler(handler)) |> ignore

AttrBuilder<'t>.CreateSubscription<PopulatedEventArgs>(name, factory, func, ?subPatchOptions = subPatchOptions)

static member onSearchTextChanged<'t when 't :> AutoCompleteBox>(func: string -> unit, ?subPatchOptions) =
AttrBuilder<'t>.CreateSubscription<string>(AutoCompleteBox.SearchTextProperty, func, ?subPatchOptions = subPatchOptions)

static member onDropDownOpening<'t when 't :> AutoCompleteBox>(func: 't * CancelEventArgs -> unit, ?subPatchOptions) =
let name = nameof Unchecked.defaultof<'t>.DropDownOpening
let factory: SubscriptionFactory<'t * CancelEventArgs> =
fun (control, func, token) ->
let control = control :?> 't
let handler = EventHandler<CancelEventArgs>(fun sender args -> func (sender :?> 't, args))
let event = control.DropDownOpening

event.AddHandler(handler)
token.Register(fun () -> event.RemoveHandler(handler)) |> ignore

AttrBuilder<'t>.CreateSubscription<'t * CancelEventArgs>(name, factory, func, ?subPatchOptions = subPatchOptions)

static member onDropDownOpened<'t when 't :> AutoCompleteBox>(func: 't -> unit, ?subPatchOptions) =
let name = nameof Unchecked.defaultof<'t>.DropDownOpened
let factory: SubscriptionFactory<'t> =
fun (control, func, token) ->
let control = control :?> 't
let handler = EventHandler(fun sender args -> func (sender :?> 't))
let event = control.DropDownOpened

event.AddHandler(handler)
token.Register(fun () -> event.RemoveHandler(handler)) |> ignore

AttrBuilder<'t>.CreateSubscription<'t>(name, factory, func, ?subPatchOptions = subPatchOptions)

static member onDropDownClosing<'t when 't :> AutoCompleteBox>(func: 't * CancelEventArgs -> unit, ?subPatchOptions) =
let name = nameof Unchecked.defaultof<'t>.DropDownClosing
let factory: SubscriptionFactory<'t * CancelEventArgs> =
fun (control, func, token) ->
let control = control :?> 't
let handler = EventHandler<CancelEventArgs>(fun sender args -> func (sender :?> 't, args))
let event = control.DropDownClosing

event.AddHandler(handler)
token.Register(fun () -> event.RemoveHandler(handler)) |> ignore

AttrBuilder<'t>.CreateSubscription<'t * CancelEventArgs>(name, factory, func, ?subPatchOptions = subPatchOptions)

static member onDropDownClosed<'t when 't :> AutoCompleteBox>(func: 't -> unit, ?subPatchOptions) =
let name = nameof Unchecked.defaultof<'t>.DropDownClosed
let factory: SubscriptionFactory<'t> =
fun (control, func, token) ->
let control = control :?> 't
let handler = EventHandler(fun sender args -> func (sender :?> 't))
let event = control.DropDownClosed

event.AddHandler(handler)
token.Register(fun () -> event.RemoveHandler(handler)) |> ignore

AttrBuilder<'t>.CreateSubscription<'t>(name, factory, func, ?subPatchOptions = subPatchOptions)

static member filterMode<'t when 't :> AutoCompleteBox>(mode: AutoCompleteFilterMode) : IAttr<'t> =
AttrBuilder<'t>.CreateProperty<AutoCompleteFilterMode>(AutoCompleteBox.FilterModeProperty, mode, ValueNone)

Expand All @@ -72,6 +159,9 @@ module AutoCompleteBox =
static member textFilter<'t when 't :> AutoCompleteBox>(filterFunc: string -> obj -> bool) : IAttr<'t> =
AttrBuilder<'t>.CreateProperty<_>(AutoCompleteBox.TextFilterProperty, filterFunc, ValueNone)

static member textSelector<'t when 't :> AutoCompleteBox>(selector: AutoCompleteSelector<string>) : IAttr<'t> =
AttrBuilder<'t>.CreateProperty<_>(AutoCompleteBox.TextSelectorProperty, selector, ValueNone)

static member dataItems<'t when 't :> AutoCompleteBox>(items: IEnumerable) : IAttr<'t> =
AttrBuilder<'t>.CreateProperty<IEnumerable>(AutoCompleteBox.ItemsSourceProperty, items, ValueNone)

Expand Down
Loading

0 comments on commit 28e60d4

Please sign in to comment.