//using System; //using System.Collections.Generic; //namespace Shared.SimpleControl.Phone //{ // public class UserSensorHistoryPage :FrameLayout // { // public UserSensorHistoryPage () // { // } // public void ShowPage(Common sensor) // { //#if DEBUG // //UserConfig.Instance.GatewayMAC = "00005AF30A845F00"; //#endif // string unitText = "PM2.5"; // string titleText = ""; // switch (sensor.Type) { // case DeviceType.SensorPM25: // titleText = "PM2.5"; // unitText = @"μg/m³"; // break; // case DeviceType.SensorCO2: // titleText = "CO2"; // unitText = "ppm"; // break; // case DeviceType.SensorTVOC: // titleText = "TVOC"; // unitText = "ppm"; // break; // case DeviceType.SensorTemperature: // titleText = Language.StringByID (R.MyInternationalizationString.Temp); // unitText = "°C"; // break; // case DeviceType.SensorHumidity: // titleText = Language.StringByID (R.MyInternationalizationString.Humidity); // unitText = "%"; // break; // } // List revertData = new List (); // this.BackgroundColor = SkinStyle.Current.MainColor; // #region 标题 // var topView = new FrameLayout () { // Y = Application.GetRealHeight (36), // Height = Application.GetRealHeight (90), // BackgroundColor = SkinStyle.Current.MainColor // }; // AddChidren (topView); // var title = new Button () { // TextAlignment = TextAlignment.Center, // Text = titleText +" " + Language.StringByID(R.MyInternationalizationString.DataHistory) , // //TextID = R.MyInternationalizationString.SetPush, // TextColor = SkinStyle.Current.TextColor1, // TextSize = 19, // }; // topView.AddChidren (title); // var logo = new Button () { // Width = Application.GetRealWidth (154), // Height = Application.GetRealHeight (90), // X = Application.GetRealWidth (486), // UnSelectedImagePath = MainPage.LogoString, // }; // topView.AddChidren (logo); // var back = new Button () { // Height = Application.GetRealHeight (90), // Width = Application.GetRealWidth (85), // UnSelectedImagePath = "Item/Back.png", // SelectedImagePath = "Item/BackSelected.png", // }; // topView.AddChidren (back); // back.MouseUpEventHandler += (sender, e) => { // (Parent as PageLayout).PageIndex -= 1; // }; // #endregion // FrameLayout bodyView = new FrameLayout () { // Y = topView.Bottom, // Height = Application.GetRealHeight(1136 -126), // BackgroundColor = SkinStyle.Current.ViewColor, // }; // AddChidren (bodyView); // FrameLayout timeView = new FrameLayout () { // X = Application.GetRealWidth(20), // Height = Application.GetRealHeight (200), // Width = Application.GetRealWidth (600), // }; // bodyView.AddChidren (timeView); // Button btnYear = new Button () { // Y = Application.GetRealHeight (50), // Width = Application.GetRealWidth (150), // Height = Application.GetRealHeight (80), // BorderColor = SkinStyle.Current.BorderColor, // BorderWidth = 1, // Radius = 1, // TextID = R.MyInternationalizationString.Year, // TextAlignment = TextAlignment.Center, // TextColor = SkinStyle.Current.TextColor1, // SelectedTextColor = SkinStyle.Current.SelectedColor, // }; // timeView.AddChidren (btnYear); // Button btnMonth = new Button () { // X = btnYear.Right, // Y = Application.GetRealHeight (50), // Width = Application.GetRealWidth(150), // Height = Application.GetRealHeight (80), // BorderColor = SkinStyle.Current.BorderColor, // BorderWidth = 1, // Radius = 1, // Text = GetMonthText(DateTime.Now.Month), // TextAlignment = TextAlignment.Center, // TextColor= SkinStyle.Current.TextColor1, // SelectedTextColor = SkinStyle.Current.SelectedColor, // }; // timeView.AddChidren (btnMonth); // Button btnDay = new Button () { // X = btnMonth.Right, // Y = Application.GetRealHeight (50), // Width = Application.GetRealWidth (150), // Height = Application.GetRealHeight(80), // BorderColor = SkinStyle.Current.BorderColor, // BorderWidth = 1, // Radius = 1, // TextID = R.MyInternationalizationString.CurDay, // TextAlignment = TextAlignment.Center, // TextColor = SkinStyle.Current.TextColor1, // SelectedTextColor = SkinStyle.Current.SelectedColor, // }; // timeView.AddChidren (btnDay); // Button btnTime = new Button () { // X = btnDay.Right, // Y = Application.GetRealHeight (50), // Width = Application.GetRealWidth (150), // Height = Application.GetRealHeight (80), // BorderColor = SkinStyle.Current.BorderColor, // BorderWidth = 1, // Radius = 1, // TextID = R.MyInternationalizationString.Days7, // TextAlignment = TextAlignment.Center, // TextColor = SkinStyle.Current.TextColor1, // SelectedTextColor = SkinStyle.Current.SelectedColor, // }; // timeView.AddChidren (btnTime); // FrameLayout chartView = new FrameLayout () { // Y = Application.GetRealHeight(200), // Height = Application.GetRealHeight(600), // }; // bodyView.AddChidren (chartView); // //MyEchartsView myEchartsView = new MyEchartsView (); // //chartView.AddChidren (myEchartsView); // Random random = new Random (); // List xstrings = new List (); // List ystrings = new List (); // btnMonth.BorderColor = SkinStyle.Current.SelectedColor; // btnMonth.IsSelected = true; // btnDay.BorderColor = btnTime.BorderColor = SkinStyle.Current.BorderColor; // btnDay.IsSelected = btnDay.IsSelected = false; // btnYear.MouseUpEventHandler += (df, fd) => { // xstrings.Clear (); // ystrings.Clear (); // btnYear.BorderColor = SkinStyle.Current.SelectedColor; // btnYear.IsSelected = true; // btnMonth.BorderColor = btnDay.BorderColor = btnTime.BorderColor = SkinStyle.Current.BorderColor; // btnMonth.IsSelected = btnDay.IsSelected = btnTime.IsSelected = false; // System.Threading.Tasks.Task.Run (() => { // try { // var requestObj = new SensorPushHistory () { SubnetID = sensor.SubnetID, DeviceID = sensor.DeviceID, LargeType = sensor.BigClass, SmallType = sensor.MinClass, QueryType = QueryType.NowYear, LoopID = 1, NowMonth = 0, MAC = UserConfig.Instance.GatewayMAC }; // var requestJson = Newtonsoft.Json.JsonConvert.SerializeObject (requestObj); // var revertObj = MainPage.RequestHttps ("GetSensorPushHistory", requestJson); // if (revertObj != null) { // Application.RunOnMainThread (() => { // if (revertObj.StateCode.ToUpper() == StateCode.SUCCESS) { // revertData = Newtonsoft.Json.JsonConvert.DeserializeObject> (revertObj.ResponseData.ToString ()); // int ass = 0; // for (int i = 0; i < revertData.Count;i++) { // if (revertData [i].TargetValue.ToString () == "NaN") { // ass = 0; // } else { // ass = Convert.ToInt32 (revertData [i].TargetValue); // } // xstrings.Add (revertData [i].CreatedOnUtc.ToLocalTime ().Month.ToString ()); // ystrings.Add (ass.ToString ()); // } // //myEchartsView.Show (unitText, xstrings.ToArray (), ystrings.ToArray ()); // } // }); // } // } catch (Exception ex) { // Utlis.WriteLine (ex.ToString ()); // } finally { // Application.RunOnMainThread (() => { // MainPage.Loading.Hide (); // }); // } // }); // }; // btnMonth.MouseUpEventHandler += (df, fd) => { // xstrings.Clear (); // ystrings.Clear (); // btnMonth.BorderColor = SkinStyle.Current.SelectedColor; // btnMonth.IsSelected = true; // btnYear.IsSelected = btnDay.IsSelected = btnDay.IsSelected = false; // btnYear.BorderColor = btnDay.BorderColor = btnTime.BorderColor = SkinStyle.Current.BorderColor; // Dialog dialogChooseMonth = new Dialog (); // var chooseMonthView = new FrameLayout () { // BackgroundColor = SkinStyle.Current.Black50Transparent, // }; // dialogChooseMonth.AddChidren (chooseMonthView); // chooseMonthView.MouseUpEventHandler += (ddfd, fdfd) => { // dialogChooseMonth.Close (); // }; // VerticalScrolViewLayout chooseMothView = new VerticalScrolViewLayout () { // Y = Application.GetRealHeight (636), // Height = Application.GetRealHeight(500), // BackgroundColor = SkinStyle.Current.DialogColor, // }; // chooseMonthView.AddChidren (chooseMothView); // for (int ii = 1; ii < DateTime.Now.Month+1; ii++) { // Button btn = new Button () { // Height = Application.GetRealHeight (100), // TextAlignment = TextAlignment.Center, // TextColor = SkinStyle.Current.TextColor, // Tag = ii // }; // btn.Text = GetMonthText (ii); // chooseMothView.AddChidren (btn); // btn.MouseUpEventHandler += (dff, ffd) => { // chooseMothView.RemoveAll (); // chooseMothView.RemoveFromParent (); // dialogChooseMonth.Close (); // btnMonth.Text = ((Button)dff).Text; // System.Threading.Tasks.Task.Run (() => { // try { // var requestObj = new SensorPushHistory () { SubnetID = sensor.SubnetID, DeviceID = sensor.DeviceID, LargeType = sensor.BigClass, SmallType = sensor.MinClass, QueryType = QueryType.NowMonth, LoopID = 1, NowMonth = Convert.ToInt32 (((Button)dff).Tag), MAC = UserConfig.Instance.GatewayMAC }; // var requestJson = Newtonsoft.Json.JsonConvert.SerializeObject (requestObj); // var revertObj = MainPage.RequestHttps ("GetSensorPushHistory", requestJson); // if (revertObj != null) { // Application.RunOnMainThread (() => { // if (revertObj.StateCode.ToUpper() == StateCode.SUCCESS) { // revertData = Newtonsoft.Json.JsonConvert.DeserializeObject> (revertObj.ResponseData.ToString ()); // int ass = 0; // for (int i = 0; i < revertData.Count; i++) { // if (revertData [i].TargetValue.ToString () == "NaN") { // ass = 0; // } else { // ass = Convert.ToInt32 (revertData [i].TargetValue); // } // xstrings.Add (revertData [i].CreatedOnUtc.ToLocalTime ().Day.ToString ()); // ystrings.Add (ass.ToString ()); // } // //myEchartsView.Show (unitText, xstrings.ToArray (), ystrings.ToArray ()); // } // }); // } // } catch (Exception ex) { // Utlis.WriteLine (ex.ToString ()); // } finally { // Application.RunOnMainThread (() => { // MainPage.Loading.Hide (); // }); // } // }); // }; // Button btnLine = new Button (){ // BackgroundColor = SkinStyle.Current.Black50Transparent, // Height = 1 // }; // chooseMothView.AddChidren (btnLine); // } // dialogChooseMonth.Show (); // }; // btnDay.MouseUpEventHandler += (df, fd) => { // xstrings.Clear (); // ystrings.Clear (); // btnDay.BorderColor = SkinStyle.Current.SelectedColor; // btnDay.IsSelected = true; // btnYear.BorderColor = btnMonth.BorderColor = btnTime.BorderColor = SkinStyle.Current.BorderColor; // btnYear.IsSelected = btnMonth.IsSelected = btnTime.IsSelected = false; // System.Threading.Tasks.Task.Run (() => { // try { // var requestObj = new SensorPushHistory () { SubnetID = sensor.SubnetID, DeviceID = sensor.DeviceID, LargeType = sensor.BigClass, SmallType = sensor.MinClass, QueryType = QueryType.NowDay, LoopID = 1, NowMonth = 0, MAC = UserConfig.Instance.GatewayMAC }; // var requestJson = Newtonsoft.Json.JsonConvert.SerializeObject (requestObj); // var revertObj = MainPage.RequestHttps ("GetSensorPushHistory", requestJson); // if (revertObj != null) { // Application.RunOnMainThread (() => { // if (revertObj.StateCode.ToUpper() == StateCode.SUCCESS) { // revertData = Newtonsoft.Json.JsonConvert.DeserializeObject> (revertObj.ResponseData.ToString ()); // int ass = 0; // for (int i = 0; i < revertData.Count; i++) { // if (revertData [i].TargetValue.ToString () == "NaN") { // ass = 0; // } else { // ass = Convert.ToInt32 (revertData [i].TargetValue); // } // xstrings.Add (revertData [i].CreatedOnUtc.Hour.ToString ()); // ystrings.Add (ass.ToString ()); // } // //myEchartsView.Show (unitText, xstrings.ToArray (), ystrings.ToArray ()); // } // }); // } // } catch (Exception ex) { // Utlis.WriteLine (ex.ToString ()); // } finally { // Application.RunOnMainThread (() => { // MainPage.Loading.Hide (); // }); // } // }); // }; // Action action = () => { // xstrings.Clear (); // ystrings.Clear (); // btnTime.BorderColor = SkinStyle.Current.SelectedColor; // btnTime.IsSelected = true; // btnYear.BorderColor = btnMonth.BorderColor = btnDay.BorderColor = SkinStyle.Current.BorderColor; // btnYear.IsSelected = btnMonth.IsSelected = btnDay.IsSelected = false; // MainPage.Loading.Start ("Please wait..."); // System.Threading.Tasks.Task.Run (() => { // try { // var requestObj = new SensorPushHistory () { SubnetID = sensor.SubnetID, DeviceID = sensor.DeviceID, LargeType = sensor.BigClass, SmallType = sensor.MinClass, QueryType = QueryType.LatelySevenDay, LoopID = 1, NowMonth = 0, MAC = UserConfig.Instance.GatewayMAC }; // var requestJson = Newtonsoft.Json.JsonConvert.SerializeObject (requestObj); // var revertObj = MainPage.RequestHttps ("GetSensorPushHistory", requestJson); // if (revertObj != null) { // Application.RunOnMainThread (() => { // if (revertObj.StateCode.ToUpper() == StateCode.SUCCESS) { // revertData = Newtonsoft.Json.JsonConvert.DeserializeObject> (revertObj.ResponseData.ToString ()); // int ass = 0; // for (int i = 0; i < revertData.Count; i++) { // if (revertData [i].TargetValue.ToString () == "NaN") { // ass = 0; // } else { // ass = Convert.ToInt32 (revertData [i].TargetValue); // } // xstrings.Add (revertData [i].CreatedOnUtc.ToLocalTime ().ToString ("MM/dd")); // ystrings.Add (ass.ToString ()); // } // //myEchartsView.Show (unitText, xstrings.ToArray (), ystrings.ToArray ()); // } // }); // } // } catch (Exception ex) { // Utlis.WriteLine (ex.ToString ()); // } finally { // Application.RunOnMainThread (() => { // MainPage.Loading.Hide (); // }); // } // }); // }; // btnTime.MouseUpEventHandler += (df, fd) => { // action (); // }; // action (); // } // string GetMonthText (int InMonth) // { // string strReturn = ""; // if (Language.CurrentLanguage == "English") { // string strParaMonthn = "Jan._Feb._Mar._Apr._May_Jun._Jul._Aug._Sep._Oct._Nov._Dec."; // string [] strSubMonth = strParaMonthn.Split ("_".ToCharArray ()); // strReturn = strSubMonth [InMonth - 1]; // } else { // strReturn = InMonth + " 月"; // } // return strReturn; // } // } //}