private async Task <bool> ChooseTelescope() { var dlg = new DlgChooseOat() { Owner = Application.Current.MainWindow, WindowStartupLocation = WindowStartupLocation.CenterOwner }; var result = dlg.ShowDialog(); if (result == true) { //var chooser = new Chooser(); //chooser.DeviceType = "Telescope"; //var name = chooser.Choose("ASCOM.OpenAstroTracker.Telescope"); //if (!string.IsNullOrEmpty(name)) //{ // ScopeName = name; _commHandler = CommunicationHandlerFactory.ConnectToDevice(dlg.SelectedDevice); //_commHandler = new TcpCommunicationHandler(new IPAddress(new byte[] { 192, 168, 86, 61 }), 4030); _oatMount = new OatmealTelescopeCommandHandlers(_commHandler); await _oatMount.SetSiteLatitude((float)dlg.Latitude); await _oatMount.SetSiteLongitude((float)dlg.Longitude); return(true); } // Settings.Default.Scope = name; // Settings.Default.Save(); //} RequeryCommands(); return(false); }
public void ConnectToDevice() { var device = CommunicationHandlerFactory.ConnectToDevice(CommunicationHandlerFactory.AvailableDevices.First()); _cmdHandler = new OatmealTelescopeCommandHandlers(device); _cmdHandler.MountState.PropertyChanged += MountStateOnPropertyChanged; Commands.Add("GoHome", new Command(async() => { await _cmdHandler?.GoHome(); await _cmdHandler?.RefreshMountState(); })); Commands.Add("StartMoveDirection", new Command <string>(x => { _cmdHandler?.StartMoving(x); })); Commands.Add("StopMoveDirection", new Command <string>(x => { _cmdHandler?.StopMoving(x); })); Commands.Add("SetTracking", new Command <bool>(x => { _cmdHandler?.SetTracking(x); })); Commands.Add("SetLocation", new Command(async() => { var location = await Geolocation.GetLocationAsync(new GeolocationRequest(GeolocationAccuracy.Default)); await _cmdHandler?.SetLocation(location.Latitude, location.Longitude, 0, 0); })); Commands.Add("ToggleParkedState", new Command(async() => { if (_cmdHandler != null) { if (_cmdHandler.MountState.IsTracking) { await _cmdHandler?.SetTracking(false); } else { await _cmdHandler?.SetTracking(true); } } })); _cmdHandler?.RefreshMountState(); }