Table of Contents

Class DeviceRemovedAddedEventArgs

Namespace
VisioForge.Core.Types.Events
Assembly
VisioForge.Core.dll

Provides data for device removal and addition events, notifying when media devices are connected or disconnected from the system.

public class DeviceRemovedAddedEventArgs : EventArgs

Inheritance

Inherited Members

Examples

// Event handler for device changes
void OnDeviceChanged(object sender, DeviceRemovedAddedEventArgs e)
{
    if (e.Type == DeviceRemovedAddedType.AudioCaptureDeviceAdded)
    {
        Console.WriteLine($"New microphone connected: {e.Name}");
        // Refresh the list of available microphones
        RefreshAudioDeviceList();
    }
    else if (e.Type == DeviceRemovedAddedType.VideoCaptureDeviceRemoved)
    {
        Console.WriteLine($"Camera disconnected: {e.Name}");
        // Check if this was the active camera
        if (currentCamera?.Name == e.Name)
        {
            StopCapture();
            ShowDeviceDisconnectedMessage();
        }
    }
}

// Subscribe to device change events
deviceMonitor.DeviceChanged += OnDeviceChanged;

Remarks

This event args class is used to notify applications about hardware changes in real-time, allowing them to respond appropriately when devices are plugged in or removed. This is particularly important for media applications that need to maintain awareness of available capture devices, audio devices, and other media hardware.

Common scenarios that trigger these events include: - USB webcams being connected or disconnected - Audio devices (microphones, speakers) being plugged in or removed - Capture cards being installed or removed - Virtual devices being created or destroyed - Bluetooth audio devices connecting or disconnecting

This functionality is only available on Windows platforms where device change notifications are supported through Windows APIs. On other platforms, periodic device enumeration may be needed.

Constructors

DeviceRemovedAddedEventArgs(string, DeviceRemovedAddedType)

Initializes a new instance of the VisioForge.Core.Types.Events.DeviceRemovedAddedEventArgs class with information about the device change.

public DeviceRemovedAddedEventArgs(string name, DeviceRemovedAddedType type)

Parameters

name string

The name of the device that was added or removed. Cannot be null or empty.

type DeviceRemovedAddedType

The type of device change that occurred, specifying both device category and action (added/removed).

Examples

// Notify about a new webcam being connected
var args = new DeviceRemovedAddedEventArgs(
    "Logitech BRIO", 
    DeviceRemovedAddedType.VideoCaptureDeviceAdded);
DeviceChanged?.Invoke(this, args);

// Notify about a microphone being disconnected
var args2 = new DeviceRemovedAddedEventArgs(
    "Realtek HD Audio Mic", 
    DeviceRemovedAddedType.AudioCaptureDeviceRemoved);
DeviceChanged?.Invoke(this, args2);

Remarks

This constructor is typically called by device monitoring components when they detect hardware changes through operating system notifications. The information provided helps applications maintain accurate device inventories and respond to hardware changes.

Exceptions

ArgumentNullException

Thrown when name is null.

ArgumentException

Thrown when name is empty or contains only whitespace.

Properties

Name

Gets the name of the device that was added or removed.

public string Name { get; }

Property Value

string

Remarks

The device name format varies by device type and manufacturer: - Webcams: Often include manufacturer and model (e.g., "Logitech HD Pro Webcam C920") - Audio devices: May include type and model (e.g., "Blue Yeti USB Microphone") - Virtual devices: Usually have descriptive names (e.g., "OBS Virtual Camera")

This name can be used to match against device enumerations to identify specific devices or to display user-friendly notifications about device changes.

Type

Gets the type of device change that occurred, indicating both the device category and whether it was added or removed.

public DeviceRemovedAddedType Type { get; }

Property Value

DeviceRemovedAddedType

Remarks

The type information allows applications to filter events and respond only to relevant device changes. For example: - A video recording application might only care about video capture devices - An audio mixing application might monitor both audio capture and renderer devices - A streaming application might need to track all device types

Use this property to implement appropriate responses based on device category and the nature of the change (addition vs. removal).