Picker conmpleted
This commit is contained in:
@@ -5,13 +5,13 @@ using Microsoft.Maui.Handlers;
|
|||||||
using Microsoft.Maui.Graphics;
|
using Microsoft.Maui.Graphics;
|
||||||
using Microsoft.Maui.Controls;
|
using Microsoft.Maui.Controls;
|
||||||
using Microsoft.Maui.Platform;
|
using Microsoft.Maui.Platform;
|
||||||
using SkiaSharp;
|
|
||||||
using System.Collections.Specialized;
|
using System.Collections.Specialized;
|
||||||
|
|
||||||
namespace Microsoft.Maui.Platform.Linux.Handlers;
|
namespace Microsoft.Maui.Platform.Linux.Handlers;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Handler for Picker on Linux using Skia rendering.
|
/// Handler for Picker on Linux using Skia rendering.
|
||||||
|
/// Maps IPicker interface to SkiaPicker platform view.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public partial class PickerHandler : ViewHandler<IPicker, SkiaPicker>
|
public partial class PickerHandler : ViewHandler<IPicker, SkiaPicker>
|
||||||
{
|
{
|
||||||
@@ -27,6 +27,7 @@ public partial class PickerHandler : ViewHandler<IPicker, SkiaPicker>
|
|||||||
[nameof(IPicker.HorizontalTextAlignment)] = MapHorizontalTextAlignment,
|
[nameof(IPicker.HorizontalTextAlignment)] = MapHorizontalTextAlignment,
|
||||||
[nameof(IPicker.VerticalTextAlignment)] = MapVerticalTextAlignment,
|
[nameof(IPicker.VerticalTextAlignment)] = MapVerticalTextAlignment,
|
||||||
[nameof(IView.Background)] = MapBackground,
|
[nameof(IView.Background)] = MapBackground,
|
||||||
|
[nameof(IView.IsEnabled)] = MapIsEnabled,
|
||||||
[nameof(Picker.ItemsSource)] = MapItemsSource,
|
[nameof(Picker.ItemsSource)] = MapItemsSource,
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -63,8 +64,17 @@ public partial class PickerHandler : ViewHandler<IPicker, SkiaPicker>
|
|||||||
_itemsCollection.CollectionChanged += OnItemsCollectionChanged;
|
_itemsCollection.CollectionChanged += OnItemsCollectionChanged;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Load items
|
// Load items and sync properties
|
||||||
ReloadItems();
|
ReloadItems();
|
||||||
|
|
||||||
|
if (VirtualView != null)
|
||||||
|
{
|
||||||
|
MapTitle(this, VirtualView);
|
||||||
|
MapTitleColor(this, VirtualView);
|
||||||
|
MapTextColor(this, VirtualView);
|
||||||
|
MapSelectedIndex(this, VirtualView);
|
||||||
|
MapIsEnabled(this, VirtualView);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void DisconnectHandler(SkiaPicker platformView)
|
protected override void DisconnectHandler(SkiaPicker platformView)
|
||||||
@@ -85,11 +95,14 @@ public partial class PickerHandler : ViewHandler<IPicker, SkiaPicker>
|
|||||||
ReloadItems();
|
ReloadItems();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void OnSelectedIndexChanged(object? sender, EventArgs e)
|
private void OnSelectedIndexChanged(object? sender, SelectedIndexChangedEventArgs e)
|
||||||
{
|
{
|
||||||
if (VirtualView is null || PlatformView is null) return;
|
if (VirtualView is null || PlatformView is null) return;
|
||||||
|
|
||||||
VirtualView.SelectedIndex = PlatformView.SelectedIndex;
|
if (VirtualView.SelectedIndex != e.NewIndex)
|
||||||
|
{
|
||||||
|
VirtualView.SelectedIndex = e.NewIndex;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void ReloadItems()
|
private void ReloadItems()
|
||||||
@@ -111,22 +124,26 @@ public partial class PickerHandler : ViewHandler<IPicker, SkiaPicker>
|
|||||||
if (handler.PlatformView is null) return;
|
if (handler.PlatformView is null) return;
|
||||||
if (picker.TitleColor is not null)
|
if (picker.TitleColor is not null)
|
||||||
{
|
{
|
||||||
handler.PlatformView.TitleColor = picker.TitleColor.ToSKColor();
|
handler.PlatformView.TitleColor = picker.TitleColor;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void MapSelectedIndex(PickerHandler handler, IPicker picker)
|
public static void MapSelectedIndex(PickerHandler handler, IPicker picker)
|
||||||
{
|
{
|
||||||
if (handler.PlatformView is null) return;
|
if (handler.PlatformView is null) return;
|
||||||
|
|
||||||
|
if (handler.PlatformView.SelectedIndex != picker.SelectedIndex)
|
||||||
|
{
|
||||||
handler.PlatformView.SelectedIndex = picker.SelectedIndex;
|
handler.PlatformView.SelectedIndex = picker.SelectedIndex;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public static void MapTextColor(PickerHandler handler, IPicker picker)
|
public static void MapTextColor(PickerHandler handler, IPicker picker)
|
||||||
{
|
{
|
||||||
if (handler.PlatformView is null) return;
|
if (handler.PlatformView is null) return;
|
||||||
if (picker.TextColor is not null)
|
if (picker.TextColor is not null)
|
||||||
{
|
{
|
||||||
handler.PlatformView.TextColor = picker.TextColor.ToSKColor();
|
handler.PlatformView.TextColor = picker.TextColor;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -141,7 +158,7 @@ public partial class PickerHandler : ViewHandler<IPicker, SkiaPicker>
|
|||||||
}
|
}
|
||||||
if (font.Size > 0)
|
if (font.Size > 0)
|
||||||
{
|
{
|
||||||
handler.PlatformView.FontSize = (float)font.Size;
|
handler.PlatformView.FontSize = font.Size;
|
||||||
}
|
}
|
||||||
handler.PlatformView.Invalidate();
|
handler.PlatformView.Invalidate();
|
||||||
}
|
}
|
||||||
@@ -171,6 +188,13 @@ public partial class PickerHandler : ViewHandler<IPicker, SkiaPicker>
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void MapIsEnabled(PickerHandler handler, IPicker picker)
|
||||||
|
{
|
||||||
|
if (handler.PlatformView is null) return;
|
||||||
|
handler.PlatformView.IsEnabled = picker.IsEnabled;
|
||||||
|
handler.PlatformView.Invalidate();
|
||||||
|
}
|
||||||
|
|
||||||
public static void MapItemsSource(PickerHandler handler, IPicker picker)
|
public static void MapItemsSource(PickerHandler handler, IPicker picker)
|
||||||
{
|
{
|
||||||
handler.ReloadItems();
|
handler.ReloadItems();
|
||||||
|
|||||||
@@ -1,32 +1,49 @@
|
|||||||
// Licensed to the .NET Foundation under one or more agreements.
|
// Licensed to the .NET Foundation under one or more agreements.
|
||||||
// The .NET Foundation licenses this file to you under the MIT license.
|
// The .NET Foundation licenses this file to you under the MIT license.
|
||||||
|
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using Microsoft.Maui.Controls;
|
||||||
|
using Microsoft.Maui.Graphics;
|
||||||
using SkiaSharp;
|
using SkiaSharp;
|
||||||
|
|
||||||
namespace Microsoft.Maui.Platform;
|
namespace Microsoft.Maui.Platform;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Skia-rendered picker/dropdown control with full XAML styling support.
|
/// Skia-rendered picker/dropdown control with full MAUI compliance.
|
||||||
|
/// Implements IPicker interface requirements:
|
||||||
|
/// - Title, TitleColor for placeholder
|
||||||
|
/// - SelectedIndex, SelectedItem for selection
|
||||||
|
/// - TextColor, Font properties for styling
|
||||||
|
/// - Items collection
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class SkiaPicker : SkiaView
|
public class SkiaPicker : SkiaView
|
||||||
{
|
{
|
||||||
|
#region SKColor Helper
|
||||||
|
|
||||||
|
private static SKColor ToSKColor(Color? color)
|
||||||
|
{
|
||||||
|
if (color == null) return SKColors.Transparent;
|
||||||
|
return new SKColor(
|
||||||
|
(byte)(color.Red * 255),
|
||||||
|
(byte)(color.Green * 255),
|
||||||
|
(byte)(color.Blue * 255),
|
||||||
|
(byte)(color.Alpha * 255));
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
#region BindableProperties
|
#region BindableProperties
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Bindable property for SelectedIndex.
|
|
||||||
/// </summary>
|
|
||||||
public static readonly BindableProperty SelectedIndexProperty =
|
public static readonly BindableProperty SelectedIndexProperty =
|
||||||
BindableProperty.Create(
|
BindableProperty.Create(
|
||||||
nameof(SelectedIndex),
|
nameof(SelectedIndex),
|
||||||
typeof(int),
|
typeof(int),
|
||||||
typeof(SkiaPicker),
|
typeof(SkiaPicker),
|
||||||
-1,
|
-1,
|
||||||
BindingMode.OneWay,
|
BindingMode.TwoWay,
|
||||||
propertyChanged: (b, o, n) => ((SkiaPicker)b).OnSelectedIndexChanged());
|
propertyChanged: (b, o, n) => ((SkiaPicker)b).OnSelectedIndexChanged((int)o, (int)n));
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Bindable property for Title.
|
|
||||||
/// </summary>
|
|
||||||
public static readonly BindableProperty TitleProperty =
|
public static readonly BindableProperty TitleProperty =
|
||||||
BindableProperty.Create(
|
BindableProperty.Create(
|
||||||
nameof(Title),
|
nameof(Title),
|
||||||
@@ -36,81 +53,60 @@ public class SkiaPicker : SkiaView
|
|||||||
BindingMode.TwoWay,
|
BindingMode.TwoWay,
|
||||||
propertyChanged: (b, o, n) => ((SkiaPicker)b).Invalidate());
|
propertyChanged: (b, o, n) => ((SkiaPicker)b).Invalidate());
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Bindable property for TextColor.
|
|
||||||
/// </summary>
|
|
||||||
public static readonly BindableProperty TextColorProperty =
|
public static readonly BindableProperty TextColorProperty =
|
||||||
BindableProperty.Create(
|
BindableProperty.Create(
|
||||||
nameof(TextColor),
|
nameof(TextColor),
|
||||||
typeof(SKColor),
|
typeof(Color),
|
||||||
typeof(SkiaPicker),
|
typeof(SkiaPicker),
|
||||||
SKColors.Black,
|
Colors.Black,
|
||||||
BindingMode.TwoWay,
|
BindingMode.TwoWay,
|
||||||
propertyChanged: (b, o, n) => ((SkiaPicker)b).Invalidate());
|
propertyChanged: (b, o, n) => ((SkiaPicker)b).Invalidate());
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Bindable property for TitleColor.
|
|
||||||
/// </summary>
|
|
||||||
public static readonly BindableProperty TitleColorProperty =
|
public static readonly BindableProperty TitleColorProperty =
|
||||||
BindableProperty.Create(
|
BindableProperty.Create(
|
||||||
nameof(TitleColor),
|
nameof(TitleColor),
|
||||||
typeof(SKColor),
|
typeof(Color),
|
||||||
typeof(SkiaPicker),
|
typeof(SkiaPicker),
|
||||||
new SKColor(0x80, 0x80, 0x80),
|
Color.FromRgb(0x80, 0x80, 0x80),
|
||||||
BindingMode.TwoWay,
|
BindingMode.TwoWay,
|
||||||
propertyChanged: (b, o, n) => ((SkiaPicker)b).Invalidate());
|
propertyChanged: (b, o, n) => ((SkiaPicker)b).Invalidate());
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Bindable property for BorderColor.
|
|
||||||
/// </summary>
|
|
||||||
public static readonly BindableProperty BorderColorProperty =
|
public static readonly BindableProperty BorderColorProperty =
|
||||||
BindableProperty.Create(
|
BindableProperty.Create(
|
||||||
nameof(BorderColor),
|
nameof(BorderColor),
|
||||||
typeof(SKColor),
|
typeof(Color),
|
||||||
typeof(SkiaPicker),
|
typeof(SkiaPicker),
|
||||||
new SKColor(0xBD, 0xBD, 0xBD),
|
Color.FromRgb(0xBD, 0xBD, 0xBD),
|
||||||
BindingMode.TwoWay,
|
BindingMode.TwoWay,
|
||||||
propertyChanged: (b, o, n) => ((SkiaPicker)b).Invalidate());
|
propertyChanged: (b, o, n) => ((SkiaPicker)b).Invalidate());
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Bindable property for DropdownBackgroundColor.
|
|
||||||
/// </summary>
|
|
||||||
public static readonly BindableProperty DropdownBackgroundColorProperty =
|
public static readonly BindableProperty DropdownBackgroundColorProperty =
|
||||||
BindableProperty.Create(
|
BindableProperty.Create(
|
||||||
nameof(DropdownBackgroundColor),
|
nameof(DropdownBackgroundColor),
|
||||||
typeof(SKColor),
|
typeof(Color),
|
||||||
typeof(SkiaPicker),
|
typeof(SkiaPicker),
|
||||||
SKColors.White,
|
Colors.White,
|
||||||
BindingMode.TwoWay,
|
BindingMode.TwoWay,
|
||||||
propertyChanged: (b, o, n) => ((SkiaPicker)b).Invalidate());
|
propertyChanged: (b, o, n) => ((SkiaPicker)b).Invalidate());
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Bindable property for SelectedItemBackgroundColor.
|
|
||||||
/// </summary>
|
|
||||||
public static readonly BindableProperty SelectedItemBackgroundColorProperty =
|
public static readonly BindableProperty SelectedItemBackgroundColorProperty =
|
||||||
BindableProperty.Create(
|
BindableProperty.Create(
|
||||||
nameof(SelectedItemBackgroundColor),
|
nameof(SelectedItemBackgroundColor),
|
||||||
typeof(SKColor),
|
typeof(Color),
|
||||||
typeof(SkiaPicker),
|
typeof(SkiaPicker),
|
||||||
new SKColor(0x21, 0x96, 0xF3, 0x30),
|
Color.FromRgba(0x21, 0x96, 0xF3, 0x30),
|
||||||
BindingMode.TwoWay,
|
BindingMode.TwoWay,
|
||||||
propertyChanged: (b, o, n) => ((SkiaPicker)b).Invalidate());
|
propertyChanged: (b, o, n) => ((SkiaPicker)b).Invalidate());
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Bindable property for HoverItemBackgroundColor.
|
|
||||||
/// </summary>
|
|
||||||
public static readonly BindableProperty HoverItemBackgroundColorProperty =
|
public static readonly BindableProperty HoverItemBackgroundColorProperty =
|
||||||
BindableProperty.Create(
|
BindableProperty.Create(
|
||||||
nameof(HoverItemBackgroundColor),
|
nameof(HoverItemBackgroundColor),
|
||||||
typeof(SKColor),
|
typeof(Color),
|
||||||
typeof(SkiaPicker),
|
typeof(SkiaPicker),
|
||||||
new SKColor(0xE0, 0xE0, 0xE0),
|
Color.FromRgb(0xE0, 0xE0, 0xE0),
|
||||||
BindingMode.TwoWay,
|
BindingMode.TwoWay,
|
||||||
propertyChanged: (b, o, n) => ((SkiaPicker)b).Invalidate());
|
propertyChanged: (b, o, n) => ((SkiaPicker)b).Invalidate());
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Bindable property for FontFamily.
|
|
||||||
/// </summary>
|
|
||||||
public static readonly BindableProperty FontFamilyProperty =
|
public static readonly BindableProperty FontFamilyProperty =
|
||||||
BindableProperty.Create(
|
BindableProperty.Create(
|
||||||
nameof(FontFamily),
|
nameof(FontFamily),
|
||||||
@@ -120,39 +116,30 @@ public class SkiaPicker : SkiaView
|
|||||||
BindingMode.TwoWay,
|
BindingMode.TwoWay,
|
||||||
propertyChanged: (b, o, n) => ((SkiaPicker)b).InvalidateMeasure());
|
propertyChanged: (b, o, n) => ((SkiaPicker)b).InvalidateMeasure());
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Bindable property for FontSize.
|
|
||||||
/// </summary>
|
|
||||||
public static readonly BindableProperty FontSizeProperty =
|
public static readonly BindableProperty FontSizeProperty =
|
||||||
BindableProperty.Create(
|
BindableProperty.Create(
|
||||||
nameof(FontSize),
|
nameof(FontSize),
|
||||||
typeof(float),
|
typeof(double),
|
||||||
typeof(SkiaPicker),
|
typeof(SkiaPicker),
|
||||||
14f,
|
14.0,
|
||||||
BindingMode.TwoWay,
|
BindingMode.TwoWay,
|
||||||
propertyChanged: (b, o, n) => ((SkiaPicker)b).InvalidateMeasure());
|
propertyChanged: (b, o, n) => ((SkiaPicker)b).InvalidateMeasure());
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Bindable property for ItemHeight.
|
|
||||||
/// </summary>
|
|
||||||
public static readonly BindableProperty ItemHeightProperty =
|
public static readonly BindableProperty ItemHeightProperty =
|
||||||
BindableProperty.Create(
|
BindableProperty.Create(
|
||||||
nameof(ItemHeight),
|
nameof(ItemHeight),
|
||||||
typeof(float),
|
typeof(double),
|
||||||
typeof(SkiaPicker),
|
typeof(SkiaPicker),
|
||||||
40f,
|
40.0,
|
||||||
BindingMode.TwoWay,
|
BindingMode.TwoWay,
|
||||||
propertyChanged: (b, o, n) => ((SkiaPicker)b).Invalidate());
|
propertyChanged: (b, o, n) => ((SkiaPicker)b).Invalidate());
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Bindable property for CornerRadius.
|
|
||||||
/// </summary>
|
|
||||||
public static readonly BindableProperty CornerRadiusProperty =
|
public static readonly BindableProperty CornerRadiusProperty =
|
||||||
BindableProperty.Create(
|
BindableProperty.Create(
|
||||||
nameof(CornerRadius),
|
nameof(CornerRadius),
|
||||||
typeof(float),
|
typeof(double),
|
||||||
typeof(SkiaPicker),
|
typeof(SkiaPicker),
|
||||||
4f,
|
4.0,
|
||||||
BindingMode.TwoWay,
|
BindingMode.TwoWay,
|
||||||
propertyChanged: (b, o, n) => ((SkiaPicker)b).Invalidate());
|
propertyChanged: (b, o, n) => ((SkiaPicker)b).Invalidate());
|
||||||
|
|
||||||
@@ -181,54 +168,54 @@ public class SkiaPicker : SkiaView
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets or sets the text color.
|
/// Gets or sets the text color.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public SKColor TextColor
|
public Color TextColor
|
||||||
{
|
{
|
||||||
get => (SKColor)GetValue(TextColorProperty);
|
get => (Color)GetValue(TextColorProperty);
|
||||||
set => SetValue(TextColorProperty, value);
|
set => SetValue(TextColorProperty, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets or sets the title color.
|
/// Gets or sets the title color.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public SKColor TitleColor
|
public Color TitleColor
|
||||||
{
|
{
|
||||||
get => (SKColor)GetValue(TitleColorProperty);
|
get => (Color)GetValue(TitleColorProperty);
|
||||||
set => SetValue(TitleColorProperty, value);
|
set => SetValue(TitleColorProperty, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets or sets the border color.
|
/// Gets or sets the border color.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public SKColor BorderColor
|
public Color BorderColor
|
||||||
{
|
{
|
||||||
get => (SKColor)GetValue(BorderColorProperty);
|
get => (Color)GetValue(BorderColorProperty);
|
||||||
set => SetValue(BorderColorProperty, value);
|
set => SetValue(BorderColorProperty, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets or sets the dropdown background color.
|
/// Gets or sets the dropdown background color.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public SKColor DropdownBackgroundColor
|
public Color DropdownBackgroundColor
|
||||||
{
|
{
|
||||||
get => (SKColor)GetValue(DropdownBackgroundColorProperty);
|
get => (Color)GetValue(DropdownBackgroundColorProperty);
|
||||||
set => SetValue(DropdownBackgroundColorProperty, value);
|
set => SetValue(DropdownBackgroundColorProperty, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets or sets the selected item background color.
|
/// Gets or sets the selected item background color.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public SKColor SelectedItemBackgroundColor
|
public Color SelectedItemBackgroundColor
|
||||||
{
|
{
|
||||||
get => (SKColor)GetValue(SelectedItemBackgroundColorProperty);
|
get => (Color)GetValue(SelectedItemBackgroundColorProperty);
|
||||||
set => SetValue(SelectedItemBackgroundColorProperty, value);
|
set => SetValue(SelectedItemBackgroundColorProperty, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets or sets the hover item background color.
|
/// Gets or sets the hover item background color.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public SKColor HoverItemBackgroundColor
|
public Color HoverItemBackgroundColor
|
||||||
{
|
{
|
||||||
get => (SKColor)GetValue(HoverItemBackgroundColorProperty);
|
get => (Color)GetValue(HoverItemBackgroundColorProperty);
|
||||||
set => SetValue(HoverItemBackgroundColorProperty, value);
|
set => SetValue(HoverItemBackgroundColorProperty, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -244,27 +231,27 @@ public class SkiaPicker : SkiaView
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets or sets the font size.
|
/// Gets or sets the font size.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public float FontSize
|
public double FontSize
|
||||||
{
|
{
|
||||||
get => (float)GetValue(FontSizeProperty);
|
get => (double)GetValue(FontSizeProperty);
|
||||||
set => SetValue(FontSizeProperty, value);
|
set => SetValue(FontSizeProperty, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets or sets the item height.
|
/// Gets or sets the item height.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public float ItemHeight
|
public double ItemHeight
|
||||||
{
|
{
|
||||||
get => (float)GetValue(ItemHeightProperty);
|
get => (double)GetValue(ItemHeightProperty);
|
||||||
set => SetValue(ItemHeightProperty, value);
|
set => SetValue(ItemHeightProperty, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets or sets the corner radius.
|
/// Gets or sets the corner radius.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public float CornerRadius
|
public double CornerRadius
|
||||||
{
|
{
|
||||||
get => (float)GetValue(CornerRadiusProperty);
|
get => (double)GetValue(CornerRadiusProperty);
|
||||||
set => SetValue(CornerRadiusProperty, value);
|
set => SetValue(CornerRadiusProperty, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -304,27 +291,45 @@ public class SkiaPicker : SkiaView
|
|||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
#region Private Fields
|
||||||
|
|
||||||
private readonly List<string> _items = new();
|
private readonly List<string> _items = new();
|
||||||
private bool _isOpen;
|
private bool _isOpen;
|
||||||
private float _dropdownMaxHeight = 200;
|
private double _dropdownMaxHeight = 200;
|
||||||
private int _hoveredItemIndex = -1;
|
private int _hoveredItemIndex = -1;
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region Events
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Event raised when selected index changes.
|
/// Event raised when selected index changes.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public event EventHandler? SelectedIndexChanged;
|
public event EventHandler<SelectedIndexChangedEventArgs>? SelectedIndexChanged;
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region Constructor
|
||||||
|
|
||||||
public SkiaPicker()
|
public SkiaPicker()
|
||||||
{
|
{
|
||||||
IsFocusable = true;
|
IsFocusable = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void OnSelectedIndexChanged()
|
#endregion
|
||||||
|
|
||||||
|
#region Event Handlers
|
||||||
|
|
||||||
|
private void OnSelectedIndexChanged(int oldValue, int newValue)
|
||||||
{
|
{
|
||||||
SelectedIndexChanged?.Invoke(this, EventArgs.Empty);
|
SelectedIndexChanged?.Invoke(this, new SelectedIndexChangedEventArgs(oldValue, newValue));
|
||||||
Invalidate();
|
Invalidate();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region Public Methods
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Sets the items in the picker.
|
/// Sets the items in the picker.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -339,10 +344,13 @@ public class SkiaPicker : SkiaView
|
|||||||
Invalidate();
|
Invalidate();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region Rendering
|
||||||
|
|
||||||
private void DrawDropdownOverlay(SKCanvas canvas)
|
private void DrawDropdownOverlay(SKCanvas canvas)
|
||||||
{
|
{
|
||||||
if (_items.Count == 0 || !_isOpen) return;
|
if (_items.Count == 0 || !_isOpen) return;
|
||||||
// Use ScreenBounds for overlay drawing to account for scroll offset
|
|
||||||
DrawDropdown(canvas, ScreenBounds);
|
DrawDropdown(canvas, ScreenBounds);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -353,21 +361,30 @@ public class SkiaPicker : SkiaView
|
|||||||
|
|
||||||
private void DrawPickerButton(SKCanvas canvas, SKRect bounds)
|
private void DrawPickerButton(SKCanvas canvas, SKRect bounds)
|
||||||
{
|
{
|
||||||
|
var cornerRadius = (float)CornerRadius;
|
||||||
|
var fontSize = (float)FontSize;
|
||||||
|
|
||||||
|
// Get colors
|
||||||
|
var textColorSK = ToSKColor(TextColor);
|
||||||
|
var titleColorSK = ToSKColor(TitleColor);
|
||||||
|
var borderColorSK = ToSKColor(BorderColor);
|
||||||
|
var focusColorSK = ToSKColor(Color.FromRgb(0x21, 0x96, 0xF3));
|
||||||
|
|
||||||
// Draw background
|
// Draw background
|
||||||
using var bgPaint = new SKPaint
|
using var bgPaint = new SKPaint
|
||||||
{
|
{
|
||||||
Color = IsEnabled ? BackgroundColor : new SKColor(0xF5, 0xF5, 0xF5),
|
Color = IsEnabled ? BackgroundColor : ToSKColor(Color.FromRgb(0xF5, 0xF5, 0xF5)),
|
||||||
Style = SKPaintStyle.Fill,
|
Style = SKPaintStyle.Fill,
|
||||||
IsAntialias = true
|
IsAntialias = true
|
||||||
};
|
};
|
||||||
|
|
||||||
var buttonRect = new SKRoundRect(bounds, CornerRadius);
|
var buttonRect = new SKRoundRect(bounds, cornerRadius);
|
||||||
canvas.DrawRoundRect(buttonRect, bgPaint);
|
canvas.DrawRoundRect(buttonRect, bgPaint);
|
||||||
|
|
||||||
// Draw border
|
// Draw border
|
||||||
using var borderPaint = new SKPaint
|
using var borderPaint = new SKPaint
|
||||||
{
|
{
|
||||||
Color = IsFocused ? new SKColor(0x21, 0x96, 0xF3) : BorderColor,
|
Color = IsFocused ? focusColorSK : borderColorSK,
|
||||||
Style = SKPaintStyle.Stroke,
|
Style = SKPaintStyle.Stroke,
|
||||||
StrokeWidth = IsFocused ? 2 : 1,
|
StrokeWidth = IsFocused ? 2 : 1,
|
||||||
IsAntialias = true
|
IsAntialias = true
|
||||||
@@ -375,7 +392,7 @@ public class SkiaPicker : SkiaView
|
|||||||
canvas.DrawRoundRect(buttonRect, borderPaint);
|
canvas.DrawRoundRect(buttonRect, borderPaint);
|
||||||
|
|
||||||
// Draw text or title
|
// Draw text or title
|
||||||
using var font = new SKFont(SKTypeface.Default, FontSize);
|
using var font = new SKFont(SKTypeface.Default, fontSize);
|
||||||
using var textPaint = new SKPaint(font)
|
using var textPaint = new SKPaint(font)
|
||||||
{
|
{
|
||||||
IsAntialias = true
|
IsAntialias = true
|
||||||
@@ -385,12 +402,12 @@ public class SkiaPicker : SkiaView
|
|||||||
if (SelectedIndex >= 0 && SelectedIndex < _items.Count)
|
if (SelectedIndex >= 0 && SelectedIndex < _items.Count)
|
||||||
{
|
{
|
||||||
displayText = _items[SelectedIndex];
|
displayText = _items[SelectedIndex];
|
||||||
textPaint.Color = IsEnabled ? TextColor : TextColor.WithAlpha(128);
|
textPaint.Color = IsEnabled ? textColorSK : textColorSK.WithAlpha(128);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
displayText = Title;
|
displayText = Title;
|
||||||
textPaint.Color = TitleColor;
|
textPaint.Color = titleColorSK;
|
||||||
}
|
}
|
||||||
|
|
||||||
var textBounds = new SKRect();
|
var textBounds = new SKRect();
|
||||||
@@ -401,14 +418,14 @@ public class SkiaPicker : SkiaView
|
|||||||
canvas.DrawText(displayText, textX, textY, textPaint);
|
canvas.DrawText(displayText, textX, textY, textPaint);
|
||||||
|
|
||||||
// Draw dropdown arrow
|
// Draw dropdown arrow
|
||||||
DrawDropdownArrow(canvas, bounds);
|
DrawDropdownArrow(canvas, bounds, textColorSK);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void DrawDropdownArrow(SKCanvas canvas, SKRect bounds)
|
private void DrawDropdownArrow(SKCanvas canvas, SKRect bounds, SKColor color)
|
||||||
{
|
{
|
||||||
using var paint = new SKPaint
|
using var paint = new SKPaint
|
||||||
{
|
{
|
||||||
Color = IsEnabled ? TextColor : TextColor.WithAlpha(128),
|
Color = IsEnabled ? color : color.WithAlpha(128),
|
||||||
Style = SKPaintStyle.Stroke,
|
Style = SKPaintStyle.Stroke,
|
||||||
StrokeWidth = 2,
|
StrokeWidth = 2,
|
||||||
IsAntialias = true,
|
IsAntialias = true,
|
||||||
@@ -440,13 +457,25 @@ public class SkiaPicker : SkiaView
|
|||||||
{
|
{
|
||||||
if (_items.Count == 0) return;
|
if (_items.Count == 0) return;
|
||||||
|
|
||||||
var dropdownHeight = Math.Min(_items.Count * ItemHeight, _dropdownMaxHeight);
|
var itemHeight = (float)ItemHeight;
|
||||||
|
var cornerRadius = (float)CornerRadius;
|
||||||
|
var fontSize = (float)FontSize;
|
||||||
|
var dropdownMaxHeight = (float)_dropdownMaxHeight;
|
||||||
|
|
||||||
|
var dropdownHeight = Math.Min(_items.Count * itemHeight, dropdownMaxHeight);
|
||||||
var dropdownRect = new SKRect(
|
var dropdownRect = new SKRect(
|
||||||
bounds.Left,
|
bounds.Left,
|
||||||
bounds.Bottom + 4,
|
bounds.Bottom + 4,
|
||||||
bounds.Right,
|
bounds.Right,
|
||||||
bounds.Bottom + 4 + dropdownHeight);
|
bounds.Bottom + 4 + dropdownHeight);
|
||||||
|
|
||||||
|
// Get colors
|
||||||
|
var dropdownBgColorSK = ToSKColor(DropdownBackgroundColor);
|
||||||
|
var borderColorSK = ToSKColor(BorderColor);
|
||||||
|
var textColorSK = ToSKColor(TextColor);
|
||||||
|
var selectedBgColorSK = ToSKColor(SelectedItemBackgroundColor);
|
||||||
|
var hoverBgColorSK = ToSKColor(HoverItemBackgroundColor);
|
||||||
|
|
||||||
// Draw shadow
|
// Draw shadow
|
||||||
using var shadowPaint = new SKPaint
|
using var shadowPaint = new SKPaint
|
||||||
{
|
{
|
||||||
@@ -455,52 +484,52 @@ public class SkiaPicker : SkiaView
|
|||||||
Style = SKPaintStyle.Fill
|
Style = SKPaintStyle.Fill
|
||||||
};
|
};
|
||||||
var shadowRect = new SKRect(dropdownRect.Left + 2, dropdownRect.Top + 2, dropdownRect.Right + 2, dropdownRect.Bottom + 2);
|
var shadowRect = new SKRect(dropdownRect.Left + 2, dropdownRect.Top + 2, dropdownRect.Right + 2, dropdownRect.Bottom + 2);
|
||||||
canvas.DrawRoundRect(new SKRoundRect(shadowRect, CornerRadius), shadowPaint);
|
canvas.DrawRoundRect(new SKRoundRect(shadowRect, cornerRadius), shadowPaint);
|
||||||
|
|
||||||
// Draw dropdown background
|
// Draw dropdown background
|
||||||
using var bgPaint = new SKPaint
|
using var bgPaint = new SKPaint
|
||||||
{
|
{
|
||||||
Color = DropdownBackgroundColor,
|
Color = dropdownBgColorSK,
|
||||||
Style = SKPaintStyle.Fill,
|
Style = SKPaintStyle.Fill,
|
||||||
IsAntialias = true
|
IsAntialias = true
|
||||||
};
|
};
|
||||||
canvas.DrawRoundRect(new SKRoundRect(dropdownRect, CornerRadius), bgPaint);
|
canvas.DrawRoundRect(new SKRoundRect(dropdownRect, cornerRadius), bgPaint);
|
||||||
|
|
||||||
// Draw border
|
// Draw border
|
||||||
using var borderPaint = new SKPaint
|
using var borderPaint = new SKPaint
|
||||||
{
|
{
|
||||||
Color = BorderColor,
|
Color = borderColorSK,
|
||||||
Style = SKPaintStyle.Stroke,
|
Style = SKPaintStyle.Stroke,
|
||||||
StrokeWidth = 1,
|
StrokeWidth = 1,
|
||||||
IsAntialias = true
|
IsAntialias = true
|
||||||
};
|
};
|
||||||
canvas.DrawRoundRect(new SKRoundRect(dropdownRect, CornerRadius), borderPaint);
|
canvas.DrawRoundRect(new SKRoundRect(dropdownRect, cornerRadius), borderPaint);
|
||||||
|
|
||||||
// Clip to dropdown bounds
|
// Clip to dropdown bounds
|
||||||
canvas.Save();
|
canvas.Save();
|
||||||
canvas.ClipRoundRect(new SKRoundRect(dropdownRect, CornerRadius));
|
canvas.ClipRoundRect(new SKRoundRect(dropdownRect, cornerRadius));
|
||||||
|
|
||||||
// Draw items
|
// Draw items
|
||||||
using var font = new SKFont(SKTypeface.Default, FontSize);
|
using var font = new SKFont(SKTypeface.Default, fontSize);
|
||||||
using var textPaint = new SKPaint(font)
|
using var textPaint = new SKPaint(font)
|
||||||
{
|
{
|
||||||
Color = TextColor,
|
Color = textColorSK,
|
||||||
IsAntialias = true
|
IsAntialias = true
|
||||||
};
|
};
|
||||||
|
|
||||||
for (int i = 0; i < _items.Count; i++)
|
for (int i = 0; i < _items.Count; i++)
|
||||||
{
|
{
|
||||||
var itemTop = dropdownRect.Top + i * ItemHeight;
|
var itemTop = dropdownRect.Top + i * itemHeight;
|
||||||
if (itemTop > dropdownRect.Bottom) break;
|
if (itemTop > dropdownRect.Bottom) break;
|
||||||
|
|
||||||
var itemRect = new SKRect(dropdownRect.Left, itemTop, dropdownRect.Right, itemTop + ItemHeight);
|
var itemRect = new SKRect(dropdownRect.Left, itemTop, dropdownRect.Right, itemTop + itemHeight);
|
||||||
|
|
||||||
// Draw item background
|
// Draw item background
|
||||||
if (i == SelectedIndex)
|
if (i == SelectedIndex)
|
||||||
{
|
{
|
||||||
using var selectedPaint = new SKPaint
|
using var selectedPaint = new SKPaint
|
||||||
{
|
{
|
||||||
Color = SelectedItemBackgroundColor,
|
Color = selectedBgColorSK,
|
||||||
Style = SKPaintStyle.Fill
|
Style = SKPaintStyle.Fill
|
||||||
};
|
};
|
||||||
canvas.DrawRect(itemRect, selectedPaint);
|
canvas.DrawRect(itemRect, selectedPaint);
|
||||||
@@ -509,7 +538,7 @@ public class SkiaPicker : SkiaView
|
|||||||
{
|
{
|
||||||
using var hoverPaint = new SKPaint
|
using var hoverPaint = new SKPaint
|
||||||
{
|
{
|
||||||
Color = HoverItemBackgroundColor,
|
Color = hoverBgColorSK,
|
||||||
Style = SKPaintStyle.Fill
|
Style = SKPaintStyle.Fill
|
||||||
};
|
};
|
||||||
canvas.DrawRect(itemRect, hoverPaint);
|
canvas.DrawRect(itemRect, hoverPaint);
|
||||||
@@ -527,18 +556,23 @@ public class SkiaPicker : SkiaView
|
|||||||
canvas.Restore();
|
canvas.Restore();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region Pointer Events
|
||||||
|
|
||||||
public override void OnPointerPressed(PointerEventArgs e)
|
public override void OnPointerPressed(PointerEventArgs e)
|
||||||
{
|
{
|
||||||
if (!IsEnabled) return;
|
if (!IsEnabled) return;
|
||||||
|
|
||||||
|
var itemHeight = (float)ItemHeight;
|
||||||
|
|
||||||
if (IsOpen)
|
if (IsOpen)
|
||||||
{
|
{
|
||||||
// Use ScreenBounds for popup coordinate calculations (accounts for scroll offset)
|
|
||||||
var screenBounds = ScreenBounds;
|
var screenBounds = ScreenBounds;
|
||||||
var dropdownTop = screenBounds.Bottom + 4;
|
var dropdownTop = screenBounds.Bottom + 4;
|
||||||
if (e.Y >= dropdownTop)
|
if (e.Y >= dropdownTop)
|
||||||
{
|
{
|
||||||
var itemIndex = (int)((e.Y - dropdownTop) / ItemHeight);
|
var itemIndex = (int)((e.Y - dropdownTop) / itemHeight);
|
||||||
if (itemIndex >= 0 && itemIndex < _items.Count)
|
if (itemIndex >= 0 && itemIndex < _items.Count)
|
||||||
{
|
{
|
||||||
SelectedIndex = itemIndex;
|
SelectedIndex = itemIndex;
|
||||||
@@ -551,6 +585,7 @@ public class SkiaPicker : SkiaView
|
|||||||
IsOpen = true;
|
IsOpen = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
e.Handled = true;
|
||||||
Invalidate();
|
Invalidate();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -558,12 +593,13 @@ public class SkiaPicker : SkiaView
|
|||||||
{
|
{
|
||||||
if (!_isOpen) return;
|
if (!_isOpen) return;
|
||||||
|
|
||||||
// Use ScreenBounds for popup coordinate calculations (accounts for scroll offset)
|
var itemHeight = (float)ItemHeight;
|
||||||
var screenBounds = ScreenBounds;
|
var screenBounds = ScreenBounds;
|
||||||
var dropdownTop = screenBounds.Bottom + 4;
|
var dropdownTop = screenBounds.Bottom + 4;
|
||||||
|
|
||||||
if (e.Y >= dropdownTop)
|
if (e.Y >= dropdownTop)
|
||||||
{
|
{
|
||||||
var newHovered = (int)((e.Y - dropdownTop) / ItemHeight);
|
var newHovered = (int)((e.Y - dropdownTop) / itemHeight);
|
||||||
if (newHovered != _hoveredItemIndex && newHovered >= 0 && newHovered < _items.Count)
|
if (newHovered != _hoveredItemIndex && newHovered >= 0 && newHovered < _items.Count)
|
||||||
{
|
{
|
||||||
_hoveredItemIndex = newHovered;
|
_hoveredItemIndex = newHovered;
|
||||||
@@ -586,6 +622,10 @@ public class SkiaPicker : SkiaView
|
|||||||
Invalidate();
|
Invalidate();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region Keyboard Events
|
||||||
|
|
||||||
public override void OnKeyDown(KeyEventArgs e)
|
public override void OnKeyDown(KeyEventArgs e)
|
||||||
{
|
{
|
||||||
if (!IsEnabled) return;
|
if (!IsEnabled) return;
|
||||||
@@ -623,9 +663,29 @@ public class SkiaPicker : SkiaView
|
|||||||
e.Handled = true;
|
e.Handled = true;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case Key.Home:
|
||||||
|
if (_items.Count > 0)
|
||||||
|
{
|
||||||
|
SelectedIndex = 0;
|
||||||
|
e.Handled = true;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case Key.End:
|
||||||
|
if (_items.Count > 0)
|
||||||
|
{
|
||||||
|
SelectedIndex = _items.Count - 1;
|
||||||
|
e.Handled = true;
|
||||||
|
}
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region Lifecycle
|
||||||
|
|
||||||
public override void OnFocusLost()
|
public override void OnFocusLost()
|
||||||
{
|
{
|
||||||
base.OnFocusLost();
|
base.OnFocusLost();
|
||||||
@@ -635,6 +695,18 @@ public class SkiaPicker : SkiaView
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected override void OnEnabledChanged()
|
||||||
|
{
|
||||||
|
base.OnEnabledChanged();
|
||||||
|
SkiaVisualStateManager.GoToState(this, IsEnabled
|
||||||
|
? SkiaVisualStateManager.CommonStates.Normal
|
||||||
|
: SkiaVisualStateManager.CommonStates.Disabled);
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region Layout
|
||||||
|
|
||||||
protected override SKSize MeasureOverride(SKSize availableSize)
|
protected override SKSize MeasureOverride(SKSize availableSize)
|
||||||
{
|
{
|
||||||
return new SKSize(
|
return new SKSize(
|
||||||
@@ -642,12 +714,15 @@ public class SkiaPicker : SkiaView
|
|||||||
40);
|
40);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region Hit Testing
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Override to include dropdown area in hit testing.
|
/// Override to include dropdown area in hit testing.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
protected override bool HitTestPopupArea(float x, float y)
|
protected override bool HitTestPopupArea(float x, float y)
|
||||||
{
|
{
|
||||||
// Use ScreenBounds for hit testing (accounts for scroll offset)
|
|
||||||
var screenBounds = ScreenBounds;
|
var screenBounds = ScreenBounds;
|
||||||
|
|
||||||
// Always include the picker button itself
|
// Always include the picker button itself
|
||||||
@@ -657,7 +732,9 @@ public class SkiaPicker : SkiaView
|
|||||||
// When open, also include the dropdown area
|
// When open, also include the dropdown area
|
||||||
if (_isOpen && _items.Count > 0)
|
if (_isOpen && _items.Count > 0)
|
||||||
{
|
{
|
||||||
var dropdownHeight = Math.Min(_items.Count * ItemHeight, _dropdownMaxHeight);
|
var itemHeight = (float)ItemHeight;
|
||||||
|
var dropdownMaxHeight = (float)_dropdownMaxHeight;
|
||||||
|
var dropdownHeight = Math.Min(_items.Count * itemHeight, dropdownMaxHeight);
|
||||||
var dropdownRect = new SKRect(
|
var dropdownRect = new SKRect(
|
||||||
screenBounds.Left,
|
screenBounds.Left,
|
||||||
screenBounds.Bottom + 4,
|
screenBounds.Bottom + 4,
|
||||||
@@ -669,4 +746,28 @@ public class SkiaPicker : SkiaView
|
|||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Event args for selected index changed events.
|
||||||
|
/// </summary>
|
||||||
|
public class SelectedIndexChangedEventArgs : EventArgs
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Gets the old selected index.
|
||||||
|
/// </summary>
|
||||||
|
public int OldIndex { get; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets the new selected index.
|
||||||
|
/// </summary>
|
||||||
|
public int NewIndex { get; }
|
||||||
|
|
||||||
|
public SelectedIndexChangedEventArgs(int oldIndex, int newIndex)
|
||||||
|
{
|
||||||
|
OldIndex = oldIndex;
|
||||||
|
NewIndex = newIndex;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user