private void Lumix_DeviceDiscovered(DeviceInfo dev, Lumix cam) { var task = model.RunAsync(() => { try { if (cam == null) { var existing = model.ConnectableDevices.SingleOrDefault(d => d.Uuid == dev.Uuid); if (existing == null) { var camerafound = false; var cameraauto = false; if (model.GeneralSettings.Cameras.TryGetValue(dev.Uuid, out var settings)) { cameraauto = settings.Autoconnect; camerafound = true; } if ((camerafound && cameraauto) || (!camerafound && model.GeneralSettings.Autoconnect)) { var connecttask = model.RunAsync(async() => { try { await ConnectCameraFirstTime(dev); } catch (Exception e) { Log.Error(e); } }); } else { model.AddConnectableDevice(dev); model.SelectedDevice = dev; } } else { model.ConnectableDevices.Remove(dev); model.ConnectableDevices.Add(dev); model.SelectedDevice = dev; } } } catch (Exception ex) { Log.Error(ex); } }); }
private void Lumix_StateUpdateFailed(Lumix cam, Lumix.UpdateStateFailReason reason) { cam.Disconnect(); var task = model.RunAsync(async() => { cam.LumixState.IsBusy = true; var result = await lumixManager.ConnectCamera(cam); if (result) { cam.LumixState.IsBusy = false; } }); }
private void UpdateCamera(Lumix newcamera) { if (currentLumix != null) { currentLumix.LiveViewUpdated -= Camera_LiveViewUpdated; } currentLumix = newcamera; if (currentLumix != null) { currentLumix.LiveViewUpdated += Camera_LiveViewUpdated; } }
private async Task ConnectCameraFirstTime(DeviceInfo dev) { var lumix = new Lumix(dev, new WindowsHttpClient()); lumix.StateUpdateFailed += Lumix_StateUpdateFailed; lumix.ActionCalled += model.LumixActionCalled; var connectedCamera = model.AddConnectedDevice(lumix); var result = await lumixManager.ConnectCamera(lumix); if (result) { model.ShowCamera(connectedCamera); lumix.LumixState.IsBusy = false; } }