X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;ds=sidebyside;f=src%2Fcec-config-gui%2Factions%2FConnectToDevice.cs;h=43d786eccf1df168f9751e447f539c0583e98882;hb=6d866874c4acb7620caea7a4415357bbf56f1a62;hp=cb84a00b403d6b75b22087f984d26f47fd2f2bde;hpb=4555ed72f3a69812ad5481eabc94d54644ca549a;p=deb_libcec.git diff --git a/src/cec-config-gui/actions/ConnectToDevice.cs b/src/cec-config-gui/actions/ConnectToDevice.cs index cb84a00..43d786e 100644 --- a/src/cec-config-gui/actions/ConnectToDevice.cs +++ b/src/cec-config-gui/actions/ConnectToDevice.cs @@ -13,15 +13,26 @@ namespace CecConfigGui.actions public override void Process() { + SendEvent(UpdateEventType.StatusText, "Opening connection..."); + SendEvent(UpdateEventType.ProgressBar, 10); + + //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)) + { + 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(); + } + SendEvent(UpdateEventType.StatusText, "Detecting TV vendor..."); - SendEvent(UpdateEventType.ProgressBar, 25); + SendEvent(UpdateEventType.ProgressBar, 20); SendEvent(UpdateEventType.TVVendorId, (int)Lib.GetDeviceVendorId(CecLogicalAddress.Tv)); SendEvent(UpdateEventType.StatusText, "Detecting menu language..."); - SendEvent(UpdateEventType.ProgressBar, 40); + SendEvent(UpdateEventType.ProgressBar, 30); SendEvent(UpdateEventType.MenuLanguage, Lib.GetDeviceMenuLanguage(CecLogicalAddress.Tv)); - SendEvent(UpdateEventType.ProgressBar, 50); + SendEvent(UpdateEventType.ProgressBar, 40); SendEvent(UpdateEventType.StatusText, "Detecting AVR devices..."); bool hasAVRDevice = Lib.IsActiveDevice(CecLogicalAddress.AudioSystem); @@ -29,24 +40,28 @@ namespace CecConfigGui.actions if (hasAVRDevice) { - SendEvent(UpdateEventType.ProgressBar, 75); + SendEvent(UpdateEventType.ProgressBar, 50); 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, 60); SendEvent(UpdateEventType.StatusText, "Activating the source..."); Lib.SetActiveSource(CecDeviceType.Reserved); } - SendEvent(UpdateEventType.ProgressBar, 90); + SendEvent(UpdateEventType.ProgressBar, 70); SendEvent(UpdateEventType.StatusText, "Reading device configuration..."); Lib.GetCurrentConfiguration(Config); SendEvent(Config); + SendEvent(UpdateEventType.ProgressBar, 80); + SendEvent(UpdateEventType.StatusText, "Polling active devices"); + SendEvent(UpdateEventType.PollDevices); + SendEvent(UpdateEventType.ProgressBar, 100); SendEvent(UpdateEventType.StatusText, "Ready."); }