private void DeviceStateListner(DeviceStateChangedEventArgs args) { if (args == null) { return; } var device = AudioEndPointCollection.FirstOrDefault(fd => fd.DeviceId.Equals(args.DeviceId, StringComparison.InvariantCultureIgnoreCase)); if (device == null) { return; } switch (args.State) { case AudioDeviceState.Active: device.Disabled = false; break; case AudioDeviceState.Disabled: case AudioDeviceState.NotPresent: case AudioDeviceState.UnPlugged: device.Disabled = true; break; } }
private void DeviceStateChanged(object sender, DeviceStateChangedEventArgs e) { try { logger.Info("DeviceStateChanged"); foreach (var radio in e.Infos) { int deviceID = radio.DeviceId; if (GetDeviceInfoByDeviceID(deviceID, out DeviceInfo deviceInfo)) { logger.Info($"DeviceStateChanged [{deviceInfo.RadioID}]: {radio.State.ToString()}"); Device device = deviceInfo?.Device; if (device != null) { ciaBataController.PostDeviceLifeSign(device.RadioID, device.Name, (radio.State & DeviceState.Active) == DeviceState.Active); } } } } catch (Exception ex) { logger.Log(LogLevel.Error, ex); } }
private ControlAction CreateControlAction(DeviceStateChangedEventArgs message) { string name = message.Method.ToString(); if (message.Method == DeviceMethod.Dim) return new SlidingControlAction(name, message.DimLevel); return new SimpleControlAction(name); }
private void DeviceStateChangedHandler(object sender, DeviceStateChangedEventArgs args) { if (!_isDisappearing && args.NewState == DeviceState.Disconnected && args.IsError) { _connectionTask = ConnectAsync(); } }
public void OnDeviceStateChange(PeripheralInfo peripheralInfo) { DeviceStateChangedEventArgs deviceStateChangedEventArgs = new DeviceStateChangedEventArgs(); deviceStateChangedEventArgs.PeripheralInfo = peripheralInfo; DeviceStateChange?.Invoke(this, deviceStateChangedEventArgs); }
private void device_StateChanged(object sender, DeviceStateChangedEventArgs e) { if (this._cancelTransferBecauseFormIsClosing) { ((Device)sender).CancelTransfer(); } }
/// <summary> /// 状态变化时显示状态动画 /// </summary> private void temp_OnDeviceStateChanged(object sender, DeviceStateChangedEventArgs e) { //查找主控板 var controlDevice = GlobalEnvironment.CurrWorkStationOragnization.Where(x => x.IP == e.IP); foreach (var board in controlDevice) { try { var channelDevice = CommHelper.GetOrgInfos(board.ORGANIZATION_CODE, false).Where(x => x.channelType == enumChannelType.chn_in || x.channelType == enumChannelType.chn_out).LastOrDefault(); if (null != channelDevice) { findPic = (RoadGate)this.Controls.Find(channelDevice.ORGANIZATION_NAME, true)[0]; if (null != findPic) { string filePath = e.State == 0 ? GlobalEnvironment.BasePath + "Image\\RoadNogate.png" : GlobalEnvironment.BasePath + "Image\\GateNormalClose.png"; if (File.Exists(filePath)) findPic.PicImage = filePath; } } } catch (Exception ex) { LogHelper.Log.Error(ex.Message, ex.InnerException); } } }
/// <summary> /// /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void OnDeviceStateChanged(object sender, DeviceStateChangedEventArgs e) { if (e.DeviceState.HasFlag(DeviceState.Active) && e.TryGetDevice(out var device)) { OnDeviceAdded(device); } }
private void M_client_DeviceStateChanged(object sender, DeviceStateChangedEventArgs e) { try { logger.Info("M_client_DeviceStateChanged"); foreach (var radio in e.Infos) { Device device; lock (devices) { device = devices.FirstOrDefault(r => r.ID == radio.DeviceId); } StringBuilder build = new StringBuilder(); build.Append("M_client_DeviceStateChanged"); build.Append("device: " + device.Name + " "); build.Append("state: " + radio.State.ToString() + " "); PostDeviceLifeSign(device.Name, device.RadioID, (radio.State & DeviceState.Active) == DeviceState.Active); logger.Info(build.ToString()); } } catch (Exception ex) { logger.Log(LogLevel.Error, ex); } }
private static void OnDeviceStateChanged(object sender, DeviceStateChangedEventArgs e) { using (var enumerator = new MMDeviceEnumerator()) using (var mmDevice = enumerator.GetDevice(e.DeviceId)) { Console.WriteLine($"{mmDevice.FriendlyName} state changed to {e.DeviceState}"); } }
private void ProcessChangedDeviceState(object sender, DeviceStateChangedEventArgs e) { if (DeviceStateChanged != null) { DeviceStateChanged(sender, e); Schedules.ProcessChangedDeviceState(sender, e); } }
void gps_DeviceStateChanged(object sender, DeviceStateChangedEventArgs args) { device = args.DeviceState; // call the UpdateData method via the updateDataHandler so that we // update the UI on the UI thread Invoke(updateDataHandler); }
private void OnDeviceStateChanged(object sender, DeviceStateChangedEventArgs e) { if (e.DeviceId != DeviceId || e.DeviceState.HasFlag(DeviceState.Active)) { return; } DeviceRemoved?.Invoke(this); }
private void HandleStateChanged(DeviceStateChangedEventArgs stateChangedEvent) { _state = stateChangedEvent.State.AsEDeviceState(); ReloadAudioEndpointVolume(_device); ReloadAudioMeterInformation(_device); OnPropertyChanged("State"); }
public void ProcessChangedDeviceState(object sender, DeviceStateChangedEventArgs e) { if (e.DeviceState is HolidayManagerState) { foreach (Schedule sched in this) { sched.UpdateHolidayState(((HolidayManagerState)e.DeviceState).CurrentHolidayState); } } }
private void EventHandlerDeviceStateChanged(object s, DeviceStateChangedEventArgs e) { // Check if the device is activated if (e.DeviceState == WiFiDirectDeviceState.Activated) { LogImplementation.DLog("Activated"); // Start to discover StartDiscovery(); } }
private void OnDeviceStateChanged(object sender, DeviceStateChangedEventArgs e) { if (e.DeviceState == DeviceState.NotPresent || e.DeviceState == DeviceState.UnPlugged) { e.TryGetDevice(out var device); if (device.DeviceID.GetHashCode() == Device.DeviceID.GetHashCode()) { DeviceRemoved?.Invoke(this); } } }
// ReSharper disable InconsistentNaming private void MMNotificationClientOnDeviceStateChanged(object sender, DeviceStateChangedEventArgs e) // ReSharper restore InconsistentNaming { if (e.DeviceState == DeviceState.Active) { Application.Current.Dispatcher.BeginInvoke(new Action(() => AddDevice(e.DeviceId))); } else if (e.DeviceState != DeviceState.Active) { Application.Current.Dispatcher.BeginInvoke(new Action(() => RemoveDevice(e.DeviceId))); } }
void gps_DeviceStateChanged(object sender, DeviceStateChangedEventArgs args) { device = args.DeviceState; UpdateGpsDeviceState(); try { Invoke(UpdateGpsDataHandler); } catch { } }
private void _mmNotificationClient_DeviceStateChanged(object sender, DeviceStateChangedEventArgs e) { if (e.DeviceState == DeviceState.Active) { Application.Current.Dispatcher.BeginInvoke(DispatcherPriority.Normal, new Action(() => AddDevice(e.DeviceId))); } else if (e.DeviceState != DeviceState.Active) { Application.Current.Dispatcher.BeginInvoke(DispatcherPriority.Normal, new Action(() => RemoveDevice(e.DeviceId))); } }
protected void gps_DeviceStateChanged(object sender, DeviceStateChangedEventArgs args) { device = args.DeviceState; this.mainControler.MainForm.BeginInvoke(updateStatusHandler); // call the UpdateData method via the updateDataHandler so that we // update the UI on the UI thread //if (this.mainControler.MainForm.InvokeRequired) //{ // this.mainControler.MainForm.BeginInvoke(updateDataHandler); //} //else SetInvalidateRegions(); }
private async void StateChangedTimer_Elapsed(object sender, ElapsedEventArgs e) { var result = await baseClient.GetSystemParameterListAsync(new byte[] { 0, 1, 2, 3, 4, 5, 6, 9 }); var deviceStateChangedEventArgs = new DeviceStateChangedEventArgs() { IsUserSitting = result.DataArray[0] != 0, IsAnalShowerRunning = result.DataArray[1] != 0, IsLadyShowerRunning = result.DataArray[2] != 0, IsDryerRunning = result.DataArray[3] != 0, //DescalingState = Deserializer.DeserializeToInt(result.DataArray, 4 * 5 + 1, 4), //DescalingDurationInMinutes = Deserializer.DeserializeToInt(result.DataArray, 5 * 5 + 1, 4), //LastErrorCode = Deserializer.DeserializeToInt(result.DataArray, 6 * 5 + 1, 4), //OrientationLightState = Deserializer.DeserializeToInt(result.DataArray, 7 * 5 + 1, 4), }; if (lastDeviceStateChangedEventArgs == null) { // Invoke event for initial state of the device DeviceStateChanged?.Invoke(this, deviceStateChangedEventArgs); } else { // Only invoke event if something changed if (!deviceStateChangedEventArgs.Equals(lastDeviceStateChangedEventArgs)) { var dsc = deviceStateChangedEventArgs; var ldsc = lastDeviceStateChangedEventArgs; DeviceStateChanged?.Invoke(this, new DeviceStateChangedEventArgs() { IsUserSitting = dsc.IsUserSitting != ldsc.IsUserSitting ? dsc.IsUserSitting : null, IsAnalShowerRunning = dsc.IsAnalShowerRunning != ldsc.IsAnalShowerRunning ? dsc.IsAnalShowerRunning : null, IsLadyShowerRunning = dsc.IsLadyShowerRunning != ldsc.IsLadyShowerRunning ? dsc.IsLadyShowerRunning : null, IsDryerRunning = dsc.IsDryerRunning != ldsc.IsDryerRunning ? dsc.IsDryerRunning : null, }); } } lastDeviceStateChangedEventArgs = deviceStateChangedEventArgs; }
private static void DeviceStatusCallBackPro(int nethandle, int devhandle, int alive_status, int status_handle) { string ip = string.Empty; ip = DevInstanceMgr.DevFindDevIP(devhandle); DeviceStateChangedEventArgs args = new DeviceStateChangedEventArgs(alive_status, ip); if (DevInstanceMgr.dicIPDevInfo.ContainsKey(ip)) { if (DevInstanceMgr.dicIPDevInfo[ip].type == 1) { LNK_BARRIER_ISDK_X64.ExuteDelegate(1, args); } if (DevInstanceMgr.dicIPDevInfo[ip].type == 2) { LNK_LED_ISDK_X64.ExuteDelegate(1, args); } } }
////http://www.highoncoding.com/Articles/532_How%20to%20access%20GPS%20in%20Windows%20Mobile%20devices.aspx //private delegate void MessageHandler(object sender, DeviceStateChangedEventArgs args); //private void UpdateControl(object sender, DeviceStateChangedEventArgs args) //{ // UpdateData(sender, args); // //control.Text = message; //} //========================================================================== void gps_DeviceStateChanged(object sender, DeviceStateChangedEventArgs args) { ////http://www.highoncoding.com/Articles/532_How%20to%20access%20GPS%20in%20Windows%20Mobile%20devices.aspx //MessageHandler dev_change = UpdateControl; //device = args.DeviceState; //Invoke(dev_change, status, device); //Invoke(cu, tbGPSDeviceState, device.DeviceState.ToString()); //Invoke(cu, tbGPSServiceState, device.ServiceState.ToString()); // call the UpdateData method via the updateDataHandler so that we // update the UI on the UI thread try { BeginInvoke(updateDataHandler); } catch (NullReferenceException) { } }
private void lnbr_OnDeviceStateChangedEvent(object sender, DeviceStateChangedEventArgs e) { string message = string.Empty; if (e.State == 0) { message = "设备在线状态事件------设备在线状态:离线\r\n\r\n"; } if (e.State == 1) { message = "设备在线状态事件------设备IP:" + e.IP + " 设备在线状态:在线\r\n\r\n"; } LogHelper.Log.Info(message); (from x in GlobalEnvironment.ListOragnization where x.IP == e.IP select x).ToList <Equipment>().ForEach(x => x.Online = e.State == 1); if (null != this.OnDeviceStateChanged) { this.OnDeviceStateChanged(sender, e); } }
/// <summary> /// 状态变化时显示状态动画 /// </summary> private void temp_OnDeviceStateChanged(object sender, DeviceStateChangedEventArgs e) { //查找主控板 var temp = GlobalEnvironment.CurrWorkStationOragnization.Where(x => x.ORGANIZATION_CODE == _Plugin.DEVICE_ID).FirstOrDefault(); if (e.IP == temp.IP) { try { string filePath = e.State == 0 ? GlobalEnvironment.BasePath + "Image\\RoadNogate.png" : GlobalEnvironment.BasePath + "Image\\GateNormalClose.png"; if (File.Exists(filePath)) { this.picGate.Image = new Bitmap(filePath); } } catch (Exception ex) { LogHelper.Log.Error(ex.Message, ex.InnerException); } } }
void myGpsController_DeviceStateChanged(object sender, DeviceStateChangedEventArgs args) { }
private void MmNotificationClient_DeviceStateChanged(object sender, DeviceStateChangedEventArgs e) { this.audioDevicesChangedTimer.Stop(); this.audioDevicesChangedTimer.Start(); }
private void device_StateChanged(object sender, DeviceStateChangedEventArgs e) { // image acquistion must be canceled because application's form is closing if (trasferenciaCanceladaPorFormFechado) { // cancel image acquisition lDispositivo.CancelTransfer(); } }
private void OnDeviceStateChanged(DeviceStateChangedEventArgs message) { Logger.SerlogInfo("OnDeviceStateChanged", new Dictionary<string, object> { {"Id", message.DeviceId}, {"Method", message.Method}, {"DimLevel", message.DimLevel} }); var action = CreateControlAction(message); var response = new ControlChange(IdConverter.GetDeviceId(message.DeviceId), action); TellPluginPort(response); }
private void HttpPeripheral_DeviceStateChange(object source, DeviceStateChangedEventArgs args) { Debug.WriteLine(args.PeripheralInfo.Name); }
private void Device_StateChanged(object sender, DeviceStateChangedEventArgs e) { Console.WriteLine(e); }
public void RaiseDeviceStateChangedEvent(DeviceStateChangedEventArgs args) { TelldusCoreMock.Raise(m => m.DeviceStateChanged += null, args); }
private void M_client_DeviceStateChanged(object sender, DeviceStateChangedEventArgs e) { logger.Debug($"M_client_DeviceStateChanged "); }