From 12e3702003ebf2c99be6b324ca2de383c04149d5 Mon Sep 17 00:00:00 2001 From: noberumotto Date: Sun, 26 Dec 2021 05:10:34 +0800 Subject: [PATCH] =?UTF-8?q?=E2=80=9C=E8=AF=A6=E7=BB=86=E2=80=9D=E9=A1=B5?= =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E6=8C=89=E5=B9=B4=E6=9F=A5=E7=9C=8B=E8=A7=86?= =?UTF-8?q?=E5=9B=BE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- UI/Controls/DatePickerBar/DatePickerBar.cs | 4 ++++ .../DatePickerBar/DatePickerShowType.cs | 4 ++++ UI/Models/DataPageModel.cs | 10 ++++++++ UI/Themes/DatePickerBar/DatePickerBar.xaml | 8 ++++--- UI/ViewModels/DataPageVM.cs | 23 +++++++++++++++---- UI/Views/DataPage.xaml | 7 ++++++ 6 files changed, 49 insertions(+), 7 deletions(-) diff --git a/UI/Controls/DatePickerBar/DatePickerBar.cs b/UI/Controls/DatePickerBar/DatePickerBar.cs index 04bde1b..1a77a9e 100644 --- a/UI/Controls/DatePickerBar/DatePickerBar.cs +++ b/UI/Controls/DatePickerBar/DatePickerBar.cs @@ -175,6 +175,10 @@ namespace UI.Controls.DatePickerBar MonthsList.SelectedItemChanged += DateChanged; } + if(ShowType== DatePickerShowType.Year) + { + SelectedDateString = SelectedDate.ToString("yyyy"); + } } private void DateChanged(object sender, EventArgs e) diff --git a/UI/Controls/DatePickerBar/DatePickerShowType.cs b/UI/Controls/DatePickerBar/DatePickerShowType.cs index 2c29042..436da8c 100644 --- a/UI/Controls/DatePickerBar/DatePickerShowType.cs +++ b/UI/Controls/DatePickerBar/DatePickerShowType.cs @@ -19,5 +19,9 @@ namespace UI.Controls.DatePickerBar /// 月 /// Month, + /// + /// 年 + /// + Year, } } diff --git a/UI/Models/DataPageModel.cs b/UI/Models/DataPageModel.cs index 410f146..625fdf2 100644 --- a/UI/Models/DataPageModel.cs +++ b/UI/Models/DataPageModel.cs @@ -64,5 +64,15 @@ namespace UI.Models get { return MonthDate_; } set { MonthDate_ = value; OnPropertyChanged(); } } + + private DateTime YearDate_; + /// + /// date + /// + public DateTime YearDate + { + get { return YearDate_; } + set { YearDate_ = value; OnPropertyChanged(); } + } } } diff --git a/UI/Themes/DatePickerBar/DatePickerBar.xaml b/UI/Themes/DatePickerBar/DatePickerBar.xaml index 76496f3..3d154c8 100644 --- a/UI/Themes/DatePickerBar/DatePickerBar.xaml +++ b/UI/Themes/DatePickerBar/DatePickerBar.xaml @@ -86,7 +86,7 @@ - + - + @@ -135,7 +135,9 @@ - + + + diff --git a/UI/ViewModels/DataPageVM.cs b/UI/ViewModels/DataPageVM.cs index 88fec52..12a5cb7 100644 --- a/UI/ViewModels/DataPageVM.cs +++ b/UI/ViewModels/DataPageVM.cs @@ -40,7 +40,7 @@ namespace UI.ViewModels TabbarData = new System.Collections.ObjectModel.ObservableCollection() { - "按天查看","按月查看" + "按天查看","按月查看","按年查看" }; TabbarSelectedIndex = 0; @@ -83,7 +83,7 @@ namespace UI.ViewModels } } - else + else if (TabbarSelectedIndex == 1) { if (MonthDate == DateTime.MinValue) { @@ -94,6 +94,17 @@ namespace UI.ViewModels LoadData(MonthDate); } } + else if (TabbarSelectedIndex == 2) + { + if (YearDate == DateTime.MinValue) + { + YearDate = new DateTime(DateTime.Now.Year, DateTime.Now.Month, 1); + } + else + { + LoadData(YearDate); + } + } } } @@ -113,11 +124,15 @@ namespace UI.ViewModels dateStart = new DateTime(date.Year, date.Month, 1); dateEnd = new DateTime(date.Year, date.Month, DateTime.DaysInMonth(date.Year, date.Month)); } - else + else if (TabbarSelectedIndex == 0) { dateStart = new DateTime(date.Year, date.Month, date.Day, 0, 0, 0); dateEnd = new DateTime(date.Year, date.Month, date.Day, 23, 59, 59); - + } + else if (TabbarSelectedIndex == 2) + { + dateStart = new DateTime(date.Year, 1, 1, 0, 0, 0); + dateEnd = new DateTime(date.Year, 12, DateTime.DaysInMonth(date.Year, 12), 23, 59, 59); } var list = data.GetDateRangelogList(dateStart, dateEnd); Data = MapToChartsData(list); diff --git a/UI/Views/DataPage.xaml b/UI/Views/DataPage.xaml index d5042e5..484f821 100644 --- a/UI/Views/DataPage.xaml +++ b/UI/Views/DataPage.xaml @@ -45,6 +45,13 @@ + + + + + + + -- GitLab