public override void ResponseReceived(byte[] parameter) { switch ((DeviceManagerCommunication)parameter[0]) { case DeviceManagerCommunication.ResponseDevices: var devices = new Serializer(typeof(List <DeviceInfo>)).Deserialize <List <DeviceInfo> >(parameter, 1); foreach (var deviceInfo in devices) { deviceInfo.DriverBuildDate = deviceInfo.DriverBuildDate.ToLocalTime(); deviceInfo.DriverInstallDate = deviceInfo.DriverInstallDate.ToLocalTime(); } LogService.Receive(string.Format((string)Application.Current.Resources["DevicesReceived"], devices.Count)); DevicesReceived?.Invoke(this, devices); break; case DeviceManagerCommunication.DeviceStateChangedSuccessfully: var enabled = parameter[1] == 1; var hardwareId = Encoding.UTF8.GetString(parameter, 2, parameter.Length - 2); LogService.Receive((string)Application.Current.Resources["DeviceStateChangedSuccessfully"]); DeviceStateChanged?.Invoke(this, new DeviceChangedEventArgs(hardwareId, enabled)); break; case DeviceManagerCommunication.ErrorChangingDeviceState: LogService.Error(string.Format((string)Application.Current.Resources["ErrorChangeDeviceState"], Encoding.UTF8.GetString(parameter, 1, parameter.Length - 1))); break; case DeviceManagerCommunication.ErrorDeviceNotFound: LogService.Error((string)Application.Current.Resources["ErrorDeviceNotFound"]); break; } }
public override void ResponseReceived(byte[] parameter) { switch ((AudioVolumeControlCommunication)parameter[0]) { case AudioVolumeControlCommunication.ResponseDevices: var serializer = new Serializer(typeof(List <AudioDevice>)); var devices = serializer.Deserialize <List <AudioDevice> >(parameter, 1); DevicesReceived?.Invoke(this, devices); LogService.Receive(string.Format((string)Application.Current.Resources["DevicesReceived"], devices.Count)); break; case AudioVolumeControlCommunication.ResponseVolumeSet: LogService.Receive((string)Application.Current.Resources["VolumeChanged"]); break; case AudioVolumeControlCommunication.ResponseDeviceNotFound: LogService.Error((string)Application.Current.Resources["DeviceNotFound"]); break; case AudioVolumeControlCommunication.ResponseChannelNotFound: LogService.Error((string)Application.Current.Resources["ChannelNotFound"]); break; case AudioVolumeControlCommunication.ResponseNotSupported: LogService.Error((string)Application.Current.Resources["PlatformNotSupported"]); break; default: throw new ArgumentOutOfRangeException(); } }