示例#1
0
        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            int id = -1;

            slHueGradientStart.Value = Properties.Settings.Default.CPUTemp_gradientStartColor;
            slHueGradientStop.Value  = Properties.Settings.Default.CPUTemp_gradientStopColor;
            dudLowerTemp.Value       = Properties.Settings.Default.CPUTemp_gradientStartTemp;
            dudUpperTemp.Value       = Properties.Settings.Default.CPUTemp_gradientStopTemp;
            budBri.Value             = Properties.Settings.Default.CpuTemp_Brightness;
            budSat.Value             = Properties.Settings.Default.CPUTemp_Saturation;

            Dictionary <string, Light> lightlist = Host.GetLightList();
            Dictionary <string, Group> grouplist = Host.GetGroupList();

            foreach (KeyValuePair <string, Light> kvp in lightlist)
            {
                cbObject.Items.Add(kvp);
                if (Properties.Settings.Default.CPUTemp_ObjectType)
                {
                    if (kvp.Key == Properties.Settings.Default.CPUTemp_ObjectID)
                    {
                        id = cbObject.Items.Count - 1;
                    }
                }
            }

            foreach (KeyValuePair <string, Group> kvp in grouplist)
            {
                cbObject.Items.Add(kvp);
                if (!Properties.Settings.Default.CPUTemp_ObjectType)
                {
                    if (kvp.Key == Properties.Settings.Default.CPUTemp_ObjectID)
                    {
                        id = cbObject.Items.Count - 1;
                    }
                }
            }

            if (cbObject.Items.Count > 0)
            {
                cbObject.SelectedIndex = 0;
            }

            if (id > -1)
            {
                cbObject.SelectedIndex = id;
            }
        }
示例#2
0
        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            Dictionary <string, Light> listlights = _host.GetLightList();

            foreach (KeyValuePair <string, Light> kvp in listlights)
            {
                lbLights.Items.Add(kvp);
            }

            if (_action == null)
            {
                return;
            }

            if (_action.hue != null)
            {
                chbHue.IsChecked = true;
                slHue.Value      = (double)_action.hue;
            }

            if (_action.bri != null)
            {
                chbBri.IsChecked = true;
                slBri.Value      = (double)_action.bri;
            }

            if (_action.sat != null)
            {
                chbSAT.IsChecked = true;
                slSAT.Value      = (double)_action.sat;
            }

            if (_action.ct != null)
            {
                chbCT.IsChecked = true;
                slCT.Value      = (double)_action.ct;
            }

            if (_action.xy != null)
            {
                chbX.IsChecked = true;
                //   slX.Value = (double) _action.xy[0];
                //   slY.Value = (double) _action.xy[1];
            }

            if (_action.transitiontime != null)
            {
                chbTT.IsChecked = true;
                slTT.Value      = (double)_action.transitiontime;
            }

            if (_action.alert != null)
            {
                switch (_action.alert)
                {
                case "none":
                    cbAlert.SelectedIndex = 0;
                    break;

                case "select":
                    cbAlert.SelectedItem = 1;
                    break;

                case "lselect":
                    cbAlert.SelectedItem = 2;
                    break;

                default:
                    break;
                }
            }
            else
            {
                cbAlert.SelectedIndex = 0;
            }

            if (_listselectedLights == null)
            {
                return;
            }

            foreach (KeyValuePair <byte, Light> kvp in lbLights.Items.Cast <KeyValuePair <byte, Light> >().Where(kvp => _listselectedLights.Contains(kvp.Key.ToString())))
            {
                lbLights.SelectedItems.Add(kvp);
            }
        }