/// <summary> /// Implementation of the select all devices command. /// </summary> private void SelectAllDevices() { foreach (HoloLensMonitorControl monitor in this.GetCopyOfRegisteredDevices()) { HoloLensMonitorControlViewModel monitorViewModel = monitor.ViewModel; monitorViewModel.IsSelected = true; } }
/// <summary> /// Registers the HoloLensMonitor with the application. /// </summary> /// <param name="monitor">HoloLens to register.</param> /// <param name="name">Descriptive name of the HoloLens.</param> /// <returns>Task object used for tracking method completion.</returns> private async Task RegisterHoloLensAsync( HoloLensMonitor monitor, string name) { HoloLensMonitorControl holoLensMonitorControl = new HoloLensMonitorControl(monitor); holoLensMonitorControl.Disconnected += HoloLensMonitorControl_Disconnected; holoLensMonitorControl.TagChanged += HoloLensMonitorControl_TagChanged; HoloLensMonitorControlViewModel viewModel = holoLensMonitorControl.DataContext as HoloLensMonitorControlViewModel; viewModel.Name = name; this.RegisteredDevices.Add(holoLensMonitorControl); if (this.RegisteredDevices.Count > 0) { this.HaveRegisteredDevices = true; } await this.SaveConnectionsAsync(); }
/// <summary> /// Saves HoloLens connections to disk. /// </summary> /// <returns>Task object used for tracking method completion.</returns> private async Task SaveConnectionsAsync() { if (this.suppressSave) { return; } List <ConnectionInformation> connections = new List <ConnectionInformation>(); foreach (HoloLensMonitorControl monitor in this.GetCopyOfRegisteredDevices()) { HoloLensMonitorControlViewModel monitorViewModel = monitor.ViewModel; connections.Add(new ConnectionInformation( monitorViewModel.Address, monitorViewModel.Name)); } try { StorageFile connectionsFile = await this.localFolder.CreateFileAsync( MainPage.ConnectionsFileName, CreationCollisionOption.ReplaceExisting); using (Stream stream = await connectionsFile.OpenStreamForWriteAsync()) { XmlSerializer serializer = new XmlSerializer(typeof(List <ConnectionInformation>)); serializer.Serialize(stream, connections); await stream.FlushAsync(); } } catch { this.StatusMessage = "Failed to save connection information"; } }