/// <summary>Construct the page.</summary> /// <param name="Band">Band instance</param> public MainPage(BandInterface Band) { this.Band = Band; this.ViewModel = new MainPageViewModel(this); this.BindingContext = this.ViewModel; this.InitializeComponent(); this.Render(); }
/// <summary>Render!<summary> private async void Render() { this.ViewModel.Band = this.Band; this.ViewModel.BandTime = await this.Band.GetDeviceTime(); this.ViewModel.BandSerialNumber = await this.Band.GetSerialNumber(); this.ViewModel.LastSleep = await this.Band.GetLastSleep(); }
/// <summary> /// Connect to a given Band, replacing any existing Band instance. /// /// Throws if already connected. /// </summary> /// <param name="Band">Band to connect to</param> /// <returns>Task</returns> /// <exception cref="BandConnectionConnected"></exception> public async Task Connect(BandInterface Band) { if (!this.Connected) { this.Band = Band; await this.Connect(); } else { throw new BandConnectionConnected(); } }
/// <summary>Get Band connection and render main page.</summary> /// <param name="BandClient">Band client instance</param> protected async void Launch(BandClientInterface BandClient) { try { // Connect to Band this.BandClient = BandClient; this.Band = (await this.BandClient.GetPairedBands())[0]; await this.Band.Connect(); // Render main page! this.MainPage = new MainPage(this.Band); } catch (Exception) { this.LaunchPage.DisplayError(); } }
/// <summary> /// Create a new connection instance with a given Band. /// </summary> /// <param name="Band">Band to connect to</param> public BandConnection(BandInterface Band) : this() { this.Band = Band; }