| | |
| | | using System.Collections.Generic; |
| | | using HDL_ON.DAL.Server; |
| | | using HDL_ON.Entity; |
| | | using HDL_ON.Stan; |
| | | using HDL_ON.UI.CSS; |
| | | using Shared; |
| | | namespace HDL_ON.UI |
| | |
| | | Button infoView1_DateInfo_PreClickButton; |
| | | Button infoView1_DateInfo_DateTextButton; |
| | | Button infoView1_DateInfo_NextClickButton; |
| | | Button infoView1_DateInfo_NextIconButton; |
| | | Button infoView1_DateInfo_PreIconButton; |
| | | QueryType tempQueryType = QueryType.day_hour; |
| | | int tempQueryTime_Day = DateTime.Now.Day; |
| | | int tempQueryTime_Month = DateTime.Now.Month; |
| | | int tempQueryTime_Year = DateTime.Now.Year; |
| | | string tempQueryTimeString = DateTime.Now.ToString("yyyy/MM/dd"); |
| | | |
| | | |
| | | FrameLayout infoView2; |
| | |
| | | Button infoView2_DateInfo_PreClickButton; |
| | | Button infoView2_DateInfo_DateTextButton; |
| | | Button infoView2_DateInfo_NextClickButton; |
| | | Button infoView2_DateInfo_NextIconButton; |
| | | Button infoView2_DateInfo_PreIconButton; |
| | | QueryType waterQueryType = QueryType.day_hour; |
| | | int waterQueryTime_Day = DateTime.Now.Day; |
| | | int waterQueryTime_Month = DateTime.Now.Month; |
| | | int waterQueryTime_Year = DateTime.Now.Year; |
| | | string waterQueryTimeString = DateTime.Now.ToString("yyyy/MM/dd"); |
| | | |
| | | |
| | | public WetarHeaterJinmaoHistoryPage(Function deviceFunction) |
| | |
| | | }; |
| | | infoView1.AddChidren(infoView1_DateInfoView); |
| | | |
| | | var infoView1_DateInfo_PreIconButton = new Button() |
| | | infoView1_DateInfo_PreIconButton = new Button() |
| | | { |
| | | X = Application.GetRealWidth(18), |
| | | Gravity = Gravity.CenterVertical, |
| | |
| | | Gravity = Gravity.Center, |
| | | Width = Application.GetRealWidth(200), |
| | | TextAlignment = TextAlignment.Center, |
| | | Text = "2024-8-12", |
| | | Text = DateTime.Now.ToString("yyyy-MM-dd"), |
| | | TextColor = CSS_Color.FirstLevelTitleColor, |
| | | IsBold = true, |
| | | TextSize = 16, |
| | |
| | | infoView1_DateInfoView.AddChidren(infoView1_DateInfo_DateTextButton); |
| | | |
| | | |
| | | var infoView1_DateInfo_NextIconButton = new Button() |
| | | infoView1_DateInfo_NextIconButton = new Button() |
| | | { |
| | | X = Application.GetRealWidth(343 - 18 - 6), |
| | | Gravity = Gravity.CenterVertical, |
| | |
| | | |
| | | infoView1_DateInfo_NextClickButton = new Button() |
| | | { |
| | | X = Application.GetRealWidth(343 - 18 - 6 -32), |
| | | Width = Application.GetRealWidth(32 + 6), |
| | | }; |
| | | infoView1_DateInfoView.AddChidren(infoView1_DateInfo_NextClickButton); |
| | |
| | | }; |
| | | infoView2.AddChidren(infoView2_DateInfoView); |
| | | |
| | | var infoView2_DateInfo_PreIconButton = new Button() |
| | | infoView2_DateInfo_PreIconButton = new Button() |
| | | { |
| | | X = Application.GetRealWidth(18), |
| | | Gravity = Gravity.CenterVertical, |
| | |
| | | Gravity = Gravity.Center, |
| | | Width = Application.GetRealWidth(200), |
| | | TextAlignment = TextAlignment.Center, |
| | | Text = "2024-8-12", |
| | | Text = DateTime.Now.ToString("yyyy-MM-dd"), |
| | | TextColor = CSS_Color.FirstLevelTitleColor, |
| | | IsBold = true, |
| | | TextSize = 16, |
| | | }; |
| | | infoView2_DateInfoView.AddChidren(infoView2_DateInfo_DateTextButton); |
| | | |
| | | var infoView2_DateInfo_NextIconButton = new Button() |
| | | infoView2_DateInfo_NextIconButton = new Button() |
| | | { |
| | | X = Application.GetRealWidth(343 - 18 - 6), |
| | | Gravity = Gravity.CenterVertical, |
| | |
| | | |
| | | infoView2_DateInfo_NextClickButton = new Button() |
| | | { |
| | | X = Application.GetRealWidth(343 - 18 - 6 -32), |
| | | Width = Application.GetRealWidth(32 + 6), |
| | | }; |
| | | infoView2_DateInfoView.AddChidren(infoView2_DateInfo_NextClickButton); |
| | |
| | | { |
| | | Height = Application.GetRealWidth(26) |
| | | }); |
| | | |
| | | initQueryButton(); |
| | | } |
| | | |
| | | |
| | | /// <summary> |
| | | /// 读取温度值历史数据 |
| | | /// hour=近24小时、day_hour =某日24小时、week=近一周、month = 近一月、custom_month=某年某月 y/M、custom_year=某年 y |
| | | /// </summary> |
| | | private void getTempHistory(string queryType) |
| | | private void getTempHistory() |
| | | { |
| | | if (MainPage.NoLoginMode) |
| | | { |
| | | return; |
| | | } |
| | | |
| | | var loadPage = new Loading() |
| | | { |
| | | LodingBackgroundColor = 0x88888888, |
| | |
| | | loadPage.Start(Language.StringByID(StringId.PleaseWait)); |
| | | }); |
| | | |
| | | var revertObj = new HttpServerRequest().GetSensorHistory(queryType, function.deviceId, WaterHeaterJinmao_AttrEnum.temp.ToString()); |
| | | switch (tempQueryType) |
| | | { |
| | | case QueryType.day_hour: |
| | | tempQueryTimeString = tempQueryTime_Year.ToString() + "/" + tempQueryTime_Month + "/" + tempQueryTime_Day; |
| | | break; |
| | | case QueryType.custom_month: |
| | | tempQueryTimeString = tempQueryTime_Year.ToString() + "/" + tempQueryTime_Month ; |
| | | break; |
| | | case QueryType.custom_year: |
| | | tempQueryTimeString = tempQueryTime_Year.ToString(); |
| | | break; |
| | | } |
| | | |
| | | var revertObj = new HttpServerRequest().GetSensorHistory(tempQueryType.ToString(), function.deviceId, WaterHeaterJinmao_AttrEnum.temp.ToString(),tempQueryTimeString); |
| | | if (revertObj != null) |
| | | { |
| | | if (revertObj.Code == StateCode.SUCCESS) |
| | |
| | | /// <summary> |
| | | /// 获取用水量历史记录 |
| | | /// </summary> |
| | | /// <param name="queryType"></param> |
| | | private void getWaterHistory(string queryType) |
| | | private void getWaterHistory() |
| | | { |
| | | if (MainPage.NoLoginMode) |
| | | { |
| | | return; |
| | | } |
| | | var loadPage = new Loading() |
| | | { |
| | | LodingBackgroundColor = 0x88888888, |
| | |
| | | { |
| | | loadPage.Start(Language.StringByID(StringId.PleaseWait)); |
| | | }); |
| | | switch (waterQueryType) |
| | | { |
| | | case QueryType.day_hour: |
| | | waterQueryTimeString = waterQueryTime_Year.ToString() + "/" + waterQueryTime_Month + "/" + waterQueryTime_Day; |
| | | break; |
| | | case QueryType.custom_month: |
| | | waterQueryTimeString = waterQueryTime_Year.ToString() + "/" + waterQueryTime_Month; |
| | | break; |
| | | case QueryType.custom_year: |
| | | waterQueryTimeString = waterQueryTime_Year.ToString(); |
| | | break; |
| | | } |
| | | |
| | | var revertObj = new HttpServerRequest().GetSensorHistory(queryType, function.deviceId, WaterHeaterJinmao_AttrEnum.volume.ToString()); |
| | | var revertObj = new HttpServerRequest().GetSensorHistory(waterQueryType.ToString(), function.deviceId, WaterHeaterJinmao_AttrEnum.volume.ToString(),waterQueryTimeString); |
| | | if (revertObj != null) |
| | | { |
| | | if (revertObj.Code == StateCode.SUCCESS) |
| | |
| | | |
| | | private void initQueryButton() |
| | | { |
| | | infoView1_DateInfo_DateTextButton.MouseUpEventHandler = (sender, e) => |
| | | { |
| | | SetTempQureyDateDialog(); |
| | | }; |
| | | infoView1_DateInfo_PreClickButton.MouseUpEventHandler = (sender, e) => { |
| | | var tempQueryDate = new DateTime(tempQueryTime_Year,tempQueryTime_Month,tempQueryTime_Day); |
| | | if (tempQueryType == QueryType.day_hour) |
| | | { |
| | | tempQueryDate = tempQueryDate.AddDays(-1); |
| | | if(tempQueryDate.Year == 2023 && tempQueryDate.Month == 1 && tempQueryDate.Day == 1) |
| | | { |
| | | infoView1_DateInfo_PreIconButton.Visible = false; |
| | | infoView1_DateInfo_PreClickButton.Enable = false; |
| | | } |
| | | if (tempQueryDate.Year == DateTime.Now.Year && tempQueryDate.Month == DateTime.Now.Month && tempQueryDate.Day == DateTime.Now.Day - 1) |
| | | { |
| | | infoView1_DateInfo_NextIconButton.Visible = true; |
| | | infoView1_DateInfo_NextClickButton.Enable = true; |
| | | } |
| | | } |
| | | else if(tempQueryType == QueryType.custom_month) |
| | | { |
| | | tempQueryDate = tempQueryDate.AddMonths(-1); |
| | | if (tempQueryDate.Year == 2023 && tempQueryDate.Month == 1) |
| | | { |
| | | infoView1_DateInfo_PreIconButton.Visible = false; |
| | | infoView1_DateInfo_PreClickButton.Enable = false; |
| | | } |
| | | if (tempQueryDate.Year == DateTime.Now.Year && tempQueryDate.Month == DateTime.Now.Month - 1) |
| | | { |
| | | infoView1_DateInfo_NextIconButton.Visible = true; |
| | | infoView1_DateInfo_NextClickButton.Enable = true; |
| | | } |
| | | } |
| | | else if(tempQueryType == QueryType.custom_year) |
| | | { |
| | | tempQueryDate = tempQueryDate.AddYears(-1); |
| | | if (tempQueryDate.Year == 2023) |
| | | { |
| | | infoView1_DateInfo_PreIconButton.Visible = false; |
| | | infoView1_DateInfo_PreClickButton.Enable = false; |
| | | } |
| | | if (tempQueryDate.Year == DateTime.Now.Year - 1) |
| | | { |
| | | infoView1_DateInfo_NextIconButton.Visible = true; |
| | | infoView1_DateInfo_NextClickButton.Enable = true; |
| | | } |
| | | } |
| | | tempQueryTime_Year = tempQueryDate.Year; |
| | | tempQueryTime_Month = tempQueryDate.Month; |
| | | tempQueryTime_Day = tempQueryDate.Day; |
| | | infoView1_DateInfo_DateTextButton.Text = tempQueryDate.ToString("yyyy-MM-dd"); |
| | | getTempHistory(); |
| | | }; |
| | | infoView1_DateInfo_NextIconButton.Visible = false; |
| | | infoView1_DateInfo_NextClickButton.Enable = false; |
| | | infoView1_DateInfo_NextClickButton.MouseUpEventHandler = (sender, e) => { |
| | | var tempQueryDate = new DateTime(tempQueryTime_Year, tempQueryTime_Month, tempQueryTime_Day); |
| | | if (tempQueryType == QueryType.day_hour) |
| | | { |
| | | tempQueryDate = tempQueryDate.AddDays(1); |
| | | if (tempQueryDate.Year == 2023 && tempQueryDate.Month == 1 && tempQueryDate.Day == 2) |
| | | { |
| | | infoView1_DateInfo_PreIconButton.Visible = true; |
| | | infoView1_DateInfo_PreClickButton.Enable = true; |
| | | } |
| | | if (tempQueryDate.Year == DateTime.Now.Year && tempQueryDate.Month == DateTime.Now.Month && tempQueryDate.Day == DateTime.Now.Day) |
| | | { |
| | | infoView1_DateInfo_NextIconButton.Visible = false; |
| | | infoView1_DateInfo_NextClickButton.Enable = false; |
| | | } |
| | | } |
| | | else if (tempQueryType == QueryType.custom_month) |
| | | { |
| | | tempQueryDate = tempQueryDate.AddMonths(1); |
| | | if (tempQueryDate.Year == 2023 && tempQueryDate.Month == 2) |
| | | { |
| | | infoView1_DateInfo_PreIconButton.Visible = true; |
| | | infoView1_DateInfo_PreClickButton.Enable = true; |
| | | } |
| | | if (tempQueryDate.Year == DateTime.Now.Year && tempQueryDate.Month == DateTime.Now.Month ) |
| | | { |
| | | infoView1_DateInfo_NextIconButton.Visible = false; |
| | | infoView1_DateInfo_NextClickButton.Enable = false; |
| | | } |
| | | } |
| | | else if (tempQueryType == QueryType.custom_year) |
| | | { |
| | | tempQueryDate = tempQueryDate.AddYears(1); |
| | | if (tempQueryDate.Year == 2023) |
| | | { |
| | | infoView1_DateInfo_PreIconButton.Visible = false; |
| | | infoView1_DateInfo_PreClickButton.Enable = false; |
| | | } |
| | | if (tempQueryDate.Year == DateTime.Now.Year) |
| | | { |
| | | infoView1_DateInfo_NextIconButton.Visible = false; |
| | | infoView1_DateInfo_NextClickButton.Enable = false; |
| | | } |
| | | } |
| | | tempQueryTime_Year = tempQueryDate.Year; |
| | | tempQueryTime_Month = tempQueryDate.Month; |
| | | tempQueryTime_Day = tempQueryDate.Day; |
| | | infoView1_DateInfo_DateTextButton.Text = tempQueryDate.ToString("yyyy-MM-dd"); |
| | | getTempHistory(); |
| | | }; |
| | | |
| | | infoView1_Date_Day.MouseUpEventHandler = (sender, e) => { |
| | | if (infoView1_Date_Day.IsSelected) |
| | | { |
| | |
| | | infoView1_Date_Day.IsSelected = true; |
| | | infoView1_Date_Month.IsSelected = false; |
| | | infoView1_Date_Year.IsSelected = false; |
| | | //getTempHistory("day") |
| | | tempQueryType = QueryType.day_hour; |
| | | infoView1_DateInfo_DateTextButton.Text = new DateTime(tempQueryTime_Year, tempQueryTime_Month, tempQueryTime_Day).ToString("yyyy-MM-dd"); |
| | | getTempHistory(); |
| | | }; |
| | | infoView1_Date_Month.MouseUpEventHandler = (sender, e) => { |
| | | if (infoView1_Date_Month.IsSelected) |
| | | { |
| | | return; |
| | | } |
| | | infoView1_Date_Day.IsSelected = false; |
| | | infoView1_Date_Month.IsSelected = true; |
| | | infoView1_Date_Year.IsSelected = false; |
| | | tempQueryType = QueryType.custom_month; |
| | | infoView1_DateInfo_DateTextButton.Text = new DateTime(tempQueryTime_Year, tempQueryTime_Month, tempQueryTime_Day).ToString("yyyy-MM"); |
| | | getTempHistory(); |
| | | }; |
| | | infoView1_Date_Year.MouseUpEventHandler = (sender, e) => { |
| | | if (infoView1_Date_Year.IsSelected) |
| | | { |
| | | return; |
| | | } |
| | | infoView1_Date_Day.IsSelected = false; |
| | | infoView1_Date_Month.IsSelected = false; |
| | | infoView1_Date_Year.IsSelected = true; |
| | | tempQueryType = QueryType.custom_year; |
| | | infoView1_DateInfo_DateTextButton.Text = tempQueryTime_Year.ToString(); |
| | | getTempHistory(); |
| | | }; |
| | | //-----------用水 |
| | | infoView2_DateInfo_DateTextButton.MouseUpEventHandler = (sender, e) => |
| | | { |
| | | SetWaterQureyDateDialog(); |
| | | }; |
| | | infoView2_DateInfo_PreClickButton.MouseUpEventHandler = (sender, e) => { |
| | | var waterQueryDate = new DateTime(waterQueryTime_Year, waterQueryTime_Month, waterQueryTime_Day); |
| | | if (waterQueryType == QueryType.day_hour) |
| | | { |
| | | waterQueryDate = waterQueryDate.AddDays(-1); |
| | | if (waterQueryDate.Year == 2023 && waterQueryDate.Month == 1 && waterQueryDate.Day == 1) |
| | | { |
| | | infoView2_DateInfo_PreIconButton.Visible = false; |
| | | infoView2_DateInfo_PreClickButton.Enable = false; |
| | | } |
| | | if (waterQueryDate.Year == DateTime.Now.Year && waterQueryDate.Month == DateTime.Now.Month && waterQueryDate.Day == DateTime.Now.Day - 1) |
| | | { |
| | | infoView2_DateInfo_NextIconButton.Visible = true; |
| | | infoView2_DateInfo_NextClickButton.Enable = true; |
| | | } |
| | | } |
| | | else if (waterQueryType == QueryType.custom_month) |
| | | { |
| | | waterQueryDate = waterQueryDate.AddMonths(-1); |
| | | if (waterQueryDate.Year == 2023 && waterQueryDate.Month == 1) |
| | | { |
| | | infoView2_DateInfo_PreIconButton.Visible = false; |
| | | infoView2_DateInfo_PreClickButton.Enable = false; |
| | | } |
| | | if (waterQueryDate.Year == DateTime.Now.Year && waterQueryDate.Month == DateTime.Now.Month - 1) |
| | | { |
| | | infoView2_DateInfo_NextIconButton.Visible = true; |
| | | infoView2_DateInfo_NextClickButton.Enable = true; |
| | | } |
| | | } |
| | | else if (waterQueryType == QueryType.custom_year) |
| | | { |
| | | waterQueryDate = waterQueryDate.AddYears(-1); |
| | | if (waterQueryDate.Year == 2023) |
| | | { |
| | | infoView2_DateInfo_PreIconButton.Visible = false; |
| | | infoView2_DateInfo_PreClickButton.Enable = false; |
| | | } |
| | | if (waterQueryDate.Year == DateTime.Now.Year - 1) |
| | | { |
| | | infoView2_DateInfo_NextIconButton.Visible = true; |
| | | infoView2_DateInfo_NextClickButton.Enable = true; |
| | | } |
| | | } |
| | | waterQueryTime_Year = waterQueryDate.Year; |
| | | waterQueryTime_Month = waterQueryDate.Month; |
| | | waterQueryTime_Day = waterQueryDate.Day; |
| | | infoView2_DateInfo_DateTextButton.Text = waterQueryDate.ToString("yyyy-MM-dd"); |
| | | getWaterHistory(); |
| | | }; |
| | | infoView2_DateInfo_NextIconButton.Visible = false; |
| | | infoView2_DateInfo_NextClickButton.Enable = false; |
| | | infoView2_DateInfo_NextClickButton.MouseUpEventHandler = (sender, e) => { |
| | | var waterQueryDate = new DateTime(waterQueryTime_Year, waterQueryTime_Month, waterQueryTime_Day); |
| | | if (waterQueryType == QueryType.day_hour) |
| | | { |
| | | waterQueryDate = waterQueryDate.AddDays(1); |
| | | if (waterQueryDate.Year == 2023 && waterQueryDate.Month == 1 && waterQueryDate.Day == 2) |
| | | { |
| | | infoView2_DateInfo_PreIconButton.Visible = true; |
| | | infoView2_DateInfo_PreClickButton.Enable = true; |
| | | } |
| | | if (waterQueryDate.Year == DateTime.Now.Year && waterQueryDate.Month == DateTime.Now.Month && waterQueryDate.Day == DateTime.Now.Day) |
| | | { |
| | | infoView2_DateInfo_NextIconButton.Visible = false; |
| | | infoView2_DateInfo_NextClickButton.Enable = false; |
| | | } |
| | | } |
| | | else if (waterQueryType == QueryType.custom_month) |
| | | { |
| | | waterQueryDate = waterQueryDate.AddMonths(1); |
| | | if (waterQueryDate.Year == 2023 && waterQueryDate.Month == 2) |
| | | { |
| | | infoView2_DateInfo_PreIconButton.Visible = true; |
| | | infoView2_DateInfo_PreClickButton.Enable = true; |
| | | } |
| | | if (waterQueryDate.Year == DateTime.Now.Year && waterQueryDate.Month == DateTime.Now.Month) |
| | | { |
| | | infoView2_DateInfo_NextIconButton.Visible = false; |
| | | infoView2_DateInfo_NextClickButton.Enable = false; |
| | | } |
| | | } |
| | | else if (waterQueryType == QueryType.custom_year) |
| | | { |
| | | waterQueryDate = waterQueryDate.AddYears(1); |
| | | if (waterQueryDate.Year == 2023) |
| | | { |
| | | infoView2_DateInfo_PreIconButton.Visible = false; |
| | | infoView2_DateInfo_PreClickButton.Enable = false; |
| | | } |
| | | if (waterQueryDate.Year == DateTime.Now.Year) |
| | | { |
| | | infoView2_DateInfo_NextIconButton.Visible = false; |
| | | infoView2_DateInfo_NextClickButton.Enable = false; |
| | | } |
| | | } |
| | | waterQueryTime_Year = waterQueryDate.Year; |
| | | waterQueryTime_Month = waterQueryDate.Month; |
| | | waterQueryTime_Day = waterQueryDate.Day; |
| | | infoView2_DateInfo_DateTextButton.Text = waterQueryDate.ToString("yyyy-MM-dd"); |
| | | getWaterHistory(); |
| | | }; |
| | | infoView2_Date_Day.MouseDownEventHandler = (sender, e) => { |
| | | if (infoView2_Date_Day.IsSelected) |
| | | { |
| | | return; |
| | | } |
| | | infoView2_Date_Day.IsSelected = true; |
| | | infoView2_Date_Month.IsSelected = false; |
| | | infoView2_Date_Year.IsSelected = false; |
| | | waterQueryType = QueryType.day_hour; |
| | | infoView2_DateInfo_DateTextButton.Text = new DateTime(waterQueryTime_Year, waterQueryTime_Month, waterQueryTime_Day).ToString("yyyy-MM-dd"); |
| | | getWaterHistory(); |
| | | }; |
| | | infoView2_Date_Month.MouseDownEventHandler = (sender, e) => { |
| | | if (infoView2_Date_Month.IsSelected) |
| | | { |
| | | return; |
| | | } |
| | | infoView2_Date_Day.IsSelected = false; |
| | | infoView2_Date_Month.IsSelected = true; |
| | | infoView2_Date_Year.IsSelected = false; |
| | | waterQueryType = QueryType.custom_month; |
| | | infoView2_DateInfo_DateTextButton.Text = new DateTime(waterQueryTime_Year, waterQueryTime_Month, waterQueryTime_Day).ToString("yyyy-MM"); |
| | | getWaterHistory(); |
| | | }; |
| | | infoView2_Date_Year.MouseDownEventHandler = (sender, e) => { |
| | | if (infoView2_Date_Year.IsSelected) |
| | | { |
| | | return; |
| | | } |
| | | infoView2_Date_Day.IsSelected = false; |
| | | infoView2_Date_Month.IsSelected = false; |
| | | infoView2_Date_Year.IsSelected = true; |
| | | waterQueryType = QueryType.custom_year; |
| | | infoView2_DateInfo_DateTextButton.Text = waterQueryTime_Year.ToString(); |
| | | getWaterHistory(); |
| | | }; |
| | | |
| | | } |
| | | |
| | | /// <summary> |
| | | /// </summary> |
| | | public void SetTempQureyDateDialog() |
| | | { |
| | | var pickerItems_Year = new List<string>(); |
| | | List<string> pickerItems_Month = null; |
| | | List<string> pickerItems_Day = null; |
| | | |
| | | int item1 = tempQueryTime_Year; |
| | | int item2 = tempQueryTime_Month; |
| | | int item3 = tempQueryTime_Day; |
| | | |
| | | pickerItems_Year.Add("2023"); |
| | | while (DateTime.Now.Year > 2022 + pickerItems_Year.Count) |
| | | { |
| | | pickerItems_Year.Add((2023 + pickerItems_Year.Count).ToString()); |
| | | } |
| | | |
| | | if(tempQueryType == QueryType.custom_month || tempQueryType == QueryType.day_hour) |
| | | { |
| | | pickerItems_Month = new List<string>(); |
| | | if (tempQueryTime_Year == DateTime.Now.Year) |
| | | { |
| | | int addMonth = 0; |
| | | while (DateTime.Now.Month > addMonth) |
| | | { |
| | | addMonth++; |
| | | pickerItems_Month.Add(addMonth.ToString()); |
| | | } |
| | | } |
| | | else |
| | | { |
| | | for (var i = 1; i < 13; i++) |
| | | { |
| | | pickerItems_Month.Add(i.ToString()); |
| | | } |
| | | } |
| | | if (tempQueryType == QueryType.day_hour) |
| | | { |
| | | pickerItems_Day = new List<string>(); |
| | | if (tempQueryTime_Month == DateTime.Now.Month) |
| | | { |
| | | int addDay = 0; |
| | | while (DateTime.Now.Day > addDay) |
| | | { |
| | | addDay++; |
| | | pickerItems_Day.Add(addDay.ToString()); |
| | | } |
| | | } |
| | | else |
| | | { |
| | | for (var i = 1; i <= DateTime.DaysInMonth(tempQueryTime_Year, tempQueryTime_Month); i++) |
| | | { |
| | | pickerItems_Day.Add(i.ToString()); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | | Dialog dialog = new Dialog(); |
| | | |
| | | var pView = new FrameLayout() |
| | | { |
| | | BackgroundColor = CSS_Color.DialogTransparentColor1, |
| | | }; |
| | | dialog.AddChidren(pView); |
| | | |
| | | var optionBaseView = new FrameLayout() |
| | | { |
| | | Y = Application.GetRealHeight(456 - 60), |
| | | Gravity = Gravity.CenterHorizontal, |
| | | Width = Application.GetRealWidth(343), |
| | | Height = Application.GetRealHeight(260), |
| | | AnimateSpeed = 0.3f, |
| | | Animate = Animate.DownToUp, |
| | | BackgroundColor = CSS_Color.MainBackgroundColor, |
| | | Radius = (uint)Application.GetRealWidth(12), |
| | | }; |
| | | pView.AddChidren(optionBaseView); |
| | | |
| | | var topView = new FrameLayout() |
| | | { |
| | | Gravity = Gravity.CenterHorizontal, |
| | | Width = Application.GetRealWidth(343), |
| | | Height = Application.GetRealHeight(40), |
| | | BackgroundColor = CSS_Color.MainBackgroundColor, |
| | | Radius = (uint)Application.GetRealWidth(12), |
| | | }; |
| | | optionBaseView.AddChidren(topView); |
| | | topView.AddChidren(new Button() { Y = Application.GetRealHeight(39), Height = Application.GetRealHeight(1), BackgroundColor = CSS_Color.DividingLineColor }); |
| | | |
| | | var btnCancel = new Button() |
| | | { |
| | | X = Application.GetRealWidth(21), |
| | | Width = Application.GetRealWidth(100), |
| | | TextAlignment = TextAlignment.CenterLeft, |
| | | TextColor = CSS_Color.PromptingColor1, |
| | | TextSize = CSS_FontSize.TextFontSize, |
| | | TextID = StringId.Cancel, |
| | | }; |
| | | topView.AddChidren(btnCancel); |
| | | |
| | | var btnConfrim = new Button() |
| | | { |
| | | X = Application.GetRealWidth(160), |
| | | Width = Application.GetRealWidth(160), |
| | | TextAlignment = TextAlignment.CenterRight, |
| | | TextColor = CSS_Color.MainColor, |
| | | TextSize = CSS_FontSize.TextFontSize, |
| | | TextID = StringId.Confirm, |
| | | }; |
| | | topView.AddChidren(btnConfrim); |
| | | |
| | | UIPickerView uIPickerView = new UIPickerView() |
| | | { |
| | | Y = Application.GetRealHeight(40), |
| | | Height = Application.GetRealHeight(210), |
| | | Radius = (uint)Application.GetRealWidth(12), |
| | | }; |
| | | optionBaseView.AddChidren(uIPickerView); |
| | | uIPickerView.setNPicker(pickerItems_Year, pickerItems_Month, pickerItems_Day); |
| | | uIPickerView.setCurrentItems(pickerItems_Year.IndexOf(tempQueryTime_Year.ToString()), |
| | | pickerItems_Month == null ? 0: pickerItems_Month.IndexOf(tempQueryTime_Month.ToString()), |
| | | pickerItems_Day == null? 0: pickerItems_Day.IndexOf(tempQueryTime_Day.ToString())); |
| | | |
| | | dialog.Show(); |
| | | |
| | | pView.MouseUpEventHandler = (sender, e) => |
| | | { |
| | | dialog.Close(); |
| | | }; |
| | | |
| | | btnCancel.MouseUpEventHandler = (sender, e) => |
| | | { |
| | | dialog.Close(); |
| | | }; |
| | | uIPickerView.OnSelectChangeEvent = (int1, int2, int3) => |
| | | { |
| | | if (pickerItems_Year[int1] != item1.ToString()) |
| | | { |
| | | int.TryParse(pickerItems_Year[int1], out item1); |
| | | if (tempQueryType == QueryType.custom_month || tempQueryType == QueryType.day_hour) |
| | | { |
| | | pickerItems_Month = new List<string>(); |
| | | if (item1 == DateTime.Now.Year) |
| | | { |
| | | int addMonth = 0; |
| | | while (DateTime.Now.Month > addMonth) |
| | | { |
| | | addMonth++; |
| | | pickerItems_Month.Add(addMonth.ToString()); |
| | | } |
| | | } |
| | | else |
| | | { |
| | | for (var i = 1; i < 13; i++) |
| | | { |
| | | pickerItems_Month.Add(i.ToString()); |
| | | } |
| | | } |
| | | if (tempQueryType == QueryType.day_hour) |
| | | { |
| | | pickerItems_Day = new List<string>(); |
| | | if (item1 == DateTime.Now.Year && item2 == DateTime.Now.Month) |
| | | { |
| | | int addDay = 0; |
| | | while (DateTime.Now.Day > addDay) |
| | | { |
| | | addDay++; |
| | | pickerItems_Day.Add(addDay.ToString()); |
| | | } |
| | | } |
| | | else |
| | | { |
| | | for (var i = 1; i <= DateTime.DaysInMonth(item1, item2); i++) |
| | | { |
| | | pickerItems_Day.Add(i.ToString()); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | uIPickerView.setNPicker(pickerItems_Year, pickerItems_Month, pickerItems_Day); |
| | | uIPickerView.setCurrentItems(pickerItems_Year.IndexOf(item1.ToString()), |
| | | pickerItems_Month == null ? 0 : pickerItems_Month.IndexOf(item2.ToString()), |
| | | pickerItems_Day == null ? 0 : pickerItems_Day.IndexOf(item3.ToString())); |
| | | |
| | | } |
| | | if (pickerItems_Month != null) |
| | | { |
| | | if (pickerItems_Month[int2] != item2.ToString()) |
| | | { |
| | | int.TryParse(pickerItems_Month[int2], out item2); |
| | | if (tempQueryType == QueryType.day_hour) |
| | | { |
| | | pickerItems_Day = new List<string>(); |
| | | if (item1 == DateTime.Now.Year && item2 == DateTime.Now.Month) |
| | | { |
| | | int addDay = 0; |
| | | while (DateTime.Now.Day > addDay) |
| | | { |
| | | addDay++; |
| | | pickerItems_Day.Add(addDay.ToString()); |
| | | } |
| | | } |
| | | else |
| | | { |
| | | for (var i = 1; i <= DateTime.DaysInMonth(item1, item2); i++) |
| | | { |
| | | pickerItems_Day.Add(i.ToString()); |
| | | } |
| | | } |
| | | } |
| | | |
| | | uIPickerView.setNPicker(pickerItems_Year, pickerItems_Month, pickerItems_Day); |
| | | uIPickerView.setCurrentItems(pickerItems_Year.IndexOf(item1.ToString()), |
| | | pickerItems_Month == null ? 0 : pickerItems_Month.IndexOf(item2.ToString()), |
| | | pickerItems_Day == null ? 0 : pickerItems_Day.IndexOf(item3.ToString())); |
| | | } |
| | | } |
| | | if (pickerItems_Day != null) |
| | | { |
| | | if (int3 >= pickerItems_Day.Count) |
| | | { |
| | | int3 = 0; |
| | | } |
| | | if (pickerItems_Day[int3] != item3.ToString()) |
| | | { |
| | | int.TryParse(pickerItems_Day[int3], out item3); |
| | | } |
| | | } |
| | | }; |
| | | btnConfrim.MouseUpEventHandler = (sender, e) => |
| | | { |
| | | dialog.Close(); |
| | | tempQueryTime_Year = item1; |
| | | infoView1_DateInfo_DateTextButton.Text = tempQueryTime_Year.ToString(); |
| | | if (tempQueryType == QueryType.custom_month || tempQueryType == QueryType.day_hour) |
| | | { |
| | | if (item2 != tempQueryTime_Month) |
| | | { |
| | | tempQueryTime_Month = item2; |
| | | } |
| | | infoView1_DateInfo_DateTextButton.Text = new DateTime(tempQueryTime_Year, tempQueryTime_Month, tempQueryTime_Day).ToString("yyyy-MM"); |
| | | if (tempQueryType == QueryType.day_hour) |
| | | { |
| | | if (item3 != tempQueryTime_Day) |
| | | { |
| | | tempQueryTime_Day = item3; |
| | | } |
| | | infoView1_DateInfo_DateTextButton.Text = new DateTime(tempQueryTime_Year, tempQueryTime_Month, tempQueryTime_Day).ToString("yyyy-MM-dd"); |
| | | } |
| | | } |
| | | getTempHistory(); |
| | | }; |
| | | |
| | | } |
| | | |
| | | public void SetWaterQureyDateDialog() |
| | | { |
| | | var pickerItems_Year = new List<string>(); |
| | | List<string> pickerItems_Month = null; |
| | | List<string> pickerItems_Day = null; |
| | | |
| | | int item1 = waterQueryTime_Year; |
| | | int item2 = waterQueryTime_Month; |
| | | int item3 = waterQueryTime_Day; |
| | | |
| | | pickerItems_Year.Add("2023"); |
| | | while (DateTime.Now.Year > 2022 + pickerItems_Year.Count) |
| | | { |
| | | pickerItems_Year.Add((2023 + pickerItems_Year.Count).ToString()); |
| | | } |
| | | |
| | | if (waterQueryType == QueryType.custom_month || waterQueryType == QueryType.day_hour) |
| | | { |
| | | pickerItems_Month = new List<string>(); |
| | | if (waterQueryTime_Year == DateTime.Now.Year) |
| | | { |
| | | int addMonth = 0; |
| | | while (DateTime.Now.Month > addMonth) |
| | | { |
| | | addMonth++; |
| | | pickerItems_Month.Add(addMonth.ToString()); |
| | | } |
| | | } |
| | | else |
| | | { |
| | | for (var i = 1; i < 13; i++) |
| | | { |
| | | pickerItems_Month.Add(i.ToString()); |
| | | } |
| | | } |
| | | if (waterQueryType == QueryType.day_hour) |
| | | { |
| | | pickerItems_Day = new List<string>(); |
| | | if (waterQueryTime_Month == DateTime.Now.Month) |
| | | { |
| | | int addDay = 0; |
| | | while (DateTime.Now.Day > addDay) |
| | | { |
| | | addDay++; |
| | | pickerItems_Day.Add(addDay.ToString()); |
| | | } |
| | | } |
| | | else |
| | | { |
| | | for (var i = 1; i <= DateTime.DaysInMonth(waterQueryTime_Year, waterQueryTime_Month); i++) |
| | | { |
| | | pickerItems_Day.Add(i.ToString()); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | | Dialog dialog = new Dialog(); |
| | | |
| | | var pView = new FrameLayout() |
| | | { |
| | | BackgroundColor = CSS_Color.DialogTransparentColor1, |
| | | }; |
| | | dialog.AddChidren(pView); |
| | | |
| | | var optionBaseView = new FrameLayout() |
| | | { |
| | | Y = Application.GetRealHeight(456 - 60), |
| | | Gravity = Gravity.CenterHorizontal, |
| | | Width = Application.GetRealWidth(343), |
| | | Height = Application.GetRealHeight(260), |
| | | AnimateSpeed = 0.3f, |
| | | Animate = Animate.DownToUp, |
| | | BackgroundColor = CSS_Color.MainBackgroundColor, |
| | | Radius = (uint)Application.GetRealWidth(12), |
| | | }; |
| | | pView.AddChidren(optionBaseView); |
| | | |
| | | var topView = new FrameLayout() |
| | | { |
| | | Gravity = Gravity.CenterHorizontal, |
| | | Width = Application.GetRealWidth(343), |
| | | Height = Application.GetRealHeight(40), |
| | | BackgroundColor = CSS_Color.MainBackgroundColor, |
| | | Radius = (uint)Application.GetRealWidth(12), |
| | | }; |
| | | optionBaseView.AddChidren(topView); |
| | | topView.AddChidren(new Button() { Y = Application.GetRealHeight(39), Height = Application.GetRealHeight(1), BackgroundColor = CSS_Color.DividingLineColor }); |
| | | |
| | | var btnCancel = new Button() |
| | | { |
| | | X = Application.GetRealWidth(21), |
| | | Width = Application.GetRealWidth(100), |
| | | TextAlignment = TextAlignment.CenterLeft, |
| | | TextColor = CSS_Color.PromptingColor1, |
| | | TextSize = CSS_FontSize.TextFontSize, |
| | | TextID = StringId.Cancel, |
| | | }; |
| | | topView.AddChidren(btnCancel); |
| | | |
| | | var btnConfrim = new Button() |
| | | { |
| | | X = Application.GetRealWidth(160), |
| | | Width = Application.GetRealWidth(160), |
| | | TextAlignment = TextAlignment.CenterRight, |
| | | TextColor = CSS_Color.MainColor, |
| | | TextSize = CSS_FontSize.TextFontSize, |
| | | TextID = StringId.Confirm, |
| | | }; |
| | | topView.AddChidren(btnConfrim); |
| | | |
| | | UIPickerView uIPickerView = new UIPickerView() |
| | | { |
| | | Y = Application.GetRealHeight(40), |
| | | Height = Application.GetRealHeight(210), |
| | | Radius = (uint)Application.GetRealWidth(12), |
| | | }; |
| | | optionBaseView.AddChidren(uIPickerView); |
| | | uIPickerView.setNPicker(pickerItems_Year, pickerItems_Month, pickerItems_Day); |
| | | uIPickerView.setCurrentItems(pickerItems_Year.IndexOf(waterQueryTime_Year.ToString()), |
| | | pickerItems_Month == null ? 0 : pickerItems_Month.IndexOf(waterQueryTime_Month.ToString()), |
| | | pickerItems_Day == null ? 0 : pickerItems_Day.IndexOf(waterQueryTime_Day.ToString())); |
| | | |
| | | dialog.Show(); |
| | | |
| | | pView.MouseUpEventHandler = (sender, e) => |
| | | { |
| | | dialog.Close(); |
| | | }; |
| | | |
| | | btnCancel.MouseUpEventHandler = (sender, e) => |
| | | { |
| | | dialog.Close(); |
| | | }; |
| | | uIPickerView.OnSelectChangeEvent = (int1, int2, int3) => |
| | | { |
| | | if (pickerItems_Year[int1] != item1.ToString()) |
| | | { |
| | | int.TryParse(pickerItems_Year[int1], out item1); |
| | | if (waterQueryType == QueryType.custom_month || waterQueryType == QueryType.day_hour) |
| | | { |
| | | pickerItems_Month = new List<string>(); |
| | | if (item1 == DateTime.Now.Year) |
| | | { |
| | | int addMonth = 0; |
| | | while (DateTime.Now.Month > addMonth) |
| | | { |
| | | addMonth++; |
| | | pickerItems_Month.Add(addMonth.ToString()); |
| | | } |
| | | } |
| | | else |
| | | { |
| | | for (var i = 1; i < 13; i++) |
| | | { |
| | | pickerItems_Month.Add(i.ToString()); |
| | | } |
| | | } |
| | | if (waterQueryType == QueryType.day_hour) |
| | | { |
| | | pickerItems_Day = new List<string>(); |
| | | if (item1 == DateTime.Now.Year && item2 == DateTime.Now.Month) |
| | | { |
| | | int addDay = 0; |
| | | while (DateTime.Now.Day > addDay) |
| | | { |
| | | addDay++; |
| | | pickerItems_Day.Add(addDay.ToString()); |
| | | } |
| | | } |
| | | else |
| | | { |
| | | for (var i = 1; i <= DateTime.DaysInMonth(item1, item2); i++) |
| | | { |
| | | pickerItems_Day.Add(i.ToString()); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | uIPickerView.setNPicker(pickerItems_Year, pickerItems_Month, pickerItems_Day); |
| | | uIPickerView.setCurrentItems(pickerItems_Year.IndexOf(item1.ToString()), |
| | | pickerItems_Month == null ? 0 : pickerItems_Month.IndexOf(item2.ToString()), |
| | | pickerItems_Day == null ? 0 : pickerItems_Day.IndexOf(item3.ToString())); |
| | | |
| | | } |
| | | if (pickerItems_Month != null) |
| | | { |
| | | if (pickerItems_Month[int2] != item2.ToString()) |
| | | { |
| | | int.TryParse(pickerItems_Month[int2], out item2); |
| | | if (waterQueryType == QueryType.day_hour) |
| | | { |
| | | pickerItems_Day = new List<string>(); |
| | | if (item1 == DateTime.Now.Year && item2 == DateTime.Now.Month) |
| | | { |
| | | int addDay = 0; |
| | | while (DateTime.Now.Day > addDay) |
| | | { |
| | | addDay++; |
| | | pickerItems_Day.Add(addDay.ToString()); |
| | | } |
| | | } |
| | | else |
| | | { |
| | | for (var i = 1; i <= DateTime.DaysInMonth(item1, item2); i++) |
| | | { |
| | | pickerItems_Day.Add(i.ToString()); |
| | | } |
| | | } |
| | | } |
| | | |
| | | uIPickerView.setNPicker(pickerItems_Year, pickerItems_Month, pickerItems_Day); |
| | | uIPickerView.setCurrentItems(pickerItems_Year.IndexOf(item1.ToString()), |
| | | pickerItems_Month == null ? 0 : pickerItems_Month.IndexOf(item2.ToString()), |
| | | pickerItems_Day == null ? 0 : pickerItems_Day.IndexOf(item3.ToString())); |
| | | } |
| | | } |
| | | if (pickerItems_Day != null) |
| | | { |
| | | if (int3 >= pickerItems_Day.Count) |
| | | { |
| | | int3 = 0; |
| | | } |
| | | if (pickerItems_Day[int3] != item3.ToString()) |
| | | { |
| | | int.TryParse(pickerItems_Day[int3], out item3); |
| | | } |
| | | } |
| | | }; |
| | | btnConfrim.MouseUpEventHandler = (sender, e) => |
| | | { |
| | | dialog.Close(); |
| | | waterQueryTime_Year = item1; |
| | | infoView2_DateInfo_DateTextButton.Text = waterQueryTime_Year.ToString(); |
| | | if (waterQueryType == QueryType.custom_month || waterQueryType == QueryType.day_hour) |
| | | { |
| | | if (item2 != waterQueryTime_Month) |
| | | { |
| | | waterQueryTime_Month = item2; |
| | | } |
| | | infoView2_DateInfo_DateTextButton.Text = new DateTime(waterQueryTime_Year, waterQueryTime_Month, waterQueryTime_Day).ToString("yyyy-MM"); |
| | | if (waterQueryType == QueryType.day_hour) |
| | | { |
| | | if (item3 != waterQueryTime_Day) |
| | | { |
| | | waterQueryTime_Day = item3; |
| | | } |
| | | infoView2_DateInfo_DateTextButton.Text = new DateTime(waterQueryTime_Year, waterQueryTime_Month, waterQueryTime_Day).ToString("yyyy-MM-dd"); |
| | | } |
| | | } |
| | | getWaterHistory(); |
| | | }; |
| | | |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | } |
| | | |
| | | public enum QueryType |
| | | { |
| | | /// <summary> |
| | | /// 近24小时、 |
| | | /// </summary> |
| | | hour, |
| | | /// <summary> |
| | | /// 某日24小时、 |
| | | /// </summary> |
| | | day_hour, |
| | | /// <summary> |
| | | /// 近一周、 |
| | | /// </summary> |
| | | week, |
| | | /// <summary> |
| | | /// 近一月、 |
| | | /// </summary> |
| | | month, |
| | | /// <summary> |
| | | /// 某年某月 y/M、 |
| | | /// </summary> |
| | | custom_month, |
| | | /// <summary> |
| | | /// 某年 y |
| | | /// </summary> |
| | | custom_year, |
| | | } |
| | | } |
| | | |