feat: WIP.

This commit is contained in:
rabbitism
2024-04-27 14:28:24 +08:00
parent 1576af3fc7
commit 6abfb645b0
3 changed files with 38 additions and 6 deletions

View File

@@ -153,7 +153,7 @@
Focusable="False"
Theme="{DynamicResource InnerIconButton}" />
<Popup
Name="{x:Static u:TimePicker.PART_Popup}"
Name="{x:Static iri:PartNames.PART_Popup}"
Grid.Column="0"
IsLightDismissEnabled="True"
IsOpen="{TemplateBinding IsDropdownOpen,

View File

@@ -6,19 +6,19 @@ using Avalonia.Controls.Primitives;
using Avalonia.Data;
using Avalonia.Input;
using Avalonia.Interactivity;
using Irihi.Avalonia.Shared.Common;
using Irihi.Avalonia.Shared.Contracts;
using Irihi.Avalonia.Shared.Helpers;
namespace Ursa.Controls;
[TemplatePart(PART_TextBox, typeof(TextBox))]
[TemplatePart(PART_Popup, typeof(Popup))]
[TemplatePart(PartNames.PART_Popup, typeof(Popup))]
[TemplatePart(PART_Presenter, typeof(TimePickerPresenter))]
[TemplatePart(PART_Button, typeof(Button))]
public class TimePicker : TemplatedControl, IClearControl, IInnerContentControl, IPopupInnerContent
{
public const string PART_TextBox = "PART_TextBox";
public const string PART_Popup = "PART_Popup";
public const string PART_Presenter = "PART_Presenter";
public const string PART_Button = "PART_Button";
@@ -157,7 +157,7 @@ public class TimePicker : TemplatedControl, IClearControl, IInnerContentControl,
Button.ClickEvent.RemoveHandler(OnButtonClick, _button);
_textBox = e.NameScope.Find<TextBox>(PART_TextBox);
_popup = e.NameScope.Find<Popup>(PART_Popup);
_popup = e.NameScope.Find<Popup>(PartNames.PART_Popup);
_presenter = e.NameScope.Find<TimePickerPresenter>(PART_Presenter);
_button = e.NameScope.Find<Button>(PART_Button);

View File

@@ -1,8 +1,40 @@
using Avalonia.Controls.Primitives;
using Avalonia;
using Avalonia.Controls;
using Avalonia.Controls.Metadata;
using Avalonia.Controls.Primitives;
using Irihi.Avalonia.Shared.Common;
namespace Ursa.Controls;
[TemplatePart(PART_StartTextBox, typeof(TextBox))]
[TemplatePart(PART_EndTextBox, typeof(TextBox))]
[TemplatePart(PartNames.PART_Popup, typeof(Popup))]
[TemplatePart(PART_StartPresenter, typeof(TimePickerPresenter))]
[TemplatePart(PART_EndPresenter, typeof(TimePickerPresenter))]
[TemplatePart(PART_Button, typeof(Button))]
public class TimeRangePicker: TemplatedControl
{
public const string PART_StartTextBox = "PART_StartTextBox";
public const string PART_EndTextBox = "PART_EndTextBox";
public const string PART_StartPresenter = "PART_StartPresenter";
public const string PART_EndPresenter = "PART_EndPresenter";
public const string PART_Button = "PART_Button";
public static readonly StyledProperty<TimeSpan?> StartTimeProperty = AvaloniaProperty.Register<TimeRangePicker, TimeSpan?>(
nameof(StartTime));
public TimeSpan? StartTime
{
get => GetValue(StartTimeProperty);
set => SetValue(StartTimeProperty, value);
}
public static readonly StyledProperty<TimeSpan?> EndTimeProperty = AvaloniaProperty.Register<TimeRangePicker, TimeSpan?>(
nameof(EndTime));
public TimeSpan? EndTime
{
get => GetValue(EndTimeProperty);
set => SetValue(EndTimeProperty, value);
}
}