123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172 |
- using CommunityToolkit.Mvvm.ComponentModel;
- using CommunityToolkit.Mvvm.Input;
- using DialogHostAvalonia;
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace InABox.Avalonia.Components.DateSelector;
- public partial class DateSelectorViewModel : ObservableObject, IPopupViewModel<DateTime?>, IViewModelBase
- {
- [ObservableProperty]
- private DateTime? _date;
- public bool IsClosed { get; private set; }
- public bool BackButtonVisible { get; set; }
- public bool ProgressVisible { get; set; }
- public AvaloniaMenuItemCollection PrimaryMenu { get; set; } = new();
- public AvaloniaMenuItemCollection SecondaryMenu { get; set; } = new();
- private DateTime? _result;
- public DateTime? GetResult()
- {
- return _result;
- }
- public void Close(DateTime? result)
- {
- _result = result;
- IsClosed = true;
- DialogHost.GetDialogSession(null)?.Close();
- }
- public Task Activate()
- {
- return Task.CompletedTask;
- }
- public Task Deactivate()
- {
- return Task.CompletedTask;
- }
- [RelayCommand]
- private void Cancel()
- {
- Close(null);
- }
- [RelayCommand]
- private void Clear()
- {
- Close(DateTime.MinValue);
- }
- [RelayCommand]
- private void Today()
- {
- Close(DateTime.Today);
- }
- [RelayCommand]
- private void Select()
- {
- Close(Date);
- }
- }
|