/// <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); }
public DevicesView() { this.SelectionMode = ListViewItemsSelectionMode.Single; this.SelectionChanged += (o, e) => { SelectedDeviceChanged?.Invoke(this, new EventsArgs <string>(this.SelectedDevice)); }; }
private void OnSelectedIndexChanged(object sender, EventArgs e) { SelectedDeviceChanged handler = this.OnSelectedDeviceChanged; if (handler != null) { handler(this.deviceName.SelectedIndex); } }
/// <summary> /// Selection changed. /// </summary> private void OnSelectedIndexChanged(object sender, EventArgs e) { try { var selection = SelectedDevice; if ((selection != null) && (selection.IsConnected)) { UserPreferences.Preferences.PreferredDeviceSerial = selection.Serial; UserPreferences.SaveNow(); } } catch (Exception ex) { ErrorLog.DumpError(ex); } SelectedDeviceChanged.Fire(this); }
public LocationsView() { InitializeComponent(); bool ignoreUserNavigation = false; usersView.SelectedUserChanged += (o, e) => { if (usersView.SelectedUser != null) { devicesView.Devices = usersView.SelectedUser .Geolocations .Select(x => x.Device) .Distinct() .ToArray(); } else { devicesView.Devices = new string[0]; } SelectedUserChanged?.Invoke(this, new EventsArgs <IGeolocationTarget>(SelectedUser)); devicesView.SelectedDevice = devicesView.Devices.FirstOrDefault(); }; devicesView.SelectedDeviceChanged += (o, e) => { if (!ignoreUserNavigation && SelectedUser != null) { locationsView.NavigateTo(SelectedUser.Name, SelectedDevice); } SelectedDeviceChanged?.Invoke(this, new EventsArgs <string>(SelectedDevice)); HideDevicesExcept(e.Value); }; locationsView.UserNavigated += (o, e) => { ignoreUserNavigation = true; usersView.SelectedUser = usersView.Users.FirstOrDefault(x => x.Id == e.Value.UserId); devicesView.SelectedDevice = e.Value.DeviceId; ignoreUserNavigation = false; }; locationsView.SelectedPlaceChanged += (o, e) => SelectedPlaceChanged?.Invoke(this, e); this.Loaded += (o, e) => FitToMarkers(); }
/// <summary> /// Raises a SelectedDeviceChanged event. /// </summary> private void OnSelectedDeviceChanged() { SelectedDeviceChanged?.Invoke(this, EventArgs.Empty); }