Ejemplo n.º 1
0
 public void ControlWithIChannelable(IChannelable sameDevice)
 {
     Console.WriteLine("Switching channels. \n\nAvailable commands: \n-Set. \n-Increase. \n-Decrease. \n\nEnter your command:");
     Message = Console.ReadLine().ToLower();
     if (Message.Contains("set"))
     {
         Console.WriteLine("Enter channel number (1-100): ");
         int setChannel;
         if (Int32.TryParse(Console.ReadLine(), out setChannel))
         {
             ;
         }
         sameDevice.SetChannel(setChannel);
         if (actWithDevice != null)
         {
             actWithDevice.Invoke((sameDevice.SetChannel(setChannel))); // можно как-то проще?
         }
     }
     else if (Message.Contains("increase"))
     {
         sameDevice.AdjustChannel(true);
         if (actWithDevice != null)
         {
             actWithDevice.Invoke(sameDevice.AdjustChannel(true));
         }
     }
     else if (Message.Contains("decrease"))
     {
         sameDevice.AdjustChannel(false);
         if (actWithDevice != null)
         {
             actWithDevice.Invoke(sameDevice.AdjustChannel(true));
         }
     }
     else
     {
         Console.WriteLine("Nonexistent command");
         if (actWithDevice != null)
         {
             actWithDevice.Invoke("Nonexistent command");
         }
     }
 }