Inheritance: System.EventArgs
Exemplo n.º 1
0
        /// <summary>
        ///     Remove a device from the Set.
        /// </summary>
        /// <param name="device"></param>
        /// <returns>
        ///     true if the element is successfully found and removed; otherwise, false.  This method returns false if
        ///     <paramref name="deviceName" /> is not found in the <see cref="T:System.Collections.Generic.HashSet`1" /> object.
        /// </returns>
        public bool UnselectDevice(IAudioDevice device)
        {
            var result = false;
            DeviceListChanged eventChanged = null;

            switch (device.Type)
            {
            case AudioDeviceType.Playback:
                result       = SelectedPlaybackDevicesList.Remove(device.FriendlyName);
                eventChanged = new DeviceListChanged(SelectedPlaybackDevicesList, device.Type);
                break;

            case AudioDeviceType.Recording:
                result       = SelectedRecordingDevicesList.Remove(device.FriendlyName);
                eventChanged = new DeviceListChanged(SelectedRecordingDevicesList, device.Type);
                break;

            default:
                throw new ArgumentOutOfRangeException();
            }

            if (result)
            {
                SelectedDeviceChanged?.Invoke(this, eventChanged);
                AppConfigs.Configuration.Save();
            }
            return(result);
        }
Exemplo n.º 2
0
        /// <summary>
        ///     Remove a device from the Set.
        /// </summary>
        /// <param name="device"></param>
        /// <returns>
        ///     true if the element is successfully found and removed; otherwise, false.  This method returns false if
        ///     <paramref name="deviceName" /> is not found in the <see cref="T:System.Collections.Generic.HashSet`1" /> object.
        /// </returns>
        public bool UnselectDevice(IAudioDevice device)
        {
            var result = false;
            DeviceListChanged eventChanged = null;
            switch (device.Type)
            {
                case AudioDeviceType.Playback:
                    result = SelectedPlaybackDevicesList.Remove(device.FriendlyName);
                    eventChanged = new DeviceListChanged(SelectedPlaybackDevicesList, device.Type);
                    break;
                case AudioDeviceType.Recording:
                    result = SelectedRecordingDevicesList.Remove(device.FriendlyName);
                    eventChanged = new DeviceListChanged(SelectedRecordingDevicesList, device.Type);
                    break;
                default:
                    throw new ArgumentOutOfRangeException();
            }

            if (result)
            {
                SelectedDeviceChanged?.Invoke(this, eventChanged);
                AppConfigs.Configuration.Save();
            }
            return result;
        }