示例#1
0
 public async Task <bool> Connect(CancellationToken token)
 {
     return(await Task <bool> .Run(() => {
         try {
             _focuser = GetFocuser(true);
             Connected = true;
             if (Connected)
             {
                 Initialize();
                 RaiseAllPropertiesChanged();
             }
         } catch (ASCOM.DriverAccessCOMException ex) {
             Utility.Utility.HandleAscomCOMException(ex);
         } catch (System.Runtime.InteropServices.COMException ex) {
             Utility.Utility.HandleAscomCOMException(ex);
         } catch (Exception ex) {
             Logger.Error(ex);
             Notification.ShowError("Unable to connect to focuser " + ex.Message);
         }
         return Connected;
     }));
 }
示例#2
0
 public void SetupDialog()
 {
     if (HasSetupDialog)
     {
         try {
             bool dispose = false;
             if (_focuser == null)
             {
                 _focuser = GetFocuser(false);
                 dispose  = true;
             }
             _focuser.SetupDialog();
             if (dispose)
             {
                 _focuser.Dispose();
                 _focuser = null;
             }
         } catch (Exception ex) {
             Logger.Error(ex);
             Notification.ShowError(ex.Message);
         }
     }
 }
示例#3
0
 public void Disconnect()
 {
     Connected = false;
     _focuser?.Dispose();
     _focuser = null;
 }