public void SetTheme(BandTheme theme)
        {
            Style st = new Style();

            st.TargetType = typeof(ListBoxItem);
            Setter Highlight = new Setter();



            foreach (var item in BandLayout.Items)
            {
                if (item is ListBoxItem)
                {
                    ListBoxItem it = (ListBoxItem)item;
                    if (it.Tag != null)
                    {
                        //it.Style.Setters.Add(new Setter(ListBoxItem.))

                        if (it.Tag.ToString() == "BaseColorStatic")
                        {
                            it.Background = new SolidColorBrush(theme.Base.ToColor());
                        }
                        else if (it.Tag.ToString() == "BaseColorHighlighted")
                        {
                            it.Background = new SolidColorBrush(theme.HighContrast.ToColor());
                        }
                    }
                }
            }
        }
 public void Set_Color(BandTheme theme)
 {
     try
     {
         foreach (var item in BandLayout.Items)
         {
             if (item is ListBoxItem)
             {
                 ListBoxItem it = (ListBoxItem)item;
                 if (it.Tag != null)
                 {
                     if (it.Tag.ToString() == "Base")
                     {
                         it.Background = new SolidColorBrush(theme.Base.ToColor());
                     }
                     else if (it.Tag.ToString() == "Lowlight")
                     {
                         it.Background = new SolidColorBrush(theme.Lowlight.ToColor());
                     }
                 }
             }
         }
     }
     catch (Exception e)
     {
         System.Diagnostics.Debug.Write(e);
     }
 }
        public async Task Load_Theme(BandTheme theme)
        {
            Base.Background         = new SolidColorBrush(_Theme.Base.ToColor());
            HighContrast.Background = new SolidColorBrush(_Theme.HighContrast.ToColor());
            Lowlight.Background     = new SolidColorBrush(_Theme.Lowlight.ToColor());
            Highlight.Background    = new SolidColorBrush(_Theme.Highlight.ToColor());
            Muted.Background        = new SolidColorBrush(_Theme.Muted.ToColor());
            Secondary.Background    = new SolidColorBrush(_Theme.SecondaryText.ToColor());

            _Base         = _Theme.Base.ToColor();
            _HighContrast = _Theme.HighContrast.ToColor();
            _Lowlight     = _Theme.Lowlight.ToColor();
            _Highlight    = _Theme.Highlight.ToColor();
            _Muted        = _Theme.Muted.ToColor();
            _Secondary    = _Theme.SecondaryText.ToColor();

            PreviewControl.Update_ColorOnPreview(-1, await Generate_BandTheme());

            if (ColorTypeSelector.SelectedIndex == -1)
            {
                ColorTypeSelector.SelectedIndex = 0;
            }
            else
            {
                Update_ColorSelectors(ColorTypeSelector.SelectedIndex);
            }
        }
Пример #4
0
        ///SingleBinding.ReloadMainPage

        public async Task Load_BandData()
        {
            IBandInfo Band_Found = await BandHandler.Get_Band();

            if (Band_Found == null)
            {
                Disable_BandFeatures();
                return;
            }



            #region Setup BandData

            if (App._CustomBandThemes == null || App._CustomBandThemes.Count == 0)
            {
                OneMomentDetails.Text  = Localization.Get_Text(Localization.Tag.Band_, "GetDetails1");
                App.OverlayApp.Overlay = true;


                #region Gets and sets the meTile
                App._MeImageTile = await Core.BandHandler.Get_Image(); /// Gets the band metile form the band

                BandPreview.SetImage(App._MeImageTile);                /// Sets the image of the previewControl
                PreviewImage.Source = App._MeImageTile;                /// Sets the image of the tapp to change control
                #endregion
                #region Gets and sets the Theme
                BandTheme tempBandTheme = await Core.BandHandler.Get_Theme(); /// Gets the current theme on the band

                BandPreview.SetTheme(tempBandTheme);                          /// Sets the preview theme as the current
                App._CurrentBandTheme  = tempBandTheme;                       /// Sets the retrieved teme as the current
                App._SelectedBandTheme = 0;                                   /// Sets the selected as 0 since the control now contains a theme. If this is not set the applicaiton will not work correctly. Possible issue of .20 -> .25 issue. Caused rewrite of this task
                App._CustomBandThemes  = await ReturnProfiles();              /// Gets the custom profiles created by user from storage.

                #endregion

                App.BandGeneration = await BandHandler.Get_BandGeneration(); /// Gets the current band generation possible values -1, 1, 2

                App.OverlayApp.Overlay = false;
            }
            else
            {
                App._CurrentBandTheme = App._CustomBandThemes[App._SelectedBandTheme].Theme;
                BandPreview.SetImage(App._MeImageTile);
                BandPreview.SetTheme(App._CurrentBandTheme);

                PreviewImage.Source = App._MeImageTile;

                Profile_Selector.SelectedIndex = App._SelectedBandTheme;

                App.ViewModel.Items.ElementAt(App._SelectedBandTheme).LineNine = "#" + await Parse._ColorToHEX(App._CurrentBandTheme.Base.ToColor());

                App.ViewModel.Items.ElementAt(App._SelectedBandTheme).LineTen = "#" + await Parse._ColorToHEX(App._CurrentBandTheme.HighContrast.ToColor());
            }

            FillBase.Fill         = new SolidColorBrush(App._CurrentBandTheme.Base.ToColor());
            FillHighContrast.Fill = new SolidColorBrush(App._CurrentBandTheme.HighContrast.ToColor());

            #endregion
        }
        public async Task SetThemeAsync(BandTheme theme)
        {
#if __ANDROID__ || __IOS__
            await Native.SetThemeTaskAsync(theme.ToNative());
#elif WINDOWS_PHONE_APP
            await Native.SetThemeAsync(theme.ToNative());
#endif
        }
Пример #6
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.";
        }
Пример #7
0
        public static BandTheme GetTileTheme()
        {
            var theme = new BandTheme();

            theme.Base          = new BandColor(51, 102, 204);
            theme.HighContrast  = new BandColor(58, 120, 221);
            theme.Highlight     = new BandColor(58, 120, 221);
            theme.Lowlight      = new BandColor(49, 101, 186);
            theme.Muted         = new BandColor(43, 90, 165);
            theme.SecondaryText = new BandColor(137, 151, 171);
            return(theme);
        }
Пример #8
0
 /// <summary>
 /// テーマカラーの変換
 /// </summary>
 /// <param name="color">共通テーマカラー情報</param>
 /// <returns>ネイティブテーマカラー情報</returns>
 public static Native.Tiles.BandTheme ToNative(BandTheme theme)
 {
     return(new Native.Tiles.BandTheme
     {
         BaseColor = ToNative(theme.Base),
         HighContrastColor = ToNative(theme.HighContrast),
         HighlightColor = ToNative(theme.Highlight),
         LowlightColor = ToNative(theme.Lowlight),
         MutedColor = ToNative(theme.Muted),
         SecondaryTextColor = ToNative(theme.SecondaryText),
     });
 }
Пример #9
0
        public static async Task <BandTheme> DemoTheme()
        {
            BandTheme bandtheme = new BandTheme();

            bandtheme.Base          = Color.FromArgb(255, 0, 184, 241).ToBandColor();
            bandtheme.HighContrast  = Color.FromArgb(255, 0, 188, 227).ToBandColor();
            bandtheme.Highlight     = Color.FromArgb(255, 0, 199, 239).ToBandColor();
            bandtheme.Lowlight      = Color.FromArgb(255, 91, 194, 231).ToBandColor();
            bandtheme.Muted         = Color.FromArgb(255, 98, 142, 156).ToBandColor();
            bandtheme.SecondaryText = Color.FromArgb(255, 0, 137, 182).ToBandColor();
            return(bandtheme);
        }
Пример #10
0
 /// <summary>
 /// テーマカラーの変換
 /// </summary>
 /// <param name="color">共通テーマカラー情報</param>
 /// <returns>ネイティブテーマカラー情報</returns>
 public static Native.Personalization.BandTheme ToNative(BandTheme theme)
 {
     return(new Native.Personalization.BandTheme
     {
         Base = ToNative(theme.Base),
         HighContrast = ToNative(theme.HighContrast),
         Highlight = ToNative(theme.Highlight),
         Lowlight = ToNative(theme.Lowlight),
         Muted = ToNative(theme.Muted),
         SecondaryText = ToNative(theme.SecondaryText),
     });
 }
        public async void Update_ColorOnPreview(int index, BandTheme _BandTheme)
        {
            switch (index)
            {
            case -1:
                try
                {
                    while (await ContentIsLoaded() == false)
                    {
                        await Task.Delay(100);

                        System.Diagnostics.Debug.WriteLine("Task Delayed");
                    }


                    Base.Set_Color(_BandTheme);
                    HighContrast.Set_Color(_BandTheme);
                    LowLight.Set_Color(_BandTheme);
                    Hightlight.Set_Color(_BandTheme);
                    Muted.Set_Color(_BandTheme);
                    Secondary.Set_Color(_BandTheme);
                } catch (Exception e)
                {
                    System.Diagnostics.Debug.Write(e);
                }

                break;

            case 0:
                Base.Set_Color(_BandTheme);
                break;

            case 1:
                HighContrast.Set_Color(_BandTheme);
                break;

            case 2:
                LowLight.Set_Color(_BandTheme);
                break;

            case 3:
                Hightlight.Set_Color(_BandTheme);
                break;

            case 4:
                Muted.Set_Color(_BandTheme);
                break;

            case 5:
                Secondary.Set_Color(_BandTheme);
                break;
            }
        }
        private async void OnGetThemeClick(object sender, EventArgs e)
        {
            try
            {
                BandTheme theme = await Model.Instance.Client.PersonalizationManager.GetThemeTaskAsync();

                mViewTheme.Theme = theme;
                RefreshControls();
            }
            catch (Exception ex)
            {
                Util.ShowExceptionAlert(Activity, "Get theme", ex);
            }
        }
        public async Task <BandTheme> Generate_BandTheme()
        {
            BandTheme theme = new BandTheme()
            {
                Base          = _Base.ToBandColor(),
                HighContrast  = _HighContrast.ToBandColor(),
                Highlight     = _Highlight.ToBandColor(),
                Lowlight      = _Lowlight.ToBandColor(),
                Muted         = _Muted.ToBandColor(),
                SecondaryText = _Secondary.ToBandColor()
            };

            return(theme);
        }
Пример #14
0
        public static async Task Set_Theme(BandTheme theme)
        {
            BandClient = await Connect_Band(await Get_Band());

            if (BandClient == null)
            {
                return;
            }

            using (BandClient)
            {
                await BandClient.PersonalizationManager.SetThemeAsync(theme);
            }
        }
Пример #15
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));
 }
Пример #16
0
        /// <summary>
        /// Returns the theme from Microsoft Band
        /// </summary>
        /// <returns></returns>
        public static async Task <BandTheme> Get_Theme()
        {
            BandClient = await Connect_Band(await Get_Band());

            if (BandClient == null)
            {
                return(new BandTheme());
            }

            using (BandClient)
            {
                BandTheme bandTheme = await BandClient.PersonalizationManager.GetThemeAsync();

                return(bandTheme);
            }
        }
        protected override async void OnNavigatedTo(NavigationEventArgs e)
        {
            base.OnNavigatedTo(e);

            if (SingleBinding.ResetThemePage)
            {
                SingleBinding.ResetThemePage = false;
                App.HexWatcher.Color         = string.Empty;
                if (App._SelectedBandTheme == -1 && App._CustomBandThemes.Count == 0)
                {
                    this.Frame.GoBack(); return;
                }
                _Theme = App._CustomBandThemes[App._SelectedBandTheme].Theme;
                await Load_Theme(_Theme);
            }

            UpdateHex();
        }
Пример #18
0
        public override bool Equals(object obj)
        {
            if (!(obj is BandTheme))
            {
                return(this.Equals(obj));
            }

            BandTheme theme1 = this;
            BandTheme theme2 = (BandTheme)obj;

            return
                (theme1.Base == theme2.Base &&
                 theme1.HighContrast == theme2.HighContrast &&
                 theme1.Highlight == theme2.Highlight &&
                 theme1.Lowlight == theme2.Lowlight &&
                 theme1.Muted == theme2.Muted &&
                 theme1.SecondaryText == theme2.SecondaryText);
        }
Пример #19
0
        /// <summary>
        /// 設定適用
        /// </summary>
        /// <returns>Task</returns>
        private async Task Apply()
        {
            this.IsBusy = true;
            var theme = new BandTheme()
            {
                Base          = StringToColor(this.BaseColor.Color),
                HighContrast  = StringToColor(this.HighContrastColor.Color),
                Highlight     = StringToColor(this.HighlightColor.Color),
                Lowlight      = StringToColor(this.LowlightColor.Color),
                Muted         = StringToColor(this.MutedColor.Color),
                SecondaryText = StringToColor(this.SecondaryTextColor.Color),
            };

            await this.manager.SetThemeAsync(theme);

            var source = this.meTileImageSource as StreamImageSource;

            if (source != null)
            {
                await this.manager.SetMeTileImageSourceAsync(source);
            }

            this.IsBusy = false;
        }
        /// <summary>
        /// アプリタイルを生成する
        /// </summary>
        /// <param name="id">ID</param>
        /// <param name="name">名称</param>
        /// <param name="icon">アイコンの画像ソース(46 x 46 px)</param>
        /// <param name="smallIcon">小さいアイコンの画像ソース(24 x 24 px)</param>
        /// <param name="theme">テーマカラー</param>
        /// <returns>アプリタイル</returns>
        public async Task <IBandTile> CreateTile(Guid id, string name, StreamImageSource icon, StreamImageSource smallIcon, BandTheme theme = null)
        {
            var nativeIcon = await NativeBandImageConvert.ToNativeIcon(icon);

            var nativeSmallIcon = await NativeBandImageConvert.ToNativeIcon(smallIcon);

            var tile = new NativeBandTile(id, name, nativeIcon, nativeSmallIcon);

            tile.Theme = theme;

            return(tile);
        }
Пример #21
0
 public async void Set_Color(BandTheme theme)
 {
     root.Background  = new SolidColorBrush(theme.SecondaryText.ToColor());
     Muted.Background = new SolidColorBrush(theme.Muted.ToColor());
 }
Пример #22
0
        public AddTileViewModel(BandDeviceInfo info, BandClient bandClient)
            : base(info, bandClient)
        {
            tileManager = bandClient.TileManager;
            tileTheme = App.DefaultTheme;
            tileId = Guid.NewGuid();
            tileName = "New Tile";

            GenerateTileIdCommand = new Command(() =>
            {
                TileId = Guid.NewGuid().ToString("D");
            });

            DefaultTileIconCommand = new Command(async () =>
            {
                TileIcon = await App.LoadImageResourceAsync("Resources/tile.png");
            });
            SelectTileIconCommand = new Command(async () =>
            {
                var photo = await CrossMedia.Current.PickPhotoAsync();
                if (photo != null)
                {
                    TileIcon = await BandImage.FromStreamAsync(photo.GetStream());
                }
            }, () => CrossMedia.Current.IsPickPhotoSupported);

            DefaultTileBadgeCommand = new Command(async () =>
            {
                TileBadge = await App.LoadImageResourceAsync("Resources/badge.png");
            });
            SelectTileBadgeCommand = new Command(async () =>
            {
                var photo = await CrossMedia.Current.PickPhotoAsync();
                if (photo != null)
                {
                    TileBadge = await BandImage.FromStreamAsync(photo.GetStream());
                }
            }, () => CrossMedia.Current.IsPickPhotoSupported);

            DefaultThemeCommand = new Command(() => 
            {
                TileTheme = App.DefaultTheme;
            });

            AddTileCommand = new Command(async () =>
            {
                var tile = new BandTile(tileId)
                {
                    Icon = TileIcon,
                    Name = TileName,
                    SmallIcon = TileBadge,
                    IsScreenTimeoutDisabled = DisableScreenTimeout
                };
                if (UseCustomTheme)
                {
                    tile.Theme = TileTheme;
                }
                tile.PageImages.AddRange(new[]
                {
                    await App.LoadImageResourceAsync("Resources/star.png")
                });
                var layouts = CreatePageLayouts();
                tile.PageLayouts.AddRange(layouts);
                await tileManager.AddTileAsync(tile);
                var datas = CreatePageDatas();
                await tileManager.SetTilePageDataAsync(tile.Id, datas);
            });
            RemoveTileCommand = new Command(async () =>
            {
                await tileManager.RemoveTileAsync(tileId);
            });
        }
 /// <summary>
 /// テーマカラーの設定
 /// </summary>
 /// <param name="theme">テーマ情報</param>
 /// <returns>Task</returns>
 public Task SetThemeAsync(BandTheme theme)
 {
     return(Native.Personalization.BandPersonalizationManagerExtensions.SetThemeTaskAsync(
                this.manager, NativeBandThemeConvert.ToNative(theme)));
 }
 public Task SetThemeAsync(BandTheme theme, CancellationToken cancel)
 {
     return(this.SetThemeAsync(theme));
 }
        public AddTileViewModel(BandDeviceInfo info, BandClient bandClient)
            : base(info, bandClient)
        {
            tileManager = bandClient.TileManager;
            tileTheme   = App.DefaultTheme;
            tileId      = Guid.NewGuid();
            tileName    = "New Tile";

            GenerateTileIdCommand = new Command(() =>
            {
                TileId = Guid.NewGuid().ToString("D");
            });

            DefaultTileIconCommand = new Command(async() =>
            {
                TileIcon = await App.LoadImageResourceAsync("Resources/tile.png");
            });
            SelectTileIconCommand = new Command(async() =>
            {
                var photo = await CrossMedia.Current.PickPhotoAsync();
                if (photo != null)
                {
                    TileIcon = await BandImage.FromStreamAsync(photo.GetStream());
                }
            }, () => CrossMedia.Current.IsPickPhotoSupported);

            DefaultTileBadgeCommand = new Command(async() =>
            {
                TileBadge = await App.LoadImageResourceAsync("Resources/badge.png");
            });
            SelectTileBadgeCommand = new Command(async() =>
            {
                var photo = await CrossMedia.Current.PickPhotoAsync();
                if (photo != null)
                {
                    TileBadge = await BandImage.FromStreamAsync(photo.GetStream());
                }
            }, () => CrossMedia.Current.IsPickPhotoSupported);

            DefaultThemeCommand = new Command(() =>
            {
                TileTheme = App.DefaultTheme;
            });

            AddTileCommand = new Command(async() =>
            {
                var tile = new BandTile(tileId)
                {
                    Icon = TileIcon,
                    Name = TileName
                };
                if (AllowBadging)
                {
                    tile.SmallIcon = TileBadge;
                }
                if (UseCustomTheme)
                {
                    tile.Theme = TileTheme;
                }
                await tileManager.AddTileAsync(tile);
            });
            RemoveTileCommand = new Command(async() =>
            {
                await tileManager.RemoveTileAsync(tileId);
            });
        }
        internal async void Initialize()
        {
            var bandManager = BandClientManager.Instance;
            var pairedBands = await bandManager.GetBandsAsync();

            try
            {
                if (pairedBands.Length < 1)
                {
                    info.Text = "Could not connect";
                    return;
                }

                bandClient = await bandManager.ConnectAsync(pairedBands[0]);

                info.Text = "Connected to Band";
                lastMove  = DateTime.Now;

                // Create a Tile with a TextButton on it.
                BandTile myTile = new BandTile(myTileId)
                {
                    Name      = "My Teletouch",
                    TileIcon  = await LoadIcon("ms-appx:///Assets/BandTileIconLarge.png"),
                    SmallIcon = await LoadIcon("ms-appx:///Assets/BandTileIconSmall.png")
                };
                myTile.AdditionalIcons.Add(await LoadIcon("ms-appx:///Assets/left.png"));
                myTile.AdditionalIcons.Add(await LoadIcon("ms-appx:///Assets/center.png"));
                myTile.AdditionalIcons.Add(await LoadIcon("ms-appx:///Assets/right.png"));
                myTile.AdditionalIcons.Add(await LoadIcon("ms-appx:///Assets/switch.png"));
                myTile.AdditionalIcons.Add(await LoadIcon("ms-appx:///Assets/switch1.png"));
                myTile.AdditionalIcons.Add(await LoadIcon("ms-appx:///Assets/switch2.png"));

                // get the current theme from the Band
                BandTheme theme = await bandClient.PersonalizationManager.GetThemeAsync();

                BandColor colorButton        = theme.Base;
                BandColor colorButtonPressed = new BandColor(0xFF, 0xFF, 0xFF);
                PageRect  rect1 = new PageRect(5, 0, 60, 110);
                PageRect  rect2 = new PageRect(70, 0, 60, 110);
                PageRect  rect3 = new PageRect(135, 0, 60, 110);
                PageRect  rect4 = new PageRect(200, 0, 40, 35);
                PageRect  rect5 = new PageRect(200, 37, 40, 35);
                PageRect  rect6 = new PageRect(200, 75, 40, 35);

                FilledButton buttonLeft = new FilledButton()
                {
                    ElementId = 1, Rect = rect1, BackgroundColor = colorButton
                };
                FilledButton buttonCenter = new FilledButton()
                {
                    ElementId = 2, Rect = rect2, BackgroundColor = colorButton
                };
                FilledButton buttonRight = new FilledButton()
                {
                    ElementId = 3, Rect = rect3, BackgroundColor = colorButton
                };
                FilledButton buttonSwitch = new FilledButton()
                {
                    ElementId = 4, Rect = rect4, BackgroundColor = colorButton
                };
                FilledButton buttonLock = new FilledButton()
                {
                    ElementId = 5, Rect = rect5, BackgroundColor = colorButton
                };
                FilledButton buttonOnOff = new FilledButton()
                {
                    ElementId = 6, Rect = rect6, BackgroundColor = colorButton
                };
                Icon iconLeft = new Icon()
                {
                    ElementId = 7, Rect = rect1, Color = colorButtonPressed, HorizontalAlignment = Microsoft.Band.Tiles.Pages.HorizontalAlignment.Center, VerticalAlignment = Microsoft.Band.Tiles.Pages.VerticalAlignment.Center
                };
                Icon iconCenter = new Icon()
                {
                    ElementId = 8, Rect = rect2, Color = colorButtonPressed, HorizontalAlignment = Microsoft.Band.Tiles.Pages.HorizontalAlignment.Center, VerticalAlignment = Microsoft.Band.Tiles.Pages.VerticalAlignment.Center
                };
                Icon iconRight = new Icon()
                {
                    ElementId = 9, Rect = rect3, Color = colorButtonPressed, HorizontalAlignment = Microsoft.Band.Tiles.Pages.HorizontalAlignment.Center, VerticalAlignment = Microsoft.Band.Tiles.Pages.VerticalAlignment.Center
                };
                Icon iconSwitch = new Icon()
                {
                    ElementId = 10, Rect = rect4, Color = colorButtonPressed, HorizontalAlignment = Microsoft.Band.Tiles.Pages.HorizontalAlignment.Center, VerticalAlignment = Microsoft.Band.Tiles.Pages.VerticalAlignment.Center
                };
                Icon iconLock = new Icon()
                {
                    ElementId = 11, Rect = rect5, Color = colorButtonPressed, HorizontalAlignment = Microsoft.Band.Tiles.Pages.HorizontalAlignment.Center, VerticalAlignment = Microsoft.Band.Tiles.Pages.VerticalAlignment.Center
                };
                Icon iconOnOff = new Icon()
                {
                    ElementId = 12, Rect = rect6, Color = colorButtonPressed, HorizontalAlignment = Microsoft.Band.Tiles.Pages.HorizontalAlignment.Center, VerticalAlignment = Microsoft.Band.Tiles.Pages.VerticalAlignment.Center
                };

                FilledPanel panel = new FilledPanel(iconLeft, iconCenter, iconRight, iconSwitch, iconLock, iconOnOff,
                                                    buttonLeft, buttonCenter, buttonRight, buttonSwitch, buttonLock, buttonOnOff)
                {
                    Rect = new PageRect(0, 0, 240, 110),
                    HorizontalAlignment = Microsoft.Band.Tiles.Pages.HorizontalAlignment.Center
                };
                myTile.PageLayouts.Add(new PageLayout(panel));

                // Remove the Tile from the Band, if present. An application won't need to do this everytime it runs.
                // But in case you modify this sample code and run it again, let's make sure to start fresh.
                //await bandClient.TileManager.RemoveTileAsync(myTileId);

                // Create the Tile on the Band.
                await bandClient.TileManager.AddTileAsync(myTile);

                await bandClient.TileManager.SetPagesAsync(myTileId, new PageData(pageId, 0,
                                                                                  new FilledButtonData(1, colorButtonPressed),
                                                                                  new FilledButtonData(2, colorButtonPressed),
                                                                                  new FilledButtonData(3, colorButtonPressed),
                                                                                  new FilledButtonData(4, colorButtonPressed),
                                                                                  new FilledButtonData(5, colorButtonPressed),
                                                                                  new FilledButtonData(6, colorButtonPressed),
                                                                                  new IconData(7, 2),
                                                                                  new IconData(8, 3),
                                                                                  new IconData(9, 4),
                                                                                  new IconData(10, 5),
                                                                                  new IconData(11, 6),
                                                                                  new IconData(12, 7)));

                // Subscribe to events
                bandClient.TileManager.TileOpened                 += EventHandler_TileOpened;
                bandClient.TileManager.TileClosed                 += EventHandler_TileClosed;
                bandClient.TileManager.TileButtonPressed          += EventHandler_TileButtonPressed;
                bandClient.SensorManager.Gyroscope.ReadingChanged += Gyroscope_ReadingChanged;

                // Start listening for events
                await bandClient.TileManager.StartReadingsAsync();
            }
            catch (BandException bandException)
            {
                Debug.WriteLine(bandException.Message);
                info.Text = "Could not connect";
            }
        }
Пример #27
0
        public static Task SetThemeTaskAsync(this IBandPersonalizationManager manager, BandTheme theme)
        {
            var tcs = new TaskCompletionSource <object> ();

            manager.SetThemeAsync(theme, tcs.AttachCompletionHandler());
            return(tcs.Task);
        }
Пример #28
0
        private async Task ConnectDevice()
        {
            if (DesktopSyncAppIsRunning())
                return;

            // We support connecting to a device over USB and Bluetooth.
            // Since USB is super fast (the device is either there or not), search there first and then fallback
            // on Bluetooth, since that can take a little longer.

            var device = await GetUSBBand();

            if (device == null)
            {
                // now try Bluetooth
                device = await GetBluetoothBand();
            }

            if (device != null)
            {
                // since this will trigger binding, invoke on the UI thread
                Application.Current.Dispatcher.BeginInvoke(new Action(async () =>
                {
                    // TODO: support more than one device?
                    CargoClient = device;

                    IsConnected = true;

                    //TODO: call an "OnConnected" function

                    // Bluetooth is sensitive to multiple things going on at once across different threads
                    // so let's make sure we go about this serially

                    Properties = new BandProperties(CargoClient);
                    await Properties.InitAsync();
                    
                    Theme = new BandTheme(CargoClient);
                    await Theme.InitAsync();

                    Sensors = new BandSensors(CargoClient);
                    await Sensors.InitAsync();

                    Tiles = new BandTiles(CargoClient);
                    await Tiles.InitAsync();
                }));
            }
        }
 public async void Set_Color(BandTheme theme)
 {
     Border.BorderBrush   = new SolidColorBrush(theme.Highlight.ToColor());
     Highlight.Foreground = new SolidColorBrush(theme.Highlight.ToColor());
 }
Пример #30
0
 public static Task SetThemeTaskAsync(this IBandPersonalizationManager manager, BandTheme theme)
 {
     return(manager.SetThemeAsync(theme).AsTask());
 }
 public static Task SetThemeTaskAsync(this IBandPersonalizationManager manager, BandTheme theme)
 {
     return manager.SetThemeAsync(theme).AsTask();
 }
 /// <summary>
 /// テーマカラーの設定
 /// </summary>
 /// <param name="theme">テーマ情報</param>
 /// <returns>Task</returns>
 public Task SetThemeAsync(BandTheme theme)
 {
     return(this.manager.SetThemeAsync(theme));
 }