private async void UpdateData() { HttpResponseMessage response = new HttpResponseMessage(); response = await httpClient.GetAsync("https://guardians-24413.firebaseio.com/current.json"); string data = await response.Content.ReadAsStringAsync(); c = JsonConvert.DeserializeObject <SenseData>(data); response = await httpClient.GetAsync("https://guardians-24413.firebaseio.com/average.json"); data = await response.Content.ReadAsStringAsync(); a = JsonConvert.DeserializeObject <SenseData>(data); double cTem = c.temperature; double cHum = c.humidity; double cPre = c.pressure; double aTem = a.temperature; double aHum = a.humidity; double aPre = a.pressure; double dTem = cTem - aTem; double dHum = cHum - aHum; double dPre = cPre - aPre; lblTemC.Text = cTem.ToString("0.00 °C"); lblHumC.Text = cHum.ToString("0.00 g/m³"); lblPreC.Text = cPre.ToString("0.00 mbar"); lblTemA.Text = aTem.ToString("0.00 °C"); lblHumA.Text = aHum.ToString("0.00 g/m³"); lblPreA.Text = aPre.ToString("0.00 mbar"); lblTemD.Text = dTem.ToString("+0.00 °C;-0.00 °C;0.00 °C"); lblHumD.Text = dHum.ToString("+0.00 g/m³;-0.00 g/m³;0.00 g/m³"); lblPreD.Text = dPre.ToString("+0.00 mbar;-0.00 mbar;0.00 mbar"); }
private void GUIFacePart <T>(string title, int idx, ref T[] t) where T : FaceBaseData, new() { folder[idx] = EditorGUILayout.Foldout(folder[idx], title, XEditorUtil.folderStyle); if (folder[idx]) { GUILayout.BeginHorizontal(); EditorGUILayout.Space(); if (GUILayout.Button("Add")) { Add <T>(ref t, new T()); } GUILayout.EndHorizontal(); if (t != null) { int del = -1; for (int i = 0; i < t.Length; i++) { int indx = idx * max + i; GUILayout.BeginHorizontal(); bsub[indx] = EditorGUILayout.Foldout(bsub[indx], i + "_" + t[i].name); if (GUILayout.Button("X", GUILayout.MaxWidth(20))) { del = i; } GUILayout.EndHorizontal(); int len = t[i].properities != null ? t[i].properities.Length : 0; for (int k = 0; k < len; k++) { if (t[i].properities[k] > maxid) { maxid = t[i].properities[k]; } } if (bsub[indx]) { if (typeof(T) == typeof(SenseData)) { SenseData data = (t[i] as SenseData); data.type = (SenseSubType)EditorGUILayout.EnumPopup("sub type", data.type); } else if (typeof(T) == typeof(PaintData)) { PaintData data = (t[i] as PaintData); data.type = (PaintSubType)EditorGUILayout.EnumPopup("sub type:", data.type); } GUIFaceBase(t[i], indx, i); EditorGUILayout.BeginHorizontal(); GUILayout.FlexibleSpace(); if (GUILayout.Button("insert", GUILayout.Width(100), GUILayout.Height(14))) { if (swap < t.Length && i != swap) { int max = Mathf.Max(swap, i); int min = Mathf.Min(swap, i); bool forward = max == swap; if (forward) { T temp = t[min]; for (int j = min; j < max; j++) { t[j] = t[j + 1]; } t[max] = temp; } else { T temp = t[max]; for (int j = max - 1; j >= min; j--) { t[j + 1] = t[j]; } t[min] = temp; } } swap = 0; } swap = EditorGUILayout.IntField(swap); EditorGUILayout.EndHorizontal(); } } if (del >= 0) { t = Remv <T>(t, del); } } } EditorGUILayout.Space(); }