X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;f=src%2Fcec-config-gui%2Factions%2FConnectToDevice.cs;h=8c198f4c60a20f86042aada349c0c0618ca81118;hb=1bede530033f40a81400c7a1e4ed0e8755d4ec59;hp=a1e1ef6a9bbc59f05b5ece7d0dcd5febb18f604b;hpb=a70f3777b8fc0cbf4bfb1c1546bc1bae94b60f9d;p=deb_libcec.git diff --git a/src/cec-config-gui/actions/ConnectToDevice.cs b/src/cec-config-gui/actions/ConnectToDevice.cs index a1e1ef6..8c198f4 100644 --- a/src/cec-config-gui/actions/ConnectToDevice.cs +++ b/src/cec-config-gui/actions/ConnectToDevice.cs @@ -18,14 +18,34 @@ namespace CecConfigGui.actions //TODO read the com port setting from the configuration CecAdapter[] adapters = Lib.FindAdapters(string.Empty); - if (adapters.Length == 0 || !Lib.Open(adapters[0].ComPort, 10000)) + if (adapters.Length == 0) { - MessageBox.Show("Could not connect to any CEC adapter. Please check your configuration and try again.", "Pulse-Eight USB-CEC Adapter", MessageBoxButtons.OK); - Application.Exit(); + DialogResult result = MessageBox.Show("Could not detect to any CEC adapter. Please check your configuration. Do you want to try again?", "Pulse-Eight USB-CEC Adapter", MessageBoxButtons.YesNo); + if (result == DialogResult.No) + { + SendEvent(UpdateEventType.ExitApplication); + return; + } + else + adapters = Lib.FindAdapters(string.Empty); } + while (!Lib.Open(adapters[0].ComPort, 10000)) + { + DialogResult result = MessageBox.Show("Could not connect to any CEC adapter. Please check your configuration. Do you want to try again?", "Pulse-Eight USB-CEC Adapter", MessageBoxButtons.YesNo); + if (result == DialogResult.No) + { + SendEvent(UpdateEventType.ExitApplication); + return; + } + } + + SendEvent(UpdateEventType.ProgressBar, 20); + SendEvent(UpdateEventType.StatusText, "Sending power on commands..."); + Lib.PowerOnDevices(CecLogicalAddress.Broadcast); + SendEvent(UpdateEventType.StatusText, "Detecting TV vendor..."); - SendEvent(UpdateEventType.ProgressBar, 25); + SendEvent(UpdateEventType.ProgressBar, 30); SendEvent(UpdateEventType.TVVendorId, (int)Lib.GetDeviceVendorId(CecLogicalAddress.Tv)); SendEvent(UpdateEventType.StatusText, "Detecting menu language..."); @@ -40,24 +60,28 @@ namespace CecConfigGui.actions if (hasAVRDevice) { - SendEvent(UpdateEventType.ProgressBar, 75); + SendEvent(UpdateEventType.ProgressBar, 60); SendEvent(UpdateEventType.StatusText, "Detecting AVR vendor..."); SendEvent(UpdateEventType.AVRVendorId, (int)Lib.GetDeviceVendorId(CecLogicalAddress.AudioSystem)); } if (!Lib.GetDevicePowerStatus(CecLogicalAddress.Tv).Equals(CecPowerStatus.On)) { - SendEvent(UpdateEventType.ProgressBar, 80); + SendEvent(UpdateEventType.ProgressBar, 70); SendEvent(UpdateEventType.StatusText, "Activating the source..."); Lib.SetActiveSource(CecDeviceType.Reserved); } - SendEvent(UpdateEventType.ProgressBar, 90); + SendEvent(UpdateEventType.ProgressBar, 80); SendEvent(UpdateEventType.StatusText, "Reading device configuration..."); Lib.GetCurrentConfiguration(Config); SendEvent(Config); + SendEvent(UpdateEventType.ProgressBar, 90); + SendEvent(UpdateEventType.StatusText, "Polling active devices"); + SendEvent(UpdateEventType.PollDevices); + SendEvent(UpdateEventType.ProgressBar, 100); SendEvent(UpdateEventType.StatusText, "Ready."); }