Esempio n. 1
0
        private async Task CreateTileCommandExecute()
        {
            try
            {
                // Create Tile
                var tile = new BandTile(TileId)
                {
                    Icon      = TileIcon,
                    Name      = TileName,
                    SmallIcon = TileBadge,
                    IsScreenTimeoutDisabled = DisableScreenTimeout
                };

                // Tile Custom Layouts
                var layouts = CreatePageLayouts();
                tile.PageLayouts.AddRange(layouts);

                // Add Tile
                await _tileManager.AddTileAsync(tile);

                // Update with page data
                var datas = CreatePageDatas();
                await _tileManager.SetTilePageDataAsync(tile.Id, datas);
            }
            catch (Exception ex)
            {
                Debug.WriteLine(ex.Message);
            }
        }
Esempio n. 2
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);
            });
        }
        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);
            });
        }