Ejemplo n.º 1
0
        protected void btnAceptar_Click(object sender, DialogClickEventArgs e)
        {
            var       newColor = Color.FromArgb(SliderRed.Progress, SliderGreen.Progress, SliderBlue.Progress).ToHsv();
            var       color    = Color.FromArgb(SliderRed.Progress, SliderGreen.Progress, SliderBlue.Progress).ToAndroidColor();
            LowColor  newLow   = null;
            HighColor newHigh  = null;

            switch (ValueToChange)
            {
            case ColorValue.LowColor:
                newLow = new LowColor
                {
                    H = newColor.H.ToString(),
                    S = newColor.S.ToString(),
                    V = newColor.V.ToString(),
                };
                break;

            case ColorValue.HighColor:
                newHigh = new HighColor
                {
                    H = newColor.H.ToString(),
                    S = newColor.S.ToString(),
                    V = newColor.V.ToString(),
                };
                break;
            }

            if (ColorToChange == typeof(TemperatureColor))
            {
                ColorConfiguration.TemperatureColor.LowColor  = newLow ?? ColorConfiguration.TemperatureColor.LowColor;
                ColorConfiguration.TemperatureColor.HighColor = newHigh ?? ColorConfiguration.TemperatureColor.HighColor;
                if (newLow != null)
                {
                    ((Button)Activity.FindViewById(Resource.Id.btnLowTemp)).SetBackgroundColor(color);
                }
                else
                {
                    ((Button)Activity.FindViewById(Resource.Id.btnHighTemp)).SetBackgroundColor(color);
                }
            }
            else if (ColorToChange == typeof(HumidityColor))
            {
                ColorConfiguration.HumidityColor.LowColor  = newLow ?? ColorConfiguration.HumidityColor.LowColor;
                ColorConfiguration.HumidityColor.HighColor = newHigh ?? ColorConfiguration.HumidityColor.HighColor;
                if (newLow != null)
                {
                    ((Button)Activity.FindViewById(Resource.Id.btnLowHumidity)).SetBackgroundColor(color);
                }
                else
                {
                    ((Button)Activity.FindViewById(Resource.Id.btnHighHumidity)).SetBackgroundColor(color);
                }
            }
            else if (ColorToChange == typeof(ProximityColor))
            {
                ColorConfiguration.ProximityColor.LowColor  = newLow ?? ColorConfiguration.ProximityColor.LowColor;
                ColorConfiguration.ProximityColor.HighColor = newHigh ?? ColorConfiguration.ProximityColor.HighColor;
                if (newLow != null)
                {
                    ((Button)Activity.FindViewById(Resource.Id.btnLowProximity)).SetBackgroundColor(color);
                }
                else
                {
                    ((Button)Activity.FindViewById(Resource.Id.btnHighProximity)).SetBackgroundColor(color);
                }
            }
            else if (ColorToChange == typeof(HourColor))
            {
                ColorConfiguration.HourColor.LowColor  = newLow ?? ColorConfiguration.HourColor.LowColor;
                ColorConfiguration.HourColor.HighColor = newHigh ?? ColorConfiguration.HourColor.HighColor;
                if (newLow != null)
                {
                    ((Button)Activity.FindViewById(Resource.Id.btnLowHour)).SetBackgroundColor(color);
                }
                else
                {
                    ((Button)Activity.FindViewById(Resource.Id.btnHighHour)).SetBackgroundColor(color);
                }
            }

            ColorConfiguration.SaveToXML();
        }