Ejemplo n.º 1
0
        public TemperatureConfigForm()
        {
            InitializeComponent();

            //Get stored values
            this.TempDefaults = AWSCommunication.GetTemperatureDefaults();

            this.defaultCoolOccupiedTo.SelectedItem   = this.TempDefaults.CoolOccupiedRoomsTo;
            this.defaultCoolUnOccupiedTo.SelectedItem = this.TempDefaults.CoolUnoccupiedRoomsTo;
            this.defaultHeatOccupiedTo.SelectedItem   = this.TempDefaults.HeatOccupiedRoomsTo;
            this.defaultHeatUnOccupiedTo.SelectedItem = this.TempDefaults.HeatUnoccupiedRoomsTo;

            this.dailyTempOptionComboBox.SelectedItem = this.TempDefaults.ForecastTempToUse;

            this.latTxtBox.Text  = this.TempDefaults.LocationLat;
            this.longTxtBox.Text = this.TempDefaults.LocationLong;

            this.switchToHeatAtCombo.SelectedItem = this.TempDefaults.TempToSwitchToHeat.ToString();
            this.switchToCoolAtCombo.SelectedItem = this.TempDefaults.TempToSwitchToCool.ToString();

            if (this.latTxtBox.Text == "")
            {
                this.latTxtBox.Text           = "42.35";
                this.TempDefaults.LocationLat = this.latTxtBox.Text;
            }
            if (this.longTxtBox.Text == "")
            {
                this.longTxtBox.Text           = "-71.06";
                this.TempDefaults.LocationLong = this.longTxtBox.Text;
            }

            this.dailyTempOptionComboBox.SelectedValue = this.TempDefaults.ForecastTempToUse;

            if (this.dailyTempOptionComboBox.SelectedIndex < 0)
            {
                this.dailyTempOptionComboBox.SelectedIndex = 0;
            }

            if (this.TempDefaults.GetForecast())
            {
                this.currentLowLbl.Text  = "Current Low Forecast: " + this.TempDefaults.ForecastMin;
                this.currentHighLbl.Text = "Current High Forecast: " + this.TempDefaults.ForecastMax;
                this.currentAvgLbl.Text  = "Current Average Forecast: " + this.TempDefaults.ForecastAvg;
            }
            else
            {
                MessageBox.Show("Could not get the weather... this will be a problem");
            }
        }
Ejemplo n.º 2
0
        public static bool SaveTemperatureDefaults(TemperatureDefaults tempDefaults)
        {
            bool didWork = false;

            try {
                var context = GetDynamoDbContext();

                context.Save <TemperatureDefaults>(tempDefaults);
                didWork = true;
            }
            catch (Exception) {
                didWork = false;
            }
            return(didWork);
        }