Exemplo n.º 1
0
        public async Task InitAsync()
        {
            // NEEDS BT VERIFICATION IF THIS STILL HAPPENS: check if there is a MeTile to grab (otherwise you get an exception
            // that will also kill the BT connection for daring to read to far beyond the Stream)
            // Need to find a workaround, since this is not exposed in the new lib: var tileId = _client.GetMeTileId();

            BandImage meTileImage = null;

            try
            {
                meTileImage = await _client.PersonalizationManager.GetMeTileImageAsync();
            }
            catch (InvalidOperationException)
            { } // no background image

            if (meTileImage != null)
            {
                _background = meTileImage.ToWriteableBitmap();
            }


            _themeColor = await _client.PersonalizationManager.GetThemeAsync();

            SetColorProperties();

            // Notify that all properties have changed
            NotifyPropertyChanged(null);

            _inited = true;
        }
        private static async Task SetThemeAsync(IBandClient bandClient)
        {
            var bandTheme = new BandTheme()
            {
                Base = new BandColor(0x08, 0x22, 0x5B),
                Highlight = new BandColor(0x0D, 0x36, 0x7F),
                Lowlight = new BandColor(0x06, 0x1C, 0x3E),
                Muted = Colors.Gray.ToBandColor(),
                SecondaryText = Colors.Black.ToBandColor()
            };

            await bandClient.PersonalizationManager.SetThemeAsync(bandTheme);
        }
Exemplo n.º 3
0
 internal void SetBandTheme(BandTheme theme)
 {
     LowlightColour = new SolidColorBrush(Color.FromArgb(255,
         theme.Lowlight.R, theme.Lowlight.G, theme.Lowlight.B));
     HighlightColour = new SolidColorBrush(Color.FromArgb(255,
         theme.Highlight.R, theme.Highlight.G, theme.Highlight.B));
     TileColour = new SolidColorBrush(Color.FromArgb(255,
         theme.Base.R, theme.Base.G, theme.Base.B));
     HighContrastColour = new SolidColorBrush(Color.FromArgb(255,
         theme.HighContrast.R, theme.HighContrast.G, theme.HighContrast.B));
     MutedColour = new SolidColorBrush(Color.FromArgb(255,
         theme.Muted.R, theme.Muted.G, theme.Muted.B));
     SecondaryTextColour = new SolidColorBrush(Color.FromArgb(255,
         theme.SecondaryText.R, theme.SecondaryText.G, theme.SecondaryText.B));
 }
 public Task SetThemeAsync(BandTheme theme, CancellationToken cancel)
 {
     throw new NotImplementedException();
 }
 public Task SetThemeAsync(BandTheme theme)
 {
     throw new NotImplementedException();
 }
        public Task SetThemeAsync(BandTheme theme, CancellationToken cancel)
        {
            var tcs = new TaskCompletionSource<bool>();
            Task.Run(() =>
            {
                Task.Delay(500, cancel);

                _bandTheme.HighContrast = theme.HighContrast;
                _bandTheme.Highlight = theme.Highlight;
                _bandTheme.Lowlight = theme.Lowlight;
                _bandTheme.Muted = theme.Muted;
                _bandTheme.SecondaryText = theme.SecondaryText;
                _bandTheme.Base = theme.Base;

                tcs.SetResult(true);
            });

            return tcs.Task;
        }
 public FakeBandPersonalizationManager()
 {
     _bandTheme = CreateBandTheme();
 }
		public static Task SetThemeTaskAsync (this IBandPersonalizationManager manager, BandTheme theme)
		{
			var tcs = new TaskCompletionSource<object> ();
			manager.SetThemeAsync (theme, tcs.AttachCompletionHandler ());
			return tcs.Task;
		}
Exemplo n.º 9
0
        private async void SetGetTheme_Click(object sender, RoutedEventArgs args)
        {
            IBandInfo[] pairedBands;
            IBandClient client = null;

            this.viewModel.StatusMessage = "Running Theme demo ...";

            // Enumerate Bands that are paired to this device.
            pairedBands = await BandClientManager.Instance.GetBandsAsync();

            if (pairedBands.Length == 0)
            {
                this.viewModel.StatusMessage = "This sample app requires a Microsoft Band paired to your device. Also make sure that you have the latest firmware installed on your Band, as provided by the latest Microsoft Health app.";
                return;
            }

            try
            {
                // Connect to the first Band in the enumeration.
                client = await BandClientManager.Instance.ConnectAsync(pairedBands[0]);
            }
            catch (Exception e)
            {
                this.viewModel.StatusMessage = "Failed to connect to a Band.\r\n" + e.Message;
                return;
            }

            using (client)
            {
                // Set up a custom theme.
                BandTheme theme = new BandTheme
                {
                    Base          = Colors.BurlyWood.ToBandColor(),
                    Highlight     = Colors.BlanchedAlmond.ToBandColor(),
                    Lowlight      = Colors.Azure.ToBandColor(),
                    SecondaryText = Colors.DarkGreen.ToBandColor(),
                    HighContrast  = Colors.LightGreen.ToBandColor(),
                    Muted         = Colors.Purple.ToBandColor()
                };

                // Set the theme on the band.
                await client.PersonalizationManager.SetThemeAsync(theme);

                // Get the theme from the band.
                theme = await client.PersonalizationManager.GetThemeAsync();

                // Display the theme on screen.
                ThemeColor_Base.Background          = new SolidColorBrush(theme.Base.ToColor());
                ThemeColor_Highlight.Background     = new SolidColorBrush(theme.Highlight.ToColor());
                ThemeColor_Lowlight.Background      = new SolidColorBrush(theme.Lowlight.ToColor());
                ThemeColor_SecondaryText.Background = new SolidColorBrush(theme.SecondaryText.ToColor());
                ThemeColor_HighContrast.Background  = new SolidColorBrush(theme.HighContrast.ToColor());
                ThemeColor_Muted.Background         = new SolidColorBrush(theme.Muted.ToColor());
            }

            this.viewModel.StatusMessage = "Done.";
        }