예제 #1
0
        public void UpdateStateDevice(EDeviceState deviceState, int id)
        {
            foreach (ListViewItem row in list_view_devices.Items)
            {
                if ((int)row.Tag == id)
                {
                    row.ImageIndex = (int)deviceState;
                    break;
                }
            }
            if (_controller.CurrentVideoCapture == id)
            {
                switch (deviceState)
                {
                case EDeviceState.Runing:
                    image_state.BackColor = Color.Green;
                    break;

                case EDeviceState.Recording:
                    image_state.BackColor = Color.Red;
                    break;

                case EDeviceState.Stoped:
                    image_grid.Image      = null;
                    image_state.BackColor = SystemColors.Control;
                    break;
                }
            }
            EnableDeviceButtons();
        }
예제 #2
0
 public DeviceInfo(string deviceId, string name, EDataFlow flow, EDeviceState state)
 {
     _deviceId     = deviceId;
     _friendlyName = name;
     _dataFlow     = flow;
     _state        = state;
 }
 public void OnDeviceStateChanged(string deviceId, EDeviceState newState)
 {
     if (DeviceStateChanged != null)
     {
         DeviceStateChanged(deviceId, newState);
     }
 }
 public MMDeviceCollection EnumerateAudioEndPoints(EDataFlow dataFlow, EDeviceState dwStateMask)
 {
     IMMDeviceCollection result;
     //Marshal.ThrowExceptionForHR(_realEnumerator.EnumAudioEndpoints(dataFlow, dwStateMask, out result));
     _realEnumerator.EnumAudioEndpoints(dataFlow, dwStateMask, out result);
     return new MMDeviceCollection(result, dataFlow, dwStateMask);
 }
예제 #5
0
        public int OnDeviceStateChanged(string DeviceId, EDeviceState newState)
        {
            DeviceStateChangedEventArgs arg = new DeviceStateChangedEventArgs(DeviceId, newState);

            _DeviceEnumerator.FireDeviceStateChangedEvent(arg);
            return(0);
        }
예제 #6
0
		public void TurnOn()
		{
			if (this.PowerState != EDeviceState.BROKEN)
			{
				this.PowerState = EDeviceState.ON;
			}
		}
예제 #7
0
        /// <summary>
        /// Find audio endpoint by name
        /// </summary>
        /// <param name="name">the name of the endpint</param>
        /// <param name="deviceflow">whenever it is input or output or both</param>
        /// <param name="state">whenever it is enabled,disabled unpluged or both</param>
        /// <returns>the desired endpoint</returns>
        public MMDevice FindEndpointByName(string name, EDataFlow deviceflow,
                                           EDeviceState state)
        {
            try
            {
                MMDevice           device  = null;
                MMDeviceCollection devices = this.GetAllAudioEndPoints(deviceflow, state);

                if (devices != null)
                {
                    for (int i = 0; i < devices.Count; i++)
                    {
                        MMDevice deviceAt = devices[i];
                        if (deviceAt.FriendlyName.ToLower() == name)
                        {
                            device = deviceAt;
                            break;
                        }
                    }
                }



                return(device);
            }
            catch (Exception e)
            {
                Program.Bugtracking(e);
                return(null);
            }
        }
예제 #8
0
 public void OnDeviceStateChanged(string deviceId, EDeviceState newState)
 {
     if (DeviceStateChanged != null)
     {
         DeviceStateChanged(deviceId, newState);
     }
 }
예제 #9
0
        public MMDeviceCollection EnumerateAudioEndPoints(EDataFlow dataFlow, EDeviceState dwStateMask)
        {
            IMMDeviceCollection result;

            Marshal.ThrowExceptionForHR(_realEnumerator.EnumAudioEndpoints(dataFlow, dwStateMask, out result));
            return(new MMDeviceCollection(result));
        }
예제 #10
0
 void IMultimediaNotificationClient.OnDeviceStateChanged(string deviceId, EDeviceState newState)
 {
     _client._deviceStateChanged.OnNext(new DeviceStateChangedArgs
     {
         DeviceId = deviceId,
         State    = newState
     });
 }
예제 #11
0
        void ISystemAudioEventClient.OnDeviceStateChanged(string deviceId, EDeviceState newState)
        {
            var dev = GetOrAddDeviceFromRealId(deviceId);

            if (dev != null)
            {
                RaiseAudioDeviceChanged(new DeviceStateChangedEventArgs(dev, newState.AsDeviceState()));
            }
        }
예제 #12
0
        public void OnDeviceStateChanged(string deviceId, EDeviceState newState)
        {
            var inner = GetInner();

            if (inner != null)
            {
                inner.OnDeviceStateChanged(deviceId, newState);
            }
        }
예제 #13
0
        private void HandleStateChanged(DeviceStateChangedEventArgs stateChangedEvent)
        {
            _state = stateChangedEvent.State.AsEDeviceState();

            ReloadAudioEndpointVolume(_device);
            ReloadAudioMeterInformation(_device);

            OnPropertyChanged("State");
        }
        public void OnDeviceStateChanged(string deviceId, EDeviceState newState)
	    {
            if (newState == EDeviceState.Unplugged || newState == EDeviceState.Disabled || newState == EDeviceState.NotPresent)
            {
                if (DeviceRemoved != null)
                    DeviceRemoved(deviceId);
            }
            else if (newState == EDeviceState.Active)
                if (DeviceAdded != null)
                    DeviceAdded(deviceId);
	    }
        public List <ListViewItem> GetItemGroupSorted(EDeviceState state)
        {
            ListViewGroup       activeGroup = GetItemGroup(EDeviceState.Active);
            List <ListViewItem> list        = activeGroup.Items.OfType <ListViewItem>().Select(i => i).ToList();

            ListViewColumnSorter sorter = m_listDevices.ListViewItemSorter as ListViewColumnSorter;

            list.Sort((i1, i2) => ListViewColumnSorter.Compare(i1, i2, sorter.SortColumn, sorter.SortOrder));

            return(list);
        }
예제 #16
0
 public void OnDeviceStateChanged(string deviceId, EDeviceState newState)
 {
     if (newState == EDeviceState.Unplugged || newState == EDeviceState.Disabled || newState == EDeviceState.NotPresent)
     {
         if (DeviceRemoved != null)
         {
             DeviceRemoved(deviceId);
         }
     }
     else if (newState == EDeviceState.Active)
     {
         if (DeviceAdded != null)
         {
             DeviceAdded(deviceId);
         }
     }
 }
예제 #17
0
        /// <summary>
        /// Gets all the audio endpoints based on the criteria given
        /// </summary>
        /// <param name="edataflow"> choose if you want the input or output endpoints or both</param>
        /// <param name="devicestate">choose if you want to get the disabled,enabled or unpluged or all.</param>
        /// <returns></returns>
        public MMDeviceCollection GetAllAudioEndPoints(EDataFlow edataflow, EDeviceState devicestate)
        {
            try
            {
                MMDeviceCollection devices = null;

                devices = DevEnum.EnumerateAudioEndPoints(edataflow,
                                                          devicestate);


                return(devices);
            }
            catch (Exception e)
            {
                Program.Bugtracking(e);
                return(null);
            }
        }
        public ListViewGroup GetItemGroup(EDeviceState state)
        {
            switch (state)
            {
            case EDeviceState.Active:
                return(m_listDevices.Groups[0]);

            case EDeviceState.Unplugged:
                return(m_listDevices.Groups[1]);

            case EDeviceState.Disabled:
                return(m_listDevices.Groups[2]);

            case EDeviceState.NotPresent:
            default:
                return(m_listDevices.Groups[3]);
            }
        }
예제 #19
0
        private void OnStateChanged(EDeviceState deviceState)
        {
            _state = deviceState;

            ReloadAudioEndpointVolume();
            ReloadAudioMeterInformation();
            ReloadAudioSessionController();

            OnStateChanged(deviceState.AsDeviceState());

            //only load properties if it's active
            if ((deviceState & EDeviceState.Active) != 0)
            {
                //Attempt to reload properties if the device has become active.
                //A fail-safe incase the device doesn't fire property changed events
                //when it becomes "active"
                ComThread.BeginInvoke(LoadProperties);
            }
        }
예제 #20
0
 void deviceStateChanged(EDeviceState state)
 {
     if (state == EDeviceState.Offline)
     {
         lblState.Text = "Offline";
         lblState.ForeColor = Color.Gray;
     }
     if (state == EDeviceState.PortOpen)
     {
         lblState.Text = "Opened";
         lblState.ForeColor = Color.Yellow;
     }
     if (state == EDeviceState.Online)
     {
         Invoke(deviceConnectedMethod);
         lblState.Text = "Connected";
         lblState.ForeColor = Color.Green;
     }
 }
예제 #21
0
        /// <summary>
        /// Find all audio endpoint containing the given  name
        /// </summary>
        /// <param name="name">the name of the endpint</param>
        /// <param name="deviceflow">whenever it is input or output or both</param>
        /// <param name="state">whenever it is enabled,disabled unpluged or both</param>
        /// <returns>the desired endpoint</returns>
        public MMDevice[] FindEndpointContaininginName(string name, EDataFlow deviceflow,
                                                       EDeviceState state)
        {
            try
            {
                MMDevice[]         device   = null;
                int                MaxAudio = 0;
                MMDeviceCollection devices  = this.GetAllAudioEndPoints(deviceflow, state);

                if (devices != null)
                {
                    for (int i = 0; i < devices.Count; i++)
                    {
                        MMDevice deviceAt = devices[i];
                        if (deviceAt.FriendlyName.Contains(name) == true)
                        {
                            ++MaxAudio;
                        }
                    }
                    device = new MMDevice[MaxAudio];
                    for (int i = 0; i < devices.Count; i++)
                    {
                        MMDevice deviceAt = devices[i];
                        if (deviceAt.FriendlyName.Contains(name) == true)
                        {
                            device[i] = deviceAt;
                        }
                    }
                }



                return(device);
            }
            catch (Exception e)
            {
                Program.Bugtracking(e);
                return(null);
            }
        }
예제 #22
0
        internal static DeviceState AsDeviceState(this EDeviceState deviceState)
        {
            switch (deviceState)
            {
            case EDeviceState.Active:
                return(DeviceState.Active);

            case EDeviceState.Disabled:
                return(DeviceState.Disabled);

            case EDeviceState.NotPresent:
                return(DeviceState.NotPresent);

            case EDeviceState.Unplugged:
                return(DeviceState.Unplugged);

            case EDeviceState.All:
                return(DeviceState.All);

            default:
                throw new ArgumentOutOfRangeException(nameof(deviceState));
            }
        }
예제 #23
0
        private void HandleStateChanged(DeviceStateChangedEventArgs stateChangedEvent)
        {
            _state = stateChangedEvent.State.AsEDeviceState();

            ReloadAudioEndpointVolume(_device);
            ReloadAudioMeterInformation(_device);

            OnPropertyChanged("State");
        }
예제 #24
0
 public DeviceFullInfo(MMDevice device) : base(device)
 {
     IconPath = device.IconPath;
     State    = device.State;
 }
예제 #25
0
 public void UpdateStateDevice(EDeviceState deviceState, int id)
 {
     _view.UpdateStateDevice(deviceState, id);
 }
예제 #26
0
 internal void FireOnDeviceStateChanged([MarshalAs(UnmanagedType.LPWStr)] string deviceId, EDeviceState newState)
 {
     //Debug.WriteLine("FireOnDeviceStateChanged");
     _OnDeviceStateChanged?.Invoke(deviceId, newState);
 }
예제 #27
0
		public void TurnOff()
		{
			this.PowerState = EDeviceState.OFF;
		}
예제 #28
0
 internal void FireOnDeviceStateChanged(string deviceId, EDeviceState newState)
 {
 }
예제 #29
0
 void SelectedPort_Disposed(EDeviceState state, SerialManager sm)
 {
     Invoke(DeviceStateChanged, state, sm);
 }
예제 #30
0
 void OnDeviceStatusChanged(EDeviceState state, SerialManager sm)
 {
     ShowMessage(device.PortName + " -->  " + state);
     if (state == EDeviceState.Offline)
     {
         DisableItems();
         device = null;
     }
 }
예제 #31
0
 protected void ChangeState(EDeviceState state)
 {
     if (state >= EDeviceState.Online)
     {
         btnSerialStatus.ForeColor = Color.Green;
     }
     if (state == EDeviceState.Busy)
     {
         btnSerialStatus.ForeColor = Color.Orange;
     }
     if (state == EDeviceState.Offline)
     {
         btnSerialStatus.ForeColor = Color.DarkRed;
     }
     if (state == EDeviceState.Error)
     {
         btnSerialStatus.ForeColor = Color.Red;
     }
     btnSerialStatus.Text = state.ToString();
 }
예제 #32
0
 public void OnDeviceStateChanged(string deviceId, EDeviceState newState)
 {
     parent.FireOnDeviceStateChanged(deviceId, newState);
 }
예제 #33
0
 public void OnDeviceStateChanged(string deviceId, EDeviceState newState)
 {
     throw new NotImplementedException();
 }
예제 #34
0
		public ElectricDevice()
		{
			this.PowerState = EDeviceState.OFF;
		}
예제 #35
0
 public int OnDeviceStateChanged(string DeviceId, EDeviceState newState)
 {
     DeviceStateChangedEventArgs arg = new DeviceStateChangedEventArgs(DeviceId, newState);
     _DeviceEnumerator.FireDeviceStateChangedEvent(arg);
     return 0;
 }
예제 #36
0
 public void OnDeviceStateChanged(string deviceId, EDeviceState newState)
 {
     throw new NotImplementedException();
 }
예제 #37
0
 public DeviceStateChangedEventArgs(string deviceId, EDeviceState newState)
 {
     DeviceId = deviceId;
     NewState = newState;
 }
예제 #38
0
 internal MMDeviceCollection(IMMDeviceCollection parent, EDataFlow flow, EDeviceState state)
 {
     _MMDeviceCollection = parent;
     DataFlow            = flow;
     DeviceState         = state;
 }
예제 #39
0
 public DeviceInfo(string deviceId, string name, EDataFlow flow, EDeviceState state)
 {
     _deviceId = deviceId;
     _friendlyName = name;
     _dataFlow = flow;
     _state = state;
 }
예제 #40
0
 void ISystemAudioEventClient.OnDeviceStateChanged(string deviceId, EDeviceState newState)
 {
     RaiseAudioDeviceChanged(new AudioDeviceChangedEventArgs(GetDevice(CoreAudioDevice.SystemIdToGuid(deviceId)),
                                                             AudioDeviceEventType.StateChanged));
 }
 internal MMDeviceCollection(IMMDeviceCollection parent, EDataFlow flow, EDeviceState state)
 {
     _MMDeviceCollection = parent;
     DataFlow = flow;
     DeviceState = state;
 }
예제 #42
0
 public void OnDeviceStateChanged(string deviceId, EDeviceState newState)
 {
     var inner = GetInner();
     if(inner != null)
         inner.OnDeviceStateChanged(deviceId, newState);
 }
예제 #43
0
 public DeviceFullInfo(string name, string id, EDataFlow type, string iconPath, EDeviceState state) : base(name, id, type)
 {
     IconPath = iconPath;
     State    = state;
 }
예제 #44
0
 public DeviceStateChangedEventArgs(string deviceId, EDeviceState newState)
 {
     DeviceId = deviceId;
     NewState = newState;
 }
예제 #45
0
 void UART_Server_OnStateChange(EDeviceState state, SerialManager sm)
 {
     try
     {
         Invoke(new Action<EDeviceState>(ChangeState), state);
     }
     catch(Exception e)
     {
     }
 }
 public Section(EDeviceState state, string name, CGColor color)
 {
     this.state = state;
     this.name  = name;
     this.color = color;
 }