コード例 #1
0
        public BudgetOverviewTileLayout()
        {
            LoadIconMethod  = LoadIcon;
            AdjustUriMethod = (uri) => uri;

            panel                     = new FlowPanel();
            panel.Orientation         = FlowPanelOrientation.Vertical;
            panel.Rect                = new PageRect(0, 0, 258, 128);
            panel.ElementId           = 1;
            panel.Margins             = new Margins(0, 0, 0, 0);
            panel.HorizontalAlignment = HorizontalAlignment.Left;
            panel.VerticalAlignment   = VerticalAlignment.Top;

            textBlock                     = new TextBlock();
            textBlock.Font                = TextBlockFont.Small;
            textBlock.Baseline            = 0;
            textBlock.BaselineAlignment   = TextBlockBaselineAlignment.Automatic;
            textBlock.AutoWidth           = true;
            textBlock.ColorSource         = ElementColorSource.BandBase;
            textBlock.Rect                = new PageRect(0, 0, 32, 32);
            textBlock.ElementId           = 2;
            textBlock.Margins             = new Margins(12, 8, 0, 0);
            textBlock.HorizontalAlignment = HorizontalAlignment.Left;
            textBlock.VerticalAlignment   = VerticalAlignment.Top;

            panel.Elements.Add(textBlock);
            pageLayout = new PageLayout(panel);

            PageElementData[] pageElementDataArray = new PageElementData[1];
            pageElementDataArray[0] = textBlockData;

            pageLayoutData = new PageLayoutData(pageElementDataArray);
        }
コード例 #2
0
        public BarcodeLayout()
        {
            LoadIconMethod  = LoadIcon;
            AdjustUriMethod = (uri) => uri;

            panel                     = new FlowPanel();
            panel.Orientation         = FlowPanelOrientation.Vertical;
            panel.Rect                = new PageRect(0, 0, 248, 128);
            panel.ElementId           = 1;
            panel.Margins             = new Margins(0, 0, 0, 0);
            panel.HorizontalAlignment = HorizontalAlignment.Left;
            panel.VerticalAlignment   = VerticalAlignment.Top;
            panel.Visible             = true;

            ScanCode                     = new Barcode(BarcodeType.Code39);
            ScanCode.Rect                = new PageRect(0, 0, 248, 128);
            ScanCode.ElementId           = 2;
            ScanCode.Margins             = new Margins(0, 0, 0, 0);
            ScanCode.HorizontalAlignment = HorizontalAlignment.Left;
            ScanCode.VerticalAlignment   = VerticalAlignment.Top;
            ScanCode.Visible             = true;

            panel.Elements.Add(ScanCode);
            pageLayout = new PageLayout(panel);

            PageElementData[] pageElementDataArray = new PageElementData[1];
            pageElementDataArray[0] = ScanCodeData;

            pageLayoutData = new PageLayoutData(pageElementDataArray);
        }
コード例 #3
0
        public TransactionConfirmTileLayout()
        {
            LoadIconMethod  = LoadIcon;
            AdjustUriMethod = (uri) => uri;

            panel                     = new FlowPanel();
            panel.Orientation         = FlowPanelOrientation.Vertical;
            panel.Rect                = new PageRect(0, 0, 258, 128);
            panel.ElementId           = 1;
            panel.Margins             = new Margins(0, 0, 0, 0);
            panel.HorizontalAlignment = HorizontalAlignment.Left;
            panel.VerticalAlignment   = VerticalAlignment.Top;

            textBlock                     = new TextBlock();
            textBlock.Font                = TextBlockFont.Small;
            textBlock.Baseline            = 0;
            textBlock.BaselineAlignment   = TextBlockBaselineAlignment.Automatic;
            textBlock.AutoWidth           = true;
            textBlock.ColorSource         = ElementColorSource.BandBase;
            textBlock.Rect                = new PageRect(0, 0, 32, 32);
            textBlock.ElementId           = 2;
            textBlock.Margins             = new Margins(12, 8, 0, 0);
            textBlock.HorizontalAlignment = HorizontalAlignment.Left;
            textBlock.VerticalAlignment   = VerticalAlignment.Top;

            panel.Elements.Add(textBlock);

            wrappedTextBlock                     = new WrappedTextBlock();
            wrappedTextBlock.Font                = WrappedTextBlockFont.Small;
            wrappedTextBlock.AutoHeight          = true;
            wrappedTextBlock.ColorSource         = ElementColorSource.Custom;
            wrappedTextBlock.Color               = new BandColor(255, 255, 255);
            wrappedTextBlock.Rect                = new PageRect(0, 0, 246, 32);
            wrappedTextBlock.ElementId           = 3;
            wrappedTextBlock.Margins             = new Margins(12, 8, 0, 0);
            wrappedTextBlock.HorizontalAlignment = HorizontalAlignment.Left;
            wrappedTextBlock.VerticalAlignment   = VerticalAlignment.Top;

            panel.Elements.Add(wrappedTextBlock);
            pageLayout = new PageLayout(panel);

            PageElementData[] pageElementDataArray = new PageElementData[2];
            pageElementDataArray[0] = textBlockData;
            pageElementDataArray[1] = wrappedTextBlockData;

            pageLayoutData = new PageLayoutData(pageElementDataArray);
        }
コード例 #4
0
            public static PageElementData Clone(PageElementData src)
            {
                var textD = src as TextBlockData;

                if (textD != null)
                {
                    return(new TextBlockData(textD.ElementId, textD.Text));
                }

                var buttonD = src as TextButtonData;

                if (buttonD != null)
                {
                    return(new TextButtonData(buttonD.ElementId, buttonD.Text));
                }

                var wrappedD = src as WrappedTextBlockData;

                if (wrappedD != null)
                {
                    return(new WrappedTextBlockData(wrappedD.ElementId, wrappedD.Text));
                }

                var iconD = src as IconData;

                if (iconD != null)
                {
                    return(new IconData(iconD.ElementId, iconD.IconIndex));
                }

                var filledButtonD = src as FilledButtonData;

                if (filledButtonD != null)
                {
                    return(new FilledButtonData(filledButtonD.ElementId, filledButtonD.PressedColor));
                }

                var barCodeD = src as BarcodeData;

                if (barCodeD != null)
                {
                    return(new BarcodeData(barCodeD.BarcodeType, barCodeD.ElementId, barCodeD.Barcode));
                }

                throw new NotImplementedException("Unrecognized type of PageElementData");
            }
コード例 #5
0
        public GarageControlsLayout()
        {
            LoadIconMethod  = LoadIcon;
            AdjustUriMethod = (uri) => uri;

            panel                     = new FlowPanel();
            panel.Orientation         = FlowPanelOrientation.Vertical;
            panel.Rect                = new PageRect(0, 0, 248, 128);
            panel.ElementId           = 1;
            panel.Margins             = new Margins(0, 0, 0, 0);
            panel.HorizontalAlignment = HorizontalAlignment.Left;
            panel.VerticalAlignment   = VerticalAlignment.Top;
            panel.Visible             = true;

            button = new TextButton();
            button.PressedColor        = new BandColor(32, 32, 32);
            button.Rect                = new PageRect(0, 0, 90, 32);
            button.ElementId           = 2;
            button.Margins             = new Margins(10, 10, 10, 10);
            button.HorizontalAlignment = HorizontalAlignment.Center;
            button.VerticalAlignment   = VerticalAlignment.Top;
            button.Visible             = true;

            panel.Elements.Add(button);

            button2 = new TextButton();
            button2.PressedColor        = new BandColor(32, 32, 32);
            button2.Rect                = new PageRect(0, 0, 90, 32);
            button2.ElementId           = 3;
            button2.Margins             = new Margins(10, 10, 10, 10);
            button2.HorizontalAlignment = HorizontalAlignment.Center;
            button2.VerticalAlignment   = VerticalAlignment.Top;
            button2.Visible             = true;

            panel.Elements.Add(button2);
            pageLayout = new PageLayout(panel);

            PageElementData[] pageElementDataArray = new PageElementData[2];
            pageElementDataArray[0] = buttonData;
            pageElementDataArray[1] = button2Data;

            pageLayoutData = new PageLayoutData(pageElementDataArray);
        }
 /// <summary>
 /// Update the page of data displayed within our tile
 /// </summary>
 private void UpdatePageData()
 {
     if (this.bandClient != null)
     {
         try
         {
             // Update the page data text with the current event log file size
             PageElementData[] pagedata = new PageElementData[]
             {
                 new TextButtonData(TileConstants.Button1ElementId, TileConstants.ButtonLabel),
                 new WrappedTextBlockData(TileConstants.TextElementId, String.Format("Log: {0} bytes", new FileInfo(LogFileName).Length))
             };
             this.bandClient.TileManager.SetPagesAsync(TileConstants.TileGuid, new PageData(TileConstants.Page1Guid, 0, pagedata)).Wait();
         }
         catch
         {
             LogEvent("ERROR - Unable to update page data");
         }
     }
 }
コード例 #7
0
            public static bool Same(PageElementData lhs, PageElementData rhs)
            {
                var textDL = lhs as TextData;

                if (textDL != null)
                {
                    var textDR = rhs as TextData;
                    return(textDR != null && textDL.ElementId == textDR.ElementId && textDL.Text == textDR.Text);
                }

                var iconDL = lhs as IconData;

                if (iconDL != null)
                {
                    var iconDR = rhs as IconData;
                    return(iconDR != null && iconDL.ElementId == iconDR.ElementId && iconDL.IconIndex == iconDR.IconIndex);
                }

                var filledButtonDL = lhs as FilledButtonData;

                if (filledButtonDL != null)
                {
                    var filledButtonDR = rhs as FilledButtonData;
                    return(filledButtonDR != null && filledButtonDL.ElementId == filledButtonDR.ElementId && ValueType.Equals(filledButtonDL.PressedColor, filledButtonDR.PressedColor));
                }

                var barCodeDL = lhs as BarcodeData;

                if (barCodeDL != null)
                {
                    var barCodeDR = rhs as BarcodeData;
                    return(barCodeDR != null && barCodeDL.BarcodeType == barCodeDR.BarcodeType && barCodeDL.ElementId == barCodeDR.ElementId && barCodeDL.Barcode == barCodeDR.Barcode);
                }

                throw new NotImplementedException("Unrecognized type of PageElementData");
            }
コード例 #8
0
		async partial void AddButtonPageClick (UIButton sender)
		{
			if (client != null && client.IsConnected) {
				Output ("Creating tile...");

				// remove an old tile
				try {
					var tiles = await client.TileManager.GetTilesTaskAsync ();
					if (tiles.Any (x => x.TileId.AsString () == tileId.AsString ())) {
						// a tile exists, so remove it
						await client.TileManager.RemoveTileTaskAsync (tileId);
						Output ("Removed tile!");
					}
				} catch (BandException ex) {
					Output ("Error: " + ex.Message);
				}

				// create the tile
				NSError operationError;
				var tileName = "iOS Sample";
				var tileIcon = BandIcon.FromUIImage (UIImage.FromBundle ("tile.png"), out operationError);
				var smallIcon = BandIcon.FromUIImage (UIImage.FromBundle ("badge.png"), out operationError);
				var tile = BandTile.Create (tileId, tileName, tileIcon, smallIcon, out operationError);
				tile.BadgingEnabled = true;

				// create the button page
				var textBlock = new TextBlock (PageRect.Create (0, 0, 200, 40), TextBlockFont.Small);
				textBlock.ElementId = 10;
				textBlock.Baseline = 25;
				textBlock.HorizontalAlignment = HorizontalAlignment.Center;
				textBlock.BaselineAlignment = TextBlockBaselineAlignment.Relative;
				textBlock.AutoWidth = false;
				textBlock.Color = BandColor.FromUIColor (UIColor.Red, out operationError);
				textBlock.Margins = Margins.Create (5, 2, 5, 2);

				var button = new TextButton (PageRect.Create (0, 0, 200, 40));
				button.ElementId = 11;
				button.HorizontalAlignment = HorizontalAlignment.Center;
				button.PressedColor = BandColor.FromUIColor (UIColor.Purple, out operationError);
				button.Margins = Margins.Create (5, 2, 5, 2);

				var flowPanel = new FlowPanel (PageRect.Create (15, 0, 260, 105));
				flowPanel.AddElement (textBlock);
				flowPanel.AddElement (button);

				var pageLayout = new PageLayout ();
				pageLayout.Root = flowPanel;
				tile.PageLayouts.Add (pageLayout);

				// add the tile to the band
				try {
					Output ("Adding tile...");
					await client.TileManager.AddTileTaskAsync (tile);
				} catch (BandException ex) {
					Output ("Error: " + ex.Message);
				}

				// set the page data
				try {
					Output ("Creating page data...");
					var pageValues = new PageElementData [] {
						TextBlockData.Create (textBlock.ElementId, "TextButton sample", out operationError),
						TextButtonData.Create (button.ElementId, "Press Me", out operationError)
					};
					var page = PageData.Create (barcodePageId, 0, pageValues);

					await client.TileManager.SetPagesTaskAsync (new[]{ page }, tileId);
					Output ("Completed custom page!");
				} catch (BandException ex) {
					Output ("Error: " + ex.Message);
				}
			} else {
				Output ("Band is not connected. Please wait....");
			}
		}
コード例 #9
0
        public TileLayout()
        {
            LoadIconMethod  = LoadIcon;
            AdjustUriMethod = (uri) => uri;

            panel = new FilledPanel();
            panel.BackgroundColorSource = ElementColorSource.Custom;
            panel.BackgroundColor       = new BandColor(0, 0, 0);
            panel.Rect                = new PageRect(0, 0, 258, 128);
            panel.ElementId           = 1;
            panel.Margins             = new Margins(0, 0, 0, 0);
            panel.HorizontalAlignment = HorizontalAlignment.Left;
            panel.VerticalAlignment   = VerticalAlignment.Top;

            textBlock                     = new TextBlock();
            textBlock.Font                = TextBlockFont.Small;
            textBlock.Baseline            = 0;
            textBlock.BaselineAlignment   = TextBlockBaselineAlignment.Automatic;
            textBlock.AutoWidth           = true;
            textBlock.ColorSource         = ElementColorSource.Custom;
            textBlock.Color               = new BandColor(255, 255, 255);
            textBlock.Rect                = new PageRect(24, 57, 32, 32);
            textBlock.ElementId           = 4;
            textBlock.Margins             = new Margins(0, 0, 0, 0);
            textBlock.HorizontalAlignment = HorizontalAlignment.Left;
            textBlock.VerticalAlignment   = VerticalAlignment.Top;

            panel.Elements.Add(textBlock);

            textBlock2                     = new TextBlock();
            textBlock2.Font                = TextBlockFont.Small;
            textBlock2.Baseline            = 0;
            textBlock2.BaselineAlignment   = TextBlockBaselineAlignment.Automatic;
            textBlock2.AutoWidth           = true;
            textBlock2.ColorSource         = ElementColorSource.Custom;
            textBlock2.Color               = new BandColor(255, 255, 255);
            textBlock2.Rect                = new PageRect(23, 30, 32, 32);
            textBlock2.ElementId           = 3;
            textBlock2.Margins             = new Margins(0, 0, 0, 0);
            textBlock2.HorizontalAlignment = HorizontalAlignment.Left;
            textBlock2.VerticalAlignment   = VerticalAlignment.Top;

            panel.Elements.Add(textBlock2);

            icon                     = new Icon();
            icon.ColorSource         = ElementColorSource.BandHighlight;
            icon.Rect                = new PageRect(193, 55, 64, 64);
            icon.ElementId           = 2;
            icon.Margins             = new Margins(0, 0, 0, 0);
            icon.HorizontalAlignment = HorizontalAlignment.Left;
            icon.VerticalAlignment   = VerticalAlignment.Top;

            panel.Elements.Add(icon);
            pageLayout = new PageLayout(panel);

            PageElementData[] pageElementDataArray = new PageElementData[3];
            pageElementDataArray[0] = textBlockData;
            pageElementDataArray[1] = textBlock2Data;
            pageElementDataArray[2] = iconData;

            pageLayoutData = new PageLayoutData(pageElementDataArray);
        }
コード例 #10
0
        async partial void AddButtonPageClick(UIButton sender)
        {
            if (client != null && client.IsConnected)
            {
                Output("Creating tile...");

                // remove an old tile
                try {
                    var tiles = await client.TileManager.GetTilesTaskAsync();

                    if (tiles.Any(x => x.TileId.AsString() == tileId.AsString()))
                    {
                        // a tile exists, so remove it
                        await client.TileManager.RemoveTileTaskAsync(tileId);

                        Output("Removed tile!");
                    }
                } catch (BandException ex) {
                    Output("Error: " + ex.Message);
                }

                // create the tile
                NSError operationError;
                var     tileName  = "iOS Sample";
                var     tileIcon  = BandIcon.FromUIImage(UIImage.FromBundle("tile.png"), out operationError);
                var     smallIcon = BandIcon.FromUIImage(UIImage.FromBundle("badge.png"), out operationError);
                var     tile      = BandTile.Create(tileId, tileName, tileIcon, smallIcon, out operationError);
                tile.BadgingEnabled = true;

                // create the button page
                var textBlock = new TextBlock(PageRect.Create(0, 0, 200, 40), TextBlockFont.Small);
                textBlock.ElementId           = 10;
                textBlock.Baseline            = 25;
                textBlock.HorizontalAlignment = HorizontalAlignment.Center;
                textBlock.BaselineAlignment   = TextBlockBaselineAlignment.Relative;
                textBlock.AutoWidth           = false;
                textBlock.Color   = BandColor.FromUIColor(UIColor.Red, out operationError);
                textBlock.Margins = Margins.Create(5, 2, 5, 2);

                var button = new TextButton(PageRect.Create(0, 0, 200, 40));
                button.ElementId           = 11;
                button.HorizontalAlignment = HorizontalAlignment.Center;
                button.PressedColor        = BandColor.FromUIColor(UIColor.Purple, out operationError);
                button.Margins             = Margins.Create(5, 2, 5, 2);

                var flowPanel = new FlowPanel(PageRect.Create(15, 0, 260, 105));
                flowPanel.AddElement(textBlock);
                flowPanel.AddElement(button);

                var pageLayout = new PageLayout();
                pageLayout.Root = flowPanel;
                tile.PageLayouts.Add(pageLayout);

                // add the tile to the band
                try {
                    Output("Adding tile...");
                    await client.TileManager.AddTileTaskAsync(tile);
                } catch (BandException ex) {
                    Output("Error: " + ex.Message);
                }

                // set the page data
                try {
                    Output("Creating page data...");
                    var pageValues = new PageElementData [] {
                        TextBlockData.Create(textBlock.ElementId, "TextButton sample", out operationError),
                        TextButtonData.Create(button.ElementId, "Press Me", out operationError)
                    };
                    var page = PageData.Create(barcodePageId, 0, pageValues);

                    await client.TileManager.SetPagesTaskAsync(new[] { page }, tileId);

                    Output("Completed custom page!");
                } catch (BandException ex) {
                    Output("Error: " + ex.Message);
                }
            }
            else
            {
                Output("Band is not connected. Please wait....");
            }
        }
コード例 #11
0
        public GarageDoorStatusLayout()
        {
            LoadIconMethod  = LoadIcon;
            AdjustUriMethod = (uri) => uri;

            GaragePage                     = new FlowPanel();
            GaragePage.Orientation         = FlowPanelOrientation.Vertical;
            GaragePage.Rect                = new PageRect(0, 0, 248, 128);
            GaragePage.ElementId           = 1;
            GaragePage.Margins             = new Margins(0, 0, 0, 0);
            GaragePage.HorizontalAlignment = HorizontalAlignment.Left;
            GaragePage.VerticalAlignment   = VerticalAlignment.Top;
            GaragePage.Visible             = true;

            Title                     = new TextBlock();
            Title.Font                = TextBlockFont.Small;
            Title.Baseline            = 0;
            Title.BaselineAlignment   = TextBlockBaselineAlignment.Automatic;
            Title.AutoWidth           = true;
            Title.ColorSource         = ElementColorSource.Custom;
            Title.Color               = new BandColor(255, 255, 255);
            Title.Rect                = new PageRect(0, 0, 32, 32);
            Title.ElementId           = 2;
            Title.Margins             = new Margins(0, 0, 0, 0);
            Title.HorizontalAlignment = HorizontalAlignment.Left;
            Title.VerticalAlignment   = VerticalAlignment.Top;
            Title.Visible             = true;

            GaragePage.Elements.Add(Title);

            OpenTime                     = new TextBlock();
            OpenTime.Font                = TextBlockFont.Small;
            OpenTime.Baseline            = 0;
            OpenTime.BaselineAlignment   = TextBlockBaselineAlignment.Automatic;
            OpenTime.AutoWidth           = true;
            OpenTime.ColorSource         = ElementColorSource.Custom;
            OpenTime.Color               = new BandColor(255, 255, 255);
            OpenTime.Rect                = new PageRect(0, 0, 32, 32);
            OpenTime.ElementId           = 3;
            OpenTime.Margins             = new Margins(0, 0, 0, 0);
            OpenTime.HorizontalAlignment = HorizontalAlignment.Left;
            OpenTime.VerticalAlignment   = VerticalAlignment.Top;
            OpenTime.Visible             = true;

            GaragePage.Elements.Add(OpenTime);

            CloseTime                     = new TextBlock();
            CloseTime.Font                = TextBlockFont.Small;
            CloseTime.Baseline            = 0;
            CloseTime.BaselineAlignment   = TextBlockBaselineAlignment.Automatic;
            CloseTime.AutoWidth           = true;
            CloseTime.ColorSource         = ElementColorSource.Custom;
            CloseTime.Color               = new BandColor(255, 255, 255);
            CloseTime.Rect                = new PageRect(0, 0, 32, 32);
            CloseTime.ElementId           = 4;
            CloseTime.Margins             = new Margins(0, 0, 0, 0);
            CloseTime.HorizontalAlignment = HorizontalAlignment.Left;
            CloseTime.VerticalAlignment   = VerticalAlignment.Top;
            CloseTime.Visible             = true;

            GaragePage.Elements.Add(CloseTime);
            pageLayout = new PageLayout(GaragePage);

            PageElementData[] pageElementDataArray = new PageElementData[3];
            pageElementDataArray[0] = TitleData;
            pageElementDataArray[1] = OpenTimeData;
            pageElementDataArray[2] = CloseTimeData;

            pageLayoutData = new PageLayoutData(pageElementDataArray);
        }
コード例 #12
0
        /// <summary>
        /// Called when the "Install Tile" button is pressed in the UI.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private async void InstallTileButton_Click(object sender, RoutedEventArgs e)
        {
            App.Current.StatusMessage = "Installing...\n";
            try
            {
                // Get the list of Microsoft Bands paired to the phone.
                IBandInfo[] pairedBands = await BandClientManager.Instance.GetBandsAsync();

                if (pairedBands.Length < 1)
                {
                    App.Current.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;
                }

                // Connect to Microsoft Band.
                using (IBandClient bandClient = await BandClientManager.Instance.ConnectAsync(pairedBands[0]))
                {
                    // Create a Tile with a TextButton and WrappedTextBlock on it.
                    BandTile myTile = new BandTile(TileConstants.TileGuid)
                    {
                        Name      = "My Tile",
                        TileIcon  = await LoadIcon("ms-appx:///Assets/SampleTileIconLarge.png"),
                        SmallIcon = await LoadIcon("ms-appx:///Assets/SampleTileIconSmall.png")
                    };
                    TextButton button = new TextButton()
                    {
                        ElementId = TileConstants.Button1ElementId, Rect = new PageRect(10, 5, 200, 30)
                    };
                    WrappedTextBlock textblock = new WrappedTextBlock()
                    {
                        ElementId = TileConstants.TextElementId, Rect = new PageRect(10, 40, 200, 88)
                    };
                    PageElement[] elements = new PageElement[] { button, textblock };
                    FilledPanel   panel    = new FilledPanel(elements)
                    {
                        Rect = new PageRect(0, 0, 220, 128)
                    };
                    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(TileConstants.TileGuid);

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

                    PageElementData[] pagedata = new PageElementData[]
                    {
                        new TextButtonData(TileConstants.Button1ElementId, TileConstants.ButtonLabel),
                        new WrappedTextBlockData(TileConstants.TextElementId, "...")
                    };
                    await bandClient.TileManager.SetPagesAsync(TileConstants.TileGuid, new PageData(TileConstants.Page1Guid, 0, pagedata));

                    // Subscribe to background tile events
                    await bandClient.SubscribeToBackgroundTileEventsAsync(TileConstants.TileGuid);

                    App.Current.StatusMessage = "Installed Tile";
                }
            }
            catch (Exception ex)
            {
                App.Current.StatusMessage = ex.ToString();
            }
        }
コード例 #13
0
ファイル: MainPage.xaml.cs プロジェクト: yaokailing/HoloInOne
        /// <summary>
        /// Called when the "Install Tile" button is pressed in the UI.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private async void InstallTileButton_Click(object sender, RoutedEventArgs e)
        {
            App.Current.StatusMessage = "Installing...\n";
            try
            {
                // Get the list of Microsoft Bands paired to the phone.
                IBandInfo[] pairedBands = await BandClientManager.Instance.GetBandsAsync();
                if (pairedBands.Length < 1)
                {
                    App.Current.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;
                }

                // Connect to Microsoft Band.
                using (IBandClient bandClient = await BandClientManager.Instance.ConnectAsync(pairedBands[0]))
                {
                    // Create a Tile with a TextButton and WrappedTextBlock on it.
                    BandTile myTile = new BandTile(TileConstants.TileGuid)
                    {
                        Name = "My Tile",
                        TileIcon = await LoadIcon("ms-appx:///Assets/SampleTileIconLarge.png"),
                        SmallIcon = await LoadIcon("ms-appx:///Assets/SampleTileIconSmall.png")
                    };
                    TextButton button = new TextButton() { ElementId = TileConstants.Button1ElementId, Rect = new PageRect(10, 5, 200, 30) };
                    WrappedTextBlock textblock = new WrappedTextBlock() { ElementId = TileConstants.TextElementId, Rect = new PageRect(10, 40, 200, 88) };
                    PageElement[] elements = new PageElement[] { button, textblock };
                    FilledPanel panel = new FilledPanel(elements) { Rect = new PageRect(0, 0, 220, 128) };
                    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(TileConstants.TileGuid);

                    // Create the Tile on the Band.
                    await bandClient.TileManager.AddTileAsync(myTile);
                    PageElementData[] pagedata = new PageElementData[] 
                    {
                        new TextButtonData(TileConstants.Button1ElementId, TileConstants.ButtonLabel),
                        new WrappedTextBlockData(TileConstants.TextElementId, "...")
                    };
                    await bandClient.TileManager.SetPagesAsync(TileConstants.TileGuid, new PageData(TileConstants.Page1Guid, 0, pagedata));

                    // Subscribe to background tile events
                    await bandClient.SubscribeToBackgroundTileEventsAsync(TileConstants.TileGuid);

                    App.Current.StatusMessage = "Installed Tile";
                }
            }
            catch (Exception ex)
            {
                App.Current.StatusMessage = ex.ToString();
            }
        }
コード例 #14
0
 /// <summary>
 /// Update the page of data displayed within our tile
 /// </summary>
 private void UpdatePageData()
 {
     if (this.bandClient != null)
     {
         try
         {
             // Update the page data text with the current event log file size
             PageElementData[] pagedata = new PageElementData[]
             {
                 new TextButtonData(TileConstants.Button1ElementId, TileConstants.ButtonLabel),
                 new WrappedTextBlockData(TileConstants.TextElementId, String.Format("Log: {0} bytes", new FileInfo(LogFileName).Length))
             };
             this.bandClient.TileManager.SetPagesAsync(TileConstants.TileGuid, new PageData(TileConstants.Page1Guid, 0, pagedata)).Wait();
         }
         catch
         {
             LogEvent("ERROR - Unable to update page data");
         }
     }
 }
コード例 #15
0
        public TransactionTileLayout()
        {
            LoadIconMethod  = LoadIcon;
            AdjustUriMethod = (uri) => uri;

            panel                     = new FlowPanel();
            panel.Orientation         = FlowPanelOrientation.Vertical;
            panel.Rect                = new PageRect(0, 0, 258, 128);
            panel.ElementId           = 1;
            panel.Margins             = new Margins(0, 0, 0, 0);
            panel.HorizontalAlignment = HorizontalAlignment.Left;
            panel.VerticalAlignment   = VerticalAlignment.Top;

            textBlock                     = new TextBlock();
            textBlock.Font                = TextBlockFont.Small;
            textBlock.Baseline            = 0;
            textBlock.BaselineAlignment   = TextBlockBaselineAlignment.Automatic;
            textBlock.AutoWidth           = true;
            textBlock.ColorSource         = ElementColorSource.BandBase;
            textBlock.Rect                = new PageRect(0, 0, 32, 32);
            textBlock.ElementId           = 2;
            textBlock.Margins             = new Margins(12, 8, 0, 0);
            textBlock.HorizontalAlignment = HorizontalAlignment.Left;
            textBlock.VerticalAlignment   = VerticalAlignment.Top;

            panel.Elements.Add(textBlock);

            AmountDecimalButton = new TextButton();
            AmountDecimalButton.PressedColor        = new BandColor(32, 32, 32);
            AmountDecimalButton.Rect                = new PageRect(0, 0, 80, 44);
            AmountDecimalButton.ElementId           = 3;
            AmountDecimalButton.Margins             = new Margins(12, 20, 0, 0);
            AmountDecimalButton.HorizontalAlignment = HorizontalAlignment.Right;
            AmountDecimalButton.VerticalAlignment   = VerticalAlignment.Top;

            panel.Elements.Add(AmountDecimalButton);

            icon                     = new Icon();
            icon.ColorSource         = ElementColorSource.Custom;
            icon.Color               = new BandColor(255, 21, 28);
            icon.Rect                = new PageRect(0, 0, 32, 32);
            icon.ElementId           = 5;
            icon.Margins             = new Margins(190, -38, 0, 0);
            icon.HorizontalAlignment = HorizontalAlignment.Center;
            icon.VerticalAlignment   = VerticalAlignment.Center;

            panel.Elements.Add(icon);

            CategoryButton = new FilledButton();
            CategoryButton.BackgroundColor     = new BandColor(53, 53, 53);
            CategoryButton.Rect                = new PageRect(0, 0, 44, 44);
            CategoryButton.ElementId           = 4;
            CategoryButton.Margins             = new Margins(184, -40, 0, 0);
            CategoryButton.HorizontalAlignment = HorizontalAlignment.Center;
            CategoryButton.VerticalAlignment   = VerticalAlignment.Center;

            panel.Elements.Add(CategoryButton);

            AmountSingleButton = new TextButton();
            AmountSingleButton.PressedColor        = new BandColor(32, 32, 32);
            AmountSingleButton.Rect                = new PageRect(0, 0, 80, 44);
            AmountSingleButton.ElementId           = 6;
            AmountSingleButton.Margins             = new Margins(92, -44, 0, 0);
            AmountSingleButton.HorizontalAlignment = HorizontalAlignment.Left;
            AmountSingleButton.VerticalAlignment   = VerticalAlignment.Top;

            panel.Elements.Add(AmountSingleButton);
            pageLayout = new PageLayout(panel);

            PageElementData[] pageElementDataArray = new PageElementData[5];
            pageElementDataArray[0] = textBlockData;
            pageElementDataArray[1] = AmountDecimalButtonData;
            pageElementDataArray[2] = iconData;
            pageElementDataArray[3] = CategoryButtonData;
            pageElementDataArray[4] = AmountSingleButtonData;

            pageLayoutData = new PageLayoutData(pageElementDataArray);
        }
コード例 #16
0
        public DesignedBandTileLayout()
        {
            LoadIconMethod  = LoadIcon;
            AdjustUriMethod = (uri) => uri;

            panel = new ScrollFlowPanel();
            panel.ScrollBarColorSource = ElementColorSource.Custom;
            panel.ScrollBarColor       = new BandColor(255, 255, 255);
            panel.Orientation          = FlowPanelOrientation.Vertical;
            panel.Rect                = new PageRect(-1, 0, 259, 128);
            panel.ElementId           = 1;
            panel.Margins             = new Margins(0, 0, 0, 0);
            panel.HorizontalAlignment = HorizontalAlignment.Left;
            panel.VerticalAlignment   = VerticalAlignment.Top;

            panel2                     = new FlowPanel();
            panel2.Orientation         = FlowPanelOrientation.Vertical;
            panel2.Rect                = new PageRect(0, 0, 78, 128);
            panel2.ElementId           = 2;
            panel2.Margins             = new Margins(0, 0, 0, 0);
            panel2.HorizontalAlignment = HorizontalAlignment.Left;
            panel2.VerticalAlignment   = VerticalAlignment.Top;

            textBlock                     = new TextBlock();
            textBlock.Font                = TextBlockFont.Small;
            textBlock.Baseline            = 0;
            textBlock.BaselineAlignment   = TextBlockBaselineAlignment.Automatic;
            textBlock.AutoWidth           = true;
            textBlock.ColorSource         = ElementColorSource.Custom;
            textBlock.Color               = new BandColor(255, 255, 255);
            textBlock.Rect                = new PageRect(0, 0, 32, 32);
            textBlock.ElementId           = 3;
            textBlock.Margins             = new Margins(0, 0, 0, 0);
            textBlock.HorizontalAlignment = HorizontalAlignment.Left;
            textBlock.VerticalAlignment   = VerticalAlignment.Top;

            panel2.Elements.Add(textBlock);

            textBlock2                     = new TextBlock();
            textBlock2.Font                = TextBlockFont.Small;
            textBlock2.Baseline            = 0;
            textBlock2.BaselineAlignment   = TextBlockBaselineAlignment.Automatic;
            textBlock2.AutoWidth           = true;
            textBlock2.ColorSource         = ElementColorSource.Custom;
            textBlock2.Color               = new BandColor(255, 255, 255);
            textBlock2.Rect                = new PageRect(0, 0, 32, 32);
            textBlock2.ElementId           = 4;
            textBlock2.Margins             = new Margins(0, 0, 0, 0);
            textBlock2.HorizontalAlignment = HorizontalAlignment.Left;
            textBlock2.VerticalAlignment   = VerticalAlignment.Top;

            panel2.Elements.Add(textBlock2);

            textBlock3                     = new TextBlock();
            textBlock3.Font                = TextBlockFont.Small;
            textBlock3.Baseline            = 0;
            textBlock3.BaselineAlignment   = TextBlockBaselineAlignment.Automatic;
            textBlock3.AutoWidth           = true;
            textBlock3.ColorSource         = ElementColorSource.Custom;
            textBlock3.Color               = new BandColor(255, 255, 255);
            textBlock3.Rect                = new PageRect(0, 0, 32, 32);
            textBlock3.ElementId           = 5;
            textBlock3.Margins             = new Margins(0, 0, 0, 0);
            textBlock3.HorizontalAlignment = HorizontalAlignment.Left;
            textBlock3.VerticalAlignment   = VerticalAlignment.Top;

            panel2.Elements.Add(textBlock3);

            textBlock4                     = new TextBlock();
            textBlock4.Font                = TextBlockFont.Small;
            textBlock4.Baseline            = 0;
            textBlock4.BaselineAlignment   = TextBlockBaselineAlignment.Automatic;
            textBlock4.AutoWidth           = true;
            textBlock4.ColorSource         = ElementColorSource.Custom;
            textBlock4.Color               = new BandColor(255, 255, 255);
            textBlock4.Rect                = new PageRect(0, 0, 32, 32);
            textBlock4.ElementId           = 6;
            textBlock4.Margins             = new Margins(0, 0, 0, 0);
            textBlock4.HorizontalAlignment = HorizontalAlignment.Left;
            textBlock4.VerticalAlignment   = VerticalAlignment.Top;

            panel2.Elements.Add(textBlock4);

            panel.Elements.Add(panel2);

            panel3                     = new FlowPanel();
            panel3.Orientation         = FlowPanelOrientation.Vertical;
            panel3.Rect                = new PageRect(0, 0, 47, 128);
            panel3.ElementId           = 7;
            panel3.Margins             = new Margins(86, -128, 0, 0);
            panel3.HorizontalAlignment = HorizontalAlignment.Left;
            panel3.VerticalAlignment   = VerticalAlignment.Top;

            txtCoffee                     = new TextBlock();
            txtCoffee.Font                = TextBlockFont.Small;
            txtCoffee.Baseline            = 0;
            txtCoffee.BaselineAlignment   = TextBlockBaselineAlignment.Automatic;
            txtCoffee.AutoWidth           = true;
            txtCoffee.ColorSource         = ElementColorSource.BandHighlight;
            txtCoffee.Rect                = new PageRect(0, 0, 32, 32);
            txtCoffee.ElementId           = 8;
            txtCoffee.Margins             = new Margins(0, 0, 0, 0);
            txtCoffee.HorizontalAlignment = HorizontalAlignment.Left;
            txtCoffee.VerticalAlignment   = VerticalAlignment.Top;

            panel3.Elements.Add(txtCoffee);

            txtTea                     = new TextBlock();
            txtTea.Font                = TextBlockFont.Small;
            txtTea.Baseline            = 0;
            txtTea.BaselineAlignment   = TextBlockBaselineAlignment.Automatic;
            txtTea.AutoWidth           = true;
            txtTea.ColorSource         = ElementColorSource.BandHighlight;
            txtTea.Rect                = new PageRect(0, 0, 32, 32);
            txtTea.ElementId           = 9;
            txtTea.Margins             = new Margins(0, 0, 0, 0);
            txtTea.HorizontalAlignment = HorizontalAlignment.Left;
            txtTea.VerticalAlignment   = VerticalAlignment.Top;

            panel3.Elements.Add(txtTea);

            txtBeer                     = new TextBlock();
            txtBeer.Font                = TextBlockFont.Small;
            txtBeer.Baseline            = 0;
            txtBeer.BaselineAlignment   = TextBlockBaselineAlignment.Automatic;
            txtBeer.AutoWidth           = true;
            txtBeer.ColorSource         = ElementColorSource.BandHighlight;
            txtBeer.Rect                = new PageRect(0, 0, 32, 32);
            txtBeer.ElementId           = 10;
            txtBeer.Margins             = new Margins(0, 0, 0, 0);
            txtBeer.HorizontalAlignment = HorizontalAlignment.Left;
            txtBeer.VerticalAlignment   = VerticalAlignment.Top;

            panel3.Elements.Add(txtBeer);

            txtWine                     = new TextBlock();
            txtWine.Font                = TextBlockFont.Small;
            txtWine.Baseline            = 0;
            txtWine.BaselineAlignment   = TextBlockBaselineAlignment.Automatic;
            txtWine.AutoWidth           = true;
            txtWine.ColorSource         = ElementColorSource.BandHighlight;
            txtWine.Rect                = new PageRect(0, 0, 32, 32);
            txtWine.ElementId           = 11;
            txtWine.Margins             = new Margins(0, 0, 0, 0);
            txtWine.HorizontalAlignment = HorizontalAlignment.Left;
            txtWine.VerticalAlignment   = VerticalAlignment.Top;

            panel3.Elements.Add(txtWine);

            panel.Elements.Add(panel3);

            panel4                     = new FlowPanel();
            panel4.Orientation         = FlowPanelOrientation.Vertical;
            panel4.Rect                = new PageRect(0, 0, 90, 130);
            panel4.ElementId           = 12;
            panel4.Margins             = new Margins(157, -128, 0, 0);
            panel4.HorizontalAlignment = HorizontalAlignment.Left;
            panel4.VerticalAlignment   = VerticalAlignment.Top;

            btnCoffee = new TextButton();
            btnCoffee.PressedColor        = new BandColor(32, 32, 32);
            btnCoffee.Rect                = new PageRect(0, 0, 90, 32);
            btnCoffee.ElementId           = 13;
            btnCoffee.Margins             = new Margins(0, 0, 0, 0);
            btnCoffee.HorizontalAlignment = HorizontalAlignment.Center;
            btnCoffee.VerticalAlignment   = VerticalAlignment.Top;

            panel4.Elements.Add(btnCoffee);

            btnTea = new TextButton();
            btnTea.PressedColor        = new BandColor(32, 32, 32);
            btnTea.Rect                = new PageRect(0, 0, 90, 32);
            btnTea.ElementId           = 14;
            btnTea.Margins             = new Margins(0, 0, 0, 0);
            btnTea.HorizontalAlignment = HorizontalAlignment.Center;
            btnTea.VerticalAlignment   = VerticalAlignment.Top;

            panel4.Elements.Add(btnTea);

            btnBeer = new TextButton();
            btnBeer.PressedColor        = new BandColor(32, 32, 32);
            btnBeer.Rect                = new PageRect(0, 0, 90, 32);
            btnBeer.ElementId           = 15;
            btnBeer.Margins             = new Margins(0, 0, 0, 0);
            btnBeer.HorizontalAlignment = HorizontalAlignment.Center;
            btnBeer.VerticalAlignment   = VerticalAlignment.Top;

            panel4.Elements.Add(btnBeer);

            btnWine = new TextButton();
            btnWine.PressedColor        = new BandColor(32, 32, 32);
            btnWine.Rect                = new PageRect(0, 0, 90, 32);
            btnWine.ElementId           = 16;
            btnWine.Margins             = new Margins(0, 0, 0, 0);
            btnWine.HorizontalAlignment = HorizontalAlignment.Center;
            btnWine.VerticalAlignment   = VerticalAlignment.Top;

            panel4.Elements.Add(btnWine);

            panel.Elements.Add(panel4);
            pageLayout = new PageLayout(panel);

            PageElementData[] pageElementDataArray = new PageElementData[12];
            pageElementDataArray[0]  = textBlockData;
            pageElementDataArray[1]  = textBlock2Data;
            pageElementDataArray[2]  = textBlock3Data;
            pageElementDataArray[3]  = textBlock4Data;
            pageElementDataArray[4]  = txtCoffeeData;
            pageElementDataArray[5]  = txtTeaData;
            pageElementDataArray[6]  = txtBeerData;
            pageElementDataArray[7]  = txtWineData;
            pageElementDataArray[8]  = btnCoffeeData;
            pageElementDataArray[9]  = btnTeaData;
            pageElementDataArray[10] = btnBeerData;
            pageElementDataArray[11] = btnWineData;

            pageLayoutData = new PageLayoutData(pageElementDataArray);
        }