Esempio n. 1
0
 private void UpdateUiOnStateChange(Message message)
 {
     if (message is StandardMessage)
     {
         cbxType.SelectedIndex = 0;
         StandardMessage stdMessage = message as StandardMessage;
         House = stdMessage.House;
         Unit = stdMessage.Unit;
         cbxCommand.SelectionChanged -= cbxCommand_SelectionChanged;
         Command = stdMessage.Command;
         cbxCommand.SelectionChanged += cbxCommand_SelectionChanged;
         if (
             Command == Command.On ||
             Command == Command.Bright ||
             Command == Command.Dim ||
             Command == Command.StatusOn)
         {
             On = true;
         }
         else if (Command == Command.Off || Command == Command.StatusOff)
         {
             On = false;
         }
     }
     if (message is ExtendedMessage)
     {
         ExtendedMessage extMessage = message as ExtendedMessage;
         if (extMessage.ExtendedBrightness > 0)
         {
             if (extMessage.Command != Command.StatusOff)
             {
                 On = true;
             }
             Brightness = extMessage.ExtendedBrightness;
         }
     }
 }
Esempio n. 2
0
 private void cbxCommand_SelectionChanged(object sender, SelectionChangedEventArgs e)
 {
     bool isNoUnitCommand =
         Command == Command.AllLightsOff ||
         Command == Command.AllLightsOn ||
         Command == Command.AllUnitsOff ||
         Command == Command.Bright ||
         Command == Command.Dim ||
         Command == Command.HailAcknowledge ||
         Command == Command.HailRequest;
     if (isNoUnitCommand)
     {
         Unit = Unit.X;
     }
     SelectionChangeUpdate();
 }