private void RefreshVideoCaptureDevices(IList <MediaDevice> videoCaptureDevices) { RunOnUiThread(() => { Collection <MediaDevice> videoCaptureDevicesToRemove = new Collection <MediaDevice>(); foreach (MediaDevice videoCaptureDevice in Cameras) { if (videoCaptureDevices.FirstOrDefault(x => x.Id == videoCaptureDevice.Id) == null) { videoCaptureDevicesToRemove.Add(videoCaptureDevice); } } foreach (MediaDevice removedVideoCaptureDevices in videoCaptureDevicesToRemove) { if (SelectedCamera != null && SelectedCamera.Id == removedVideoCaptureDevices.Id) { SelectedCamera = null; } Cameras.Remove(removedVideoCaptureDevices); } foreach (MediaDevice videoCaptureDevice in videoCaptureDevices) { if (Cameras.FirstOrDefault(x => x.Id == videoCaptureDevice.Id) == null) { Cameras.Add(videoCaptureDevice); } } if ((SelectedCamera == null) && Cameras.Count > 0) { Debug.WriteLine("SelectedCamera RefreshVideoCaptureDevices() Update"); SelectedCamera = Cameras.FirstOrDefault(); } }); }
protected internal override void OnDelete() { Cameras.Remove(this); if (Main != null && Main == this) { Main = null; } }
/// <summary> /// Refresh video capture devices list. /// </summary> private async Task RefreshVideoCaptureDevices() { var videoCaptureDevices = (await _mediaSettings.GetVideoCaptureDevicesAsync()).Devices; var removedDevicesInfo = ""; var videoCaptureDevicesToRemove = new Collection <MediaDevice>(); Cameras = Cameras ?? new ObservableCollection <MediaDevice>(); foreach ( var videoCaptureDevice in Cameras.Where( videoCaptureDevice => videoCaptureDevices.FirstOrDefault(x => x.Id == videoCaptureDevice.Id) == null)) { videoCaptureDevicesToRemove.Add(videoCaptureDevice); if (EtwStatsEnabled) { removedDevicesInfo += "id = " + videoCaptureDevice.Id + " name = " + videoCaptureDevice.Name + "\n"; } } foreach (var removedVideoCaptureDevices in videoCaptureDevicesToRemove) { if (SelectedCamera != null && SelectedCamera.Id == removedVideoCaptureDevices.Id) { SelectedCamera = null; } Cameras.Remove(removedVideoCaptureDevices); } if (removedDevicesInfo != "") { ETWEventLogger.Instance.LogEvent("Video Device(s) Removed", removedDevicesInfo, DateTimeOffset.Now.ToUnixTimeMilliseconds().ToString()); } var addedDevicesInfo = ""; foreach (var videoCaptureDevice in videoCaptureDevices) { if (Cameras.FirstOrDefault(x => x.Id == videoCaptureDevice.Id) == null) { Cameras.Add(videoCaptureDevice); if (EtwStatsEnabled) { addedDevicesInfo += "id = " + videoCaptureDevice.Id + " name = " + videoCaptureDevice.Name + "\n"; } } } if (addedDevicesInfo != "") { ETWEventLogger.Instance.LogEvent("Video Device(s) Added", addedDevicesInfo, DateTimeOffset.Now.ToUnixTimeMilliseconds().ToString()); } if (SelectedCamera == null) { SelectedCamera = Cameras.FirstOrDefault(); } }
private void DeleteEquipment(Type equipmentType) { if (ViewManager.ShowMessageBox("$FovSettingsVM.WarningTitle", "$FovSettingsVM.DeleteEquipmentMessage", MessageBoxButton.YesNo) == MessageBoxResult.Yes) { if (equipmentType == typeof(Telescope)) { Telescopes.Remove(Telescope); TelescopeId = Guid.Empty; NotifyPropertyChanged(nameof(Telescopes), nameof(TelescopeId)); Calculate(); SaveEquipment(); } else if (equipmentType == typeof(Eyepiece)) { Eyepieces.Remove(Eyepiece); EyepieceId = Guid.Empty; NotifyPropertyChanged(nameof(Eyepieces), nameof(EyepieceId)); Calculate(); SaveEquipment(); } else if (equipmentType == typeof(Camera)) { Cameras.Remove(Camera); CameraId = Guid.Empty; NotifyPropertyChanged(nameof(Cameras), nameof(CameraId)); Calculate(); SaveEquipment(); } else if (equipmentType == typeof(Binocular)) { Binoculars.Remove(Binocular); BinocularId = Guid.Empty; NotifyPropertyChanged(nameof(Binoculars), nameof(BinocularId)); Calculate(); SaveEquipment(); } } }
public void RemoveCamera(CameraViewModel camera) { Cameras.Remove(camera); _manager.cameras.Remove(camera.Model); }
public override void Destroy() { Cameras.Remove(this); base.Destroy(); }
protected internal override void OnDisable() { Cameras.Remove(this); }
public static void RemoveCamera(Camera2D camera) { Cameras.Remove(camera); }