From df98634fd262803a9c247609333d846dcb559a77 Mon Sep 17 00:00:00 2001 From: cliuff Date: Sun, 7 Apr 2024 18:22:46 +0700 Subject: [PATCH] =?UTF-8?q?=E5=BF=AB=E9=80=9F=E5=88=87=E6=8D=A2=E7=9B=B8?= =?UTF-8?q?=E9=82=BB=E6=97=A5=E6=9C=9F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- UI/Controls/Select/DateSelect.cs | 26 ++++++++++++++++++++++++++ UI/Themes/Select/DateSelect.xaml | 24 ++++++++++++++---------- 2 files changed, 40 insertions(+), 10 deletions(-) diff --git a/UI/Controls/Select/DateSelect.cs b/UI/Controls/Select/DateSelect.cs index 3fef81b..ca42cd7 100644 --- a/UI/Controls/Select/DateSelect.cs +++ b/UI/Controls/Select/DateSelect.cs @@ -152,6 +152,7 @@ private static void OnPropertyChanged(DependencyObject d, DependencyPropertyChan public Command ShowSelectCommand { get; set; } public Command SetYearCommand { get; set; } public Command SetMonthCommand { get; set; } + public Command SwitchDateCommand { get; set; } public Command DoneCommand { get; set; } private bool IsFirstClick = false; @@ -164,6 +165,7 @@ public DateSelect() ShowSelectCommand = new Command(new Action(OnShowSelect)); SetYearCommand = new Command(new Action(OnSetYear)); SetMonthCommand = new Command(new Action(OnSetMonth)); + SwitchDateCommand = new Command(new Action(OnSwitchDate)); DoneCommand = new Command(new Action(OnDone)); @@ -249,6 +251,30 @@ private void OnDone(object obj) IsOpen = false; } + private void OnSwitchDate(object obj) + { + var newDate = Day != null ? Day.Day : new DateTime(Year, Month, 1); + if (SelectType == DateSelectType.Day) + { + newDate = newDate.AddDays(int.Parse(obj.ToString())); + } + else if (SelectType == DateSelectType.Month) + { + newDate = newDate.AddMonths(int.Parse(obj.ToString())); + } + else if (SelectType == DateSelectType.Year) + { + newDate = newDate.AddYears(int.Parse(obj.ToString())); + } + Year = newDate.Year; + Month = newDate.Month; + Date = newDate; + SelectedDay = newDate; + + UpdateDays(); + UpdateDateStr(); + } + private void OnSetMonth(object obj) { int newMonth = Month + int.Parse(obj.ToString()); diff --git a/UI/Themes/Select/DateSelect.xaml b/UI/Themes/Select/DateSelect.xaml index b16ab1c..b086537 100644 --- a/UI/Themes/Select/DateSelect.xaml +++ b/UI/Themes/Select/DateSelect.xaml @@ -22,16 +22,20 @@ - - - - - - - - - - + + + + + + + + + + + + + +