/// <summary> /// Cleans up a specific device /// </summary> /// <param name="device">Device to clean up</param> void CleanUpDevice(CapDevice device) { // Check if there even is a device if (device == null) { return; } // Stop device.Stop(); // Unsubscribe device.NewBitmapReady -= device_OnNewBitmapReady; }
/// <summary> /// Invoked when the MonikerString dependency property has changed /// </summary> /// <param name="sender">Sender</param> /// <param name="e">EventArgs</param> private static void MonikerString_Changed(DependencyObject sender, DependencyPropertyChangedEventArgs e) { // Get typed sender CapDevice typedSender = sender as CapDevice; if (typedSender != null) { // Always stop the device typedSender.Stop(); // Get the new value string newMonikerString = e.NewValue as string; // Check if we have a valid moniker string if (!string.IsNullOrEmpty(newMonikerString)) { // Initialize device typedSender.InitializeDeviceForMoniker(newMonikerString); // Start typedSender.Start(); } } }
/// <summary> /// Cleans up a specific device /// </summary> /// <param name="device">Device to clean up</param> void CleanUpDevice(CapDevice device) { // Check if there even is a device if (device == null) return; // Stop device.Stop(); // Unsubscribe device.NewBitmapReady -= device_OnNewBitmapReady; }