Пример #1
0
        public static NativeBandTile ToNative(this BandTile tile)
        {
#if __ANDROID__
            var icon = NativeBandIcon.ToBandIcon(tile.Icon.ToBitmap());
            using (var builder = new NativeBandTile.Builder(tile.Id.ToNative(), tile.Name, icon))
            {
                if (tile.IsCustomThemeEnabled)
                {
                    builder.SetTheme(tile.Theme.ToNative());
                }
                if (tile.IsBadgingEnabled)
                {
                    icon = NativeBandIcon.ToBandIcon(tile.SmallIcon.ToBitmap());
                    builder.SetTileSmallIcon(icon);
                }
                return(builder.Build());
            }
#elif __IOS__
            // TODO: iOS - SmallIcon may not be optional
            Foundation.NSError error;
            var icon      = NativeBandIcon.FromUIImage(tile.Icon.ToUIImage(), out error);
            var smallIcon = tile.IsBadgingEnabled ? NativeBandIcon.FromUIImage(tile.SmallIcon.ToUIImage(), out error) : null;
            var bandTile  = NativeBandTile.Create(tile.Id.ToNative(), tile.Name, icon, smallIcon, out error);
            bandTile.BadgingEnabled = tile.IsBadgingEnabled;
            if (tile.IsCustomThemeEnabled)
            {
                bandTile.Theme = tile.Theme.ToNative();
            }
            return(bandTile);
#elif WINDOWS_PHONE_APP
            var bandTile = new NativeBandTile(tile.Id.ToNative())
            {
                Name     = tile.Name,
                TileIcon = tile.Icon.ToWriteableBitmap().ToBandIcon()
            };
            if (tile.IsCustomThemeEnabled)
            {
                bandTile.Theme = tile.Theme.ToNative();
            }
            if (tile.IsBadgingEnabled)
            {
                bandTile.SmallIcon        = tile.SmallIcon.ToWriteableBitmap().ToBandIcon();
                bandTile.IsBadgingEnabled = true;
            }
            return(bandTile);
#endif
        }
Пример #2
0
        public static NativeBandTile ToNative(this BandTile tile)
        {
#if __ANDROID__
            var icon = NativeBandIcon.ToBandIcon(tile.Icon.ToBitmap());
            using (var builder = new NativeBandTile.Builder(tile.Id.ToNative(), tile.Name, icon))
            {
                var smallIcon = NativeBandIcon.ToBandIcon(tile.SmallIcon.ToBitmap());
                builder.SetTileSmallIcon(smallIcon);
                var pageIcons = tile.PageImages.Select(pi => NativeBandIcon.ToBandIcon(pi.ToBitmap())).ToArray();
                builder.SetPageIcons(pageIcons);
                var pageLayouts = tile.PageLayouts.Select(pl => pl.ToNative()).ToArray();
                builder.SetPageLayouts(pageLayouts);
                if (tile.IsCustomThemeEnabled)
                {
                    builder.SetTheme(tile.Theme.ToNative());
                }
                builder.SetScreenTimeoutDisabled(tile.IsScreenTimeoutDisabled);
                return(builder.Build());
            }
#elif __IOS__
            // TODO: iOS - SmallIcon may not be optional
            Foundation.NSError error;
            var icon      = NativeBandIcon.FromUIImage(tile.Icon.ToUIImage(), out error);
            var smallIcon = NativeBandIcon.FromUIImage(tile.SmallIcon.ToUIImage(), out error);
            var bandTile  = NativeBandTile.Create(tile.Id.ToNative(), tile.Name, icon, smallIcon, out error);
            bandTile.BadgingEnabled = true;
            foreach (var image in tile.PageImages)
            {
                var pageIcon = NativeBandIcon.FromUIImage(image.ToUIImage(), out error);
                bandTile.PageIcons.Add(pageIcon);
            }
            foreach (var layout in tile.PageLayouts)
            {
                bandTile.PageLayouts.Add(layout.ToNative());
            }
            if (tile.IsCustomThemeEnabled)
            {
                bandTile.Theme = tile.Theme.ToNative();
            }
            bandTile.ScreenTimeoutDisabled = tile.IsScreenTimeoutDisabled;
            return(bandTile);
#elif WINDOWS_PHONE_APP
            var bandTile = new NativeBandTile(tile.Id.ToNative())
            {
                Name             = tile.Name,
                TileIcon         = tile.Icon.ToWriteableBitmap().ToBandIcon(),
                SmallIcon        = tile.SmallIcon.ToWriteableBitmap().ToBandIcon(),
                IsBadgingEnabled = true
            };
            foreach (var icon in tile.PageImages)
            {
                bandTile.AdditionalIcons.Add(icon.ToWriteableBitmap().ToBandIcon());
            }
            foreach (var layout in tile.PageLayouts)
            {
                bandTile.PageLayouts.Add(layout.ToNative());
            }
            if (tile.IsCustomThemeEnabled)
            {
                bandTile.Theme = tile.Theme.ToNative();
            }
            bandTile.IsScreenTimeoutDisabled = tile.IsScreenTimeoutDisabled;
            return(bandTile);
#endif
        }
        public static NativeBandTile ToNative(this BandTile tile)
        {
#if __ANDROID__
            var icon = NativeBandIcon.ToBandIcon(tile.Icon.ToBitmap());
            using (var builder = new NativeBandTile.Builder(tile.Id.ToNative(), tile.Name, icon))
            {
                var smallIcon = NativeBandIcon.ToBandIcon(tile.SmallIcon.ToBitmap());
                builder.SetTileSmallIcon(smallIcon);
                var pageIcons = tile.PageImages.Select(pi => NativeBandIcon.ToBandIcon(pi.ToBitmap())).ToArray();
                builder.SetPageIcons(pageIcons);
                var pageLayouts = tile.PageLayouts.Select(pl => pl.ToNative()).ToArray();
                builder.SetPageLayouts(pageLayouts);
                if (tile.IsCustomThemeEnabled)
                {
                    builder.SetTheme(tile.Theme.ToNative());
                }
                return builder.Build();
            }
#elif __IOS__
            // TODO: iOS - SmallIcon may not be optional
            Foundation.NSError error;
            var icon = NativeBandIcon.FromUIImage(tile.Icon.ToUIImage(), out error);
            var smallIcon = NativeBandIcon.FromUIImage(tile.SmallIcon.ToUIImage(), out error);
            var bandTile = NativeBandTile.Create(tile.Id.ToNative(), tile.Name, icon, smallIcon, out error);
            bandTile.BadgingEnabled = true;
            foreach (var image in tile.PageImages)
            {
                var pageIcon = NativeBandIcon.FromUIImage(image.ToUIImage(), out error);
                bandTile.PageIcons.Add(pageIcon);
            }
            foreach (var layout in tile.PageLayouts)
            {
                bandTile.PageLayouts.Add(layout.ToNative());
            }
            if (tile.IsCustomThemeEnabled)
            {
                bandTile.Theme = tile.Theme.ToNative();
            }
            return bandTile;
#elif WINDOWS_PHONE_APP
            var bandTile = new NativeBandTile(tile.Id.ToNative())
            {
                Name = tile.Name,
                TileIcon = tile.Icon.ToWriteableBitmap().ToBandIcon(),
                SmallIcon = tile.SmallIcon.ToWriteableBitmap().ToBandIcon(),
                IsBadgingEnabled = true
            };
            foreach (var icon in tile.PageImages)
            {
                bandTile.AdditionalIcons.Add(icon.ToWriteableBitmap().ToBandIcon());
            }
            foreach (var layout in tile.PageLayouts)
            {
                bandTile.PageLayouts.Add(layout.ToNative());
            }
            if (tile.IsCustomThemeEnabled)
            {
                bandTile.Theme = tile.Theme.ToNative();
            }
            return bandTile;
#endif
        }