Beispiel #1
0
 private void ComboBox_SelectCOMPort_SelectionChanged(object sender, SelectionChangedEventArgs e)
 {
     if (ComboBox_SelectCOMPort.SelectedIndex != -1)
     {
         SerialCommunication.SetSelectedPortName((string)ComboBox_SelectCOMPort.SelectedValue);
     }
 }
Beispiel #2
0
 private void refreshPortList()
 {
     ComboBox_SelectCOMPort.Items.Clear();
     ComboBox_SelectCOMPort.SelectedIndex = -1;
     foreach (string portName in SerialCommunication.GetPortNames())
     {
         ComboBox_SelectCOMPort.Items.Add(portName);
     }
 }
Beispiel #3
0
        private void updateColor(object obj)
        {
            while (true)
            {
                AmbientLightControl control = (AmbientLightControl)obj;
                BasicColor          color   = control.color;

                this.startTicks = DateTime.Now.Ticks;                                                 // measure time
                color.Set(ScreenColor.GetAverageScreenColor(ScreenColor.DeterminationMethod.Partly)); // read screen color

                double factor = saturation;
                transferFunctionFactor = TransferFunction(color.GetDelta());
                if (preventFlickering)
                {
                    factor *= transferFunctionFactor;
                }
                control.outputColor = ColorManipulation.IncreaseSaturation(color, factor).Multiply(brightness);

                try
                {
                    SerialCommunication.SendColor(control.outputColor); // update hardware
                    this.error = null;
                }
                catch (Exception e)
                {
                    this.error = e;
                }

                this.executionTime = DateTime.Now.Ticks - this.startTicks; // stop time measurement

                this.updateUI();                                           // update ui

                switch (this.updateSpeed)
                {
                case UpdateSpeed.Low:
                    Thread.Sleep(400);     // keep Windows very responsive
                    break;

                case UpdateSpeed.Normal:
                    Thread.Sleep(100);
                    break;

                case UpdateSpeed.Maximum:
                    // continue as quick as possible
                    break;

                default:
                    Thread.Sleep(100);
                    break;
                }
            }
        }