예제 #1
0
        //takes a lot of input and sets values into te ui controls
        void set_info(Label date, Label temper, Label tempmax, Label tempmin, Label humidity, Label desc, PictureBox pic, Label lbladvise, PictureBox smiley, Node temp)
        {
            date.Text     = getdate(temp.datetime);
            temper.Text   = temp.data.m_temperature;
            tempmax.Text  = temp.data.m_temperature_max;
            tempmin.Text  = temp.data.m_temperature_min;
            humidity.Text = temp.data.m_humidity;
            desc.Text     = temp.data.m_weatherdescription;
            WeatherForecaster forecaster2 = new WeatherForecaster(pic, smiley, lbladvise, temp.data, desc);

            forecaster2.SetForecast();
        }
예제 #2
0
        /// <summary>
        /// Callback function called after a command is executed to update the UI with newly fetched results
        /// Asynchronously updates UI
        /// </summary>
        /// <param name="something"></param>
        void updateui(WeatherData data)
        {
            if (this.InvokeRequired)
            {
                this.BeginInvoke(new UIUpdaterDelegate(updateui),
                                 new object[] { data });
                return;
            }
            else
            {
                EnableButtons();
                if (data.m_error)
                {
                    lblHeading.Text = "Could not connect. Have you entered an API key?";
                    return;
                }
                //check for validity of data
                if (!DataStore.Instance().m_today.IsValid)
                {
                    return;
                }
                //set data in currentdata
                lblHeading.Text   = DataStore.Instance().m_today.data.m_location;
                lblTodayDate.Text = getdate(DataStore.Instance().m_today.data.m_date);
                lblTodayTemp.Text = DataStore.Instance().m_today.data.m_temperature.ToString();
                //set forecast info for today
                WeatherForecaster forecaster = new WeatherForecaster(picToday, pic_similey, lblFinal, DataStore.Instance().m_today.data, null);
                forecaster.SetForecast();

                //Now walk the doubly link list and updats data for 7 days
                Node temp = DataStore.Instance().m_left;
                set_info(lblData1, lblTemp1, lblTempMax1, lblTempMin1, lblHumidity1, lblDesc1, pic1, lbladvise1, picsmiley1, temp);

                temp = temp.next;
                set_info(lblData2, lblTemp2, lblTempMax2, lblTempMin2, lblHumidity2, lblDesc2, pic2, lbladvise2, picsmiley2, temp);


                temp = temp.next;
                set_info(lblData3, lblTemp3, lblTempMax3, lblTempMin3, lblHumidity3, lblDesc3, pic3, lbladvise3, picsmiley3, temp);


                temp = temp.next;
                set_info(lblData4, lblTemp4, lblTempMax4, lblTempMin4, lblHumidity4, lblDesc4, pic4, lbladvise4, picsmiley4, temp);


                temp = temp.next;
                set_info(lblData5, lblTemp5, lblTempMax5, lblTempMin5, lblHumidity5, lblDesc5, pic5, lbladvise5, picsmiley5, temp);


                temp = temp.next;
                set_info(lblData6, lblTemp6, lblTempMax6, lblTempMin6, lblHumidity6, lblDesc6, pic6, lbladvise6, picsmiley6, temp);


                temp = temp.next;
                set_info(lblData7, lblTemp7, lblTempMax7, lblTempMin7, lblHumidity7, lblDesc7, pic7, lbladvise7, picsmiley7, temp);


                if (DataStore.Instance().m_right.next == null)
                {
                    button3.Enabled = false;
                }
                SetButtonNames();
                DrawChart();//draw the temperatur chart as well

                pic_similey.Left = lblFinal.PreferredWidth + 10 + lblFinal.Location.X;
            }
        }