public NotificationsPage(BandDeviceInfo info, BandClient bandClient, BandTile tile) : base(info, bandClient) { InitializeComponent(); ViewModel = new NotificationsViewModel(info, bandClient, tile); }
public async Task <bool> AddTileAsync(BandTile tile) { bool result = false; #if __ANDROID__ result = await ActivityWrappedActionExtensions.WrapActionAsync(activity => { return(Native.AddTileTaskAsync(activity, tile.ToNative())); }); #elif __IOS__ try { await Native.AddTileTaskAsync(tile.ToNative()); result = true; } catch (BandException ex) { if (ex.Code == (int)BandNSErrorCodes.UserDeclinedTile) { result = false; } else { throw; } } #elif WINDOWS_PHONE_APP result = await Native.AddTileAsync(tile.ToNative()); #endif return(result); }
public override void OnAppearing(object navigationContext) { var notificationData = navigationContext as NotificationData; BandClient = notificationData.BandClient; _tile = notificationData.Tile; _notifiactionManager = BandClient.NotificationManager; base.OnAppearing(navigationContext); }
public AddTilePage(BandDeviceInfo info, BandClient bandClient, BandTile tile) : base(info, bandClient) { InitializeComponent(); addTileViewModel = new AddTileViewModel(info, bandClient, tile); Init(); ViewModel = addTileViewModel; }
public NotificationsViewModel(BandDeviceInfo info, BandClient bandClient, BandTile tile) : base(info, bandClient) { notifiactionManager = bandClient.NotificationManager; this.tile = tile; SendMessageCommand = new Command(async () => { await notifiactionManager.SendMessageAsync(tile.Id, Title, Body, DateTime.Now); }); SendMessageWithDialogCommand = new Command(async () => { await notifiactionManager.SendMessageAsync(tile.Id, Title, Body, DateTime.Now, true); }); ShowDialogCommand = new Command(async () => { await notifiactionManager.ShowDialogAsync(tile.Id, Title, Body); }); }
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, BandTile tile) : this(info, bandClient) { TileId = tile.Id.ToString("D"); TileName = tile.Name; TileIcon = tile.Icon; TileBadge = tile.SmallIcon; DisableScreenTimeout = tile.IsScreenTimeoutDisabled; if (tile.Theme != BandTheme.Empty) { UseCustomTheme = true; TileTheme = tile.Theme; } else { TileTheme = App.DefaultTheme; } }
public static BandTile FromNative(this NativeBandTile tile) { #if __ANDROID__ var bandTile = new BandTile(tile.TileId.FromNative()) { Name = tile.TileName, Icon = BandImage.FromBitmap(tile.TileIcon.Icon) }; if (tile.PageIcons != null) { bandTile.PageImages.AddRange(tile.PageIcons.Select(pi => BandImage.FromBitmap(pi.Icon))); } if (tile.PageLayouts != null) { bandTile.PageLayouts.AddRange(tile.PageLayouts.Select(pl => new PageLayout(pl))); } if (tile.TileSmallIcon != null) { bandTile.SmallIcon = BandImage.FromBitmap(tile.TileSmallIcon.Icon); } if (tile.Theme != null) { bandTile.Theme = tile.Theme.FromNative(); } return bandTile; #elif __IOS__ var bandTile = new BandTile(tile.TileId.FromNative()) { Name = tile.Name, Icon = BandImage.FromUIImage(tile.TileIcon.UIImage) }; if (tile.PageIcons != null) { bandTile.PageImages.AddRange(tile.PageIcons.Select(pi => BandImage.FromUIImage(pi.UIImage))); } if (tile.PageLayouts != null) { bandTile.PageLayouts.AddRange(tile.PageLayouts.Select(pl => new PageLayout(pl))); } if (tile.SmallIcon != null) { bandTile.SmallIcon = BandImage.FromUIImage(tile.SmallIcon.UIImage); } if (tile.Theme != null) { bandTile.Theme = tile.Theme.FromNative(); } return bandTile; #elif WINDOWS_PHONE_APP var bandTile = new BandTile(tile.TileId.FromNative()) { Name = tile.Name, Icon = BandImage.FromWriteableBitmap(tile.TileIcon.ToWriteableBitmap()) }; if (tile.AdditionalIcons != null) { bandTile.PageImages.AddRange(tile.AdditionalIcons.Select(pi => BandImage.FromWriteableBitmap(pi.ToWriteableBitmap()))); } if (tile.PageLayouts != null) { bandTile.PageLayouts.AddRange(tile.PageLayouts.Select(pl => new PageLayout(pl))); } if (tile.SmallIcon != null) { bandTile.SmallIcon = BandImage.FromWriteableBitmap(tile.SmallIcon.ToWriteableBitmap()); } if (tile.Theme != null) { bandTile.Theme = tile.Theme.FromNative(); } return bandTile; #endif }
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); } }
public TileViewModel(BandTile tile, BandTileManager tiles) { tileManager = tiles; Tile = tile; }
async void AddTileButton_Click (object sender, EventArgs e) { if (0 == String.Compare(addTileButton.Text, AddTileString)) { // add tile try { BitmapFactory.Options options = new BitmapFactory.Options(); options.InScaled = false; var tile = new BandTile(tileId) { Icon = BandImage.FromBitmap(BitmapFactory.DecodeResource(Resources, Resource.Raw.tile, options)), Name = "Altitude", SmallIcon = BandImage.FromBitmap(BitmapFactory.DecodeResource(Resources, Resource.Raw.badge, options)), IsScreenTimeoutDisabled = true }; // define the page layout var pageLayout = new PageLayout { Root = new FlowPanel { Orientation = FlowPanelOrientation.Vertical, Rect = new PageRect(0, 0, 258, 128), } }; // Page1 line1 var line1 = new FlowPanel { Orientation = FlowPanelOrientation.Horizontal, Rect = new PageRect(0, 0, 258, 30), Elements = { new TextBlock { ElementId = 1, Rect = new PageRect(0, 0, 258, 30), Margins = new Margins(15,0,0,0), VerticalAlignment = VerticalAlignment.Bottom, Font = TextBlockFont.Small, ColorSource = ElementColorSource.BandHighlight, }, new TextBlock { ElementId = 2, Rect = new PageRect(0, 0, 258, 30), Margins = new Margins(10,0,0,0), VerticalAlignment = VerticalAlignment.Bottom, Font = TextBlockFont.Small } } }; // Page1 Line2 var line2 = new FlowPanel { Orientation = FlowPanelOrientation.Horizontal, Rect = new PageRect(0,38,280,90), Elements = { new Icon { ElementId = 10, Rect = new PageRect(0,0,24,24), Margins = new Margins(15,35,0,0), VerticalAlignment = VerticalAlignment.Top, ColorSource = ElementColorSource.BandBase }, new Icon { ElementId = 11, Rect = new PageRect(0,0,24,24), Margins = new Margins(-24,35,0,0), VerticalAlignment = VerticalAlignment.Top, Color = new BandColor(0xff,0,0) //red }, new Icon { ElementId = 12, Rect = new PageRect(0,0,24,24), Margins = new Margins(-24,35,0,0), VerticalAlignment = VerticalAlignment.Bottom, Color = new BandColor(0xff,0xff,0) //yellow }, new Icon { ElementId = 13, Rect = new PageRect(0,0,24,24), Margins = new Margins(-24,35,0,0), VerticalAlignment = VerticalAlignment.Bottom, Color = new BandColor(0,0xff,0) //green }, new TextBlock { ElementId = 5, Rect = new PageRect(0, 0, 228, 90), Margins = new Margins(10,0,0,15), VerticalAlignment = VerticalAlignment.Bottom, Font = TextBlockFont.ExtraLargeNumbersBold } } }; pageLayout.Root.Elements.Add(line1); pageLayout.Root.Elements.Add(line2); // add the page layout to the tile tile.PageLayouts.Add(pageLayout); // add the tile to the Band await Model.Instance.Client.TileManager.AddTileAsync(tile); addTileButton.Text = RemoveTileString; } catch (Exception ex) { Util.ShowExceptionAlert(this, "Add Tile", ex); } } else { // remove tile try { await Model.Instance.Client.TileManager.RemoveTileAsync(tileId); addTileButton.Text = AddTileString; } catch (Exception ex) { Util.ShowExceptionAlert(this, "Remove Tile", ex); } } }