private async void OnUpdateCamera(object sender, RoutedEventArgs e) { if (this.device == null) { return; } var info = this.device.CameraInfo; var update = info.UpdateAvailable; if (update == null) { return; } // stop displaying video. Disconnect(); info.UpdatingFirmware = true; // this causes static image to change. ShowStaticImage("ms-appx:/Assets/Gear.png"); try { using (var zipFile = await device.GetZipAsync(update.Download)) { string systemFirmware = update.SystemFirmware; if (!string.IsNullOrEmpty(systemFirmware)) { var binStream = device.GetSystemFirmware(zipFile, systemFirmware); string result = await device.UploadFirmware(systemFirmware, binStream); if (result != null) { ShowError(result); } else { await device.RebootDevice(); } } // todo: here we need to ping the UDP message to find out when camera is back so we // can then Reconnect(). Then do web ui update... } } catch (Exception ex) { // crap - now what state is the camera in??? ShowError(ex.Message); } }
private async void OnRebootClick(object sender, RoutedEventArgs e) { Button b = (Button)sender; b.IsEnabled = false; try { await device.RebootDevice(); } finally { b.IsEnabled = true; } }