Esempio n. 1
0
        private async void myTime_Tick(object sender, object e)
        {
            try
            {
                Random random = new Random();
                Windows.Web.Http.HttpClient httpClient = new Windows.Web.Http.HttpClient();
                string response = await httpClient.GetStringAsync(new Uri(ServerLink +
                                                                          "check.php?random=" + random.Next().ToString()));

                //to.Text = response;
                myClassBinder root = JsonConvert.DeserializeObject <myClassBinder>(response);
                string        t    = root.item[0].temp + "°C";
                string        g    = root.item[0].gas + "%";
                string        h    = root.item[0].humidity + "%";
                string        w    = root.item[0].water + "%";
                string        l    = root.item[0].light + "";

                temp.Text     = t;
                gas.Text      = g;
                water.Text    = w;
                light.Text    = l;
                humidity.Text = h;
            }
            catch (Exception ex)
            {
                var dialog_catch = new MessageDialog(ex.ToString());
                await dialog_catch.ShowAsync();
            }
        }
Esempio n. 2
0
        /// <summary>
        /// The methods provided in this section are simply used to allow
        /// NavigationHelper to respond to the page's navigation methods.
        /// <para>
        /// Page specific logic should be placed in event handlers for the
        /// <see cref="NavigationHelper.LoadState"/>
        /// and <see cref="NavigationHelper.SaveState"/>.
        /// The navigation parameter is available in the LoadState method
        /// in addition to page state preserved during an earlier session.
        /// </para>
        /// </summary>
        /// <param name="e">Provides data for navigation methods and event
        /// handlers that cannot cancel the navigation request.</param>
        protected async override void OnNavigatedTo(NavigationEventArgs e)
        {
            Random random = new Random();

            try
            {
                Windows.Web.Http.HttpClient httpClient = new Windows.Web.Http.HttpClient();
                string response = await httpClient.GetStringAsync(
                    new Uri(Statistics.ServerLink + "checkPlans.php?random=" + random.Next().ToString()));

                myClassBinder root = JsonConvert.DeserializeObject <myClassBinder>(response);
                listSelector1.ItemsSource = root.item;
            }
            catch (Exception ex)
            {
                var dialog_catch = new MessageDialog(ex.ToString());
                await dialog_catch.ShowAsync();
            }
        }
Esempio n. 3
0
        private async void myTime_Tick(object sender, object e)
        {
            try
            {
                Windows.Web.Http.HttpClient httpClient = new Windows.Web.Http.HttpClient();
                string response = await httpClient.GetStringAsync(new Uri(Statistics.ServerLink + "checkPlantGraph.php?random=" + random.Next().ToString()));

                myClassBinder root = JsonConvert.DeserializeObject <myClassBinder>(response);
                (LineChart.Series[0] as LineSeries).ItemsSource = root.item;
                (LineChart.Series[1] as LineSeries).ItemsSource = root.item;
                (LineChart.Series[2] as LineSeries).ItemsSource = root.item;
                (LineChart.Series[3] as LineSeries).ItemsSource = root.item;
                (LineChart.Series[4] as LineSeries).ItemsSource = root.item;
            }
            catch (Exception ex)
            {
                var dialog_catch = new MessageDialog(ex.ToString());
                await dialog_catch.ShowAsync();
            }
        }