| 1 | using CecSharp; |
| 2 | using LibCECTray.Properties; |
| 3 | using LibCECTray.ui; |
| 4 | |
| 5 | namespace LibCECTray.controller.actions |
| 6 | { |
| 7 | class ShowDeviceInfo : UpdateProcess |
| 8 | { |
| 9 | public ShowDeviceInfo(CECController controller, LibCecSharp lib, CecLogicalAddress address) |
| 10 | { |
| 11 | _controller = controller; |
| 12 | _lib = lib; |
| 13 | _address = address; |
| 14 | } |
| 15 | |
| 16 | public virtual void ShowDialog(CecLogicalAddress address, ref LibCecSharp lib, |
| 17 | bool devicePresent, CecVendorId vendor, bool isActiveSource, ushort physicalAddress, |
| 18 | CecVersion version, CecPowerStatus power, string osdName, string menuLanguage) |
| 19 | { |
| 20 | DeviceInformation di = new DeviceInformation(_controller, _address, ref _lib, devicePresent, vendor, isActiveSource, physicalAddress, version, power, osdName, menuLanguage); |
| 21 | _controller.DisplayDialog(di, false); |
| 22 | } |
| 23 | |
| 24 | public override void Process() |
| 25 | { |
| 26 | CecVendorId vendor = CecVendorId.Unknown; |
| 27 | bool isActiveSource = false; |
| 28 | ushort physicalAddress = 0xFFFF; |
| 29 | CecVersion version = CecVersion.Unknown; |
| 30 | CecPowerStatus power = CecPowerStatus.Unknown; |
| 31 | string osdName = Resources.unknown; |
| 32 | string menuLanguage = Resources.unknown; |
| 33 | |
| 34 | SendEvent(UpdateEventType.StatusText, string.Format(Resources.action_check_device_present, _lib.ToString(_address))); |
| 35 | SendEvent(UpdateEventType.ProgressBar, 10); |
| 36 | |
| 37 | bool devicePresent = _lib.IsActiveDevice(_address); |
| 38 | if (devicePresent) |
| 39 | { |
| 40 | SendEvent(UpdateEventType.StatusText, Resources.action_requesting_vendor_id); |
| 41 | SendEvent(UpdateEventType.ProgressBar, 20); |
| 42 | vendor = _lib.GetDeviceVendorId(_address); |
| 43 | |
| 44 | SendEvent(UpdateEventType.StatusText, Resources.action_requesting_active_source_state); |
| 45 | SendEvent(UpdateEventType.ProgressBar, 30); |
| 46 | isActiveSource = _lib.IsActiveSource(_address); |
| 47 | |
| 48 | SendEvent(UpdateEventType.StatusText, Resources.action_requesting_physical_address); |
| 49 | SendEvent(UpdateEventType.ProgressBar, 40); |
| 50 | physicalAddress = _lib.GetDevicePhysicalAddress(_address); |
| 51 | |
| 52 | SendEvent(UpdateEventType.StatusText, Resources.action_requesting_cec_version); |
| 53 | SendEvent(UpdateEventType.ProgressBar, 50); |
| 54 | version = _lib.GetDeviceCecVersion(_address); |
| 55 | |
| 56 | SendEvent(UpdateEventType.StatusText, Resources.action_requesting_power_status); |
| 57 | SendEvent(UpdateEventType.ProgressBar, 60); |
| 58 | power = _lib.GetDevicePowerStatus(_address); |
| 59 | |
| 60 | SendEvent(UpdateEventType.StatusText, Resources.action_requesting_osd_name); |
| 61 | SendEvent(UpdateEventType.ProgressBar, 70); |
| 62 | osdName = _lib.GetDeviceOSDName(_address); |
| 63 | |
| 64 | SendEvent(UpdateEventType.StatusText, Resources.action_requesting_menu_language); |
| 65 | SendEvent(UpdateEventType.ProgressBar, 80); |
| 66 | menuLanguage = _lib.GetDeviceMenuLanguage(_address); |
| 67 | } |
| 68 | |
| 69 | SendEvent(UpdateEventType.StatusText, Resources.action_showing_device_information); |
| 70 | SendEvent(UpdateEventType.ProgressBar, 90); |
| 71 | SendEvent(UpdateEventType.ProcessCompleted, true); |
| 72 | |
| 73 | ShowDialog(_address, ref _lib, devicePresent, vendor, isActiveSource, physicalAddress, version, power, osdName, menuLanguage); |
| 74 | |
| 75 | SendEvent(UpdateEventType.StatusText, Resources.ready); |
| 76 | SendEvent(UpdateEventType.ProgressBar, 100); |
| 77 | } |
| 78 | |
| 79 | private readonly CECController _controller; |
| 80 | private LibCecSharp _lib; |
| 81 | private readonly CecLogicalAddress _address; |
| 82 | } |
| 83 | } |