예제 #1
0
 /// <summary>
 /// Event for when the dimmer is scrolled
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void Dimmer_Scroll(object sender, EventArgs e)
 {
     //Set the value of the dimmer
     availableApparats.Find(item => item.Port == currentApparatPort).DimmerValue = dimmerScroll.Value;
     //Dimm the light
     log = "Send: " + serialCom.Dimm(currentApparatPort, dimmerScroll.Value) + Environment.NewLine;
     TextBox_System_Log1.AppendText(log);
 }
예제 #2
0
 /// <summary>
 /// Event for when the OnOff button is pressed
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void OnOffButton_Click(object sender, EventArgs e)
 {
     //Check if dimmer is enabled
     if ((currentApparatFunc & Func.Dimmer) == Func.Dimmer)
     {
         //If port is On turn it Off
         if (IsPortOn(currentApparatPort))
         {
             log = "Send: " + serialCom.OnOff(currentApparatPort, IsPortOn(currentApparatPort)) + Environment.NewLine;
             TextBox_System_Log1.AppendText(log);
             //Invert on/off
             availableApparats.Find(item => item.Port == currentApparatPort).OnOff = false;
         }
         //else dimm instead of setting max
         else
         {
             //Also write to log
             log = "Send: " + serialCom.Dimm(currentApparatPort, dimmerScroll.Value) + Environment.NewLine;
             TextBox_System_Log1.AppendText(log);
             //Invert on/off
             availableApparats.Find(item => item.Port == currentApparatPort).OnOff = true;
         }
         //Change text of onOffButton
         onOffButton.Text = (IsPortOn(currentApparatPort) ? "Turn Off" : "Turn On");
     }
     else
     {
         //Turn the light on/off and write to log
         log = "Send: " + serialCom.OnOff(currentApparatPort, IsPortOn(currentApparatPort)) + Environment.NewLine;
         TextBox_System_Log1.AppendText(log);
         //Invert on/off
         availableApparats.Find(item => item.Port == currentApparatPort).OnOff ^= true;
         //Change text of onOffButton
         onOffButton.Text = (IsPortOn(currentApparatPort) ? "Turn Off" : "Turn On");
     }
 }