コード例 #1
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);
        }
コード例 #2
0
        /// <summary>
        /// Generates the page layout for the second type of page.
        /// </summary>
        /// <returns>The page layout.</returns>
        private static PageLayout GeneratePageTwo()
        {
            var updatedBlock = new WrappedTextBlock
            {
                ColorSource = ElementColorSource.BandSecondaryText,
                ElementId   = Common.UpdateId,
                AutoHeight  = true,
                Rect        = new PageRect(0, 10, 200, 0),
            };

            var panel = new FlowPanel(updatedBlock)
            {
                Rect = new PageRect(15, 0, 230, 128)
            };

            return(new PageLayout(panel));
        }
コード例 #3
0
        public async Task TestPutTileBand2()
        {
            //Step 1: Connect to Band if need to.
            Message = "Connecting to Band...";
            if (currentBandClient == null)
            {
                //Connect To Band.
                bool isConnected = await InitializeBandConnection();

                //check if connection successful.
                if (isConnected == false)
                {
                    //Something is wrong.
                    Message = "Can't connect to Band. Try Again!";
                    return;
                }
            }

            Message = "Band Connected! Creating Tiles...";

            //Step 2: Create the Tile's Page layout.
            //Would look like this:
            // +--------------------+
            // | Note #1            |       <=== Header Textblock
            // | Angel is the best  |       <=== Wrapperd TextBlock for the Note
            // | girl. Ever <3      |
            // +--------------------+

            //Step 2.1: Create a TextBlock for the Header
            Microsoft.Band.Tiles.Pages.TextBlock myHeaderTextBlock = new TextBlock();

            //Fill The Required Data for the TextBlock (ElementID and Rect):
            //ElementID is the Unique ID of the control (within the layout/page). NOTE: 0 is not a valid ID. Everything has to be positive.
            myHeaderTextBlock.ElementId = 1;

            //Rect: Remember the Rectangle dashed-line in Photoshop when creating a new textbox? That's it. Pretty much the boundary of the control.
            //We will be wrapping this around a ScrollFlowPanel. X,Y of the PageRect will stay 0 (page 39 SDK)

            //Band 1 Workable Width: 245px;
            //Band 2 Workable Width: 258px;
            myHeaderTextBlock.Rect = new Microsoft.Band.Tiles.Pages.PageRect(0, 0, 200, 25);

            //For the Header , let follow the Band Color.? <Does it just stay this way?>
            //myHeaderTextBlock.Color = (await currentBandClient.PersonalizationManager.GetThemeAsync()).Base; <= Not necessarily ? Will be dynamic? Line Blow. Page 40 SDK
            myHeaderTextBlock.ColorSource = ElementColorSource.BandBase;


            //Step 2.2: Create the WrappedTextBlock below for the note.
            Microsoft.Band.Tiles.Pages.WrappedTextBlock myNoteWrappedTextBlock = new WrappedTextBlock();

            //Fill in the required data for the wrapped text block (again, elementID and Rect)
            myNoteWrappedTextBlock.ElementId = 2;
            myNoteWrappedTextBlock.Rect      = new PageRect(0, 0, 250, 100);        //<=== Band 2 Height: 128px ; Band 1 Height: 106px; Wrapped TextBlock should allow displaying a long text with ScrollFlowPanel
            //Actually, the wrapped Textblock seem to not care about the Width?

            //Color should be default of WrappedTextBlock (White)


            //Step 3: Create a Controllers' container. Or the basic layout of the page. Think of it as Grid over the entire window in WPF
            //we use ScrollFlowPanel
            Microsoft.Band.Tiles.Pages.ScrollFlowPanel myPageScrollFlowPanel = new ScrollFlowPanel(myHeaderTextBlock, myNoteWrappedTextBlock);

            //Set the flow of the content to be vertically
            myPageScrollFlowPanel.Orientation = FlowPanelOrientation.Vertical;

            //Set the color of the scroll bar to match the color of the theme that we are using
            myPageScrollFlowPanel.ScrollBarColorSource = ElementColorSource.BandBase;

            //Yet, Rect again. This one should be the entire page.?
            myPageScrollFlowPanel.Rect = new PageRect(0, 0, 250, 128); // Band 2 only


            //Step 4: Create the actual Tile.
            //Step 4.1: Create a Global Unique Identifier for the Tile.
            Guid myGuid = new Guid("D781F673-6D05-4D69-BCFF-EA7E706C3418");

            //Step 4.2 Create the band tile.
            Microsoft.Band.Tiles.BandTile myTile = new BandTile(myGuid);

            //Step 4.3 Setup the properties of the tile. (name, icon, and pageLayout)

            //Name:
            myTile.Name = "My Custom Note Tile";

            //Small and Large Icon.
            //Set the icon following the sample icon that we have from the SDK.
            myTile.TileIcon = await LoadIcon("ms-appx:///Assets/SampleTileIconLarge.png");

            myTile.SmallIcon = await LoadIcon("ms-appx:///Assets/SampleTileIconSmall.png");

            //Create a page layout object from the ScrollFlowPanel that we have.
            Microsoft.Band.Tiles.Pages.PageLayout myPageLayout = new PageLayout(myPageScrollFlowPanel);

            //Add that as the first page (can add up to 8)
            myTile.PageLayouts.Add(myPageLayout);
            myTile.PageLayouts.Add(myPageLayout);

            Message = "Done Creating Tile. Syncing...";

            //Step 5: Sync over to the phone.

            //Step 5.0: Remove old-previous pinned tile.
            //do this to make sure we start fresh everytime.
            await currentBandClient.TileManager.RemoveTileAsync(myTile.TileId);

            //Step 5.1: Sync it over to the phone.
            await currentBandClient.TileManager.AddTileAsync(myTile);


            //Step 6 (EXTRA): We add in a custom data to the page.

            //First one.
            TextBlockData        headerText = new TextBlockData(1, "Note #1");
            WrappedTextBlockData noteText   = new WrappedTextBlockData(2, "Angel is the best girl ever! She is sweet, she is beautiful, she is smart. And after all, she loves me and she is my whole world <3");

            PageData myNotePageData = new PageData(Guid.NewGuid(), 0, headerText, noteText);

            //2nd one
            TextBlockData        headerText2 = new TextBlockData(1, "Note #2");
            WrappedTextBlockData noteText2   = new WrappedTextBlockData(2, "Microsoft Band 2  rocks. This tile was created by Visual Studio 2015, written in C# and Microsoft Band SDK 1.3.20217 on Feb 24th 2016 by Scotty");

            PageData myNotePageData2 = new PageData(Guid.NewGuid(), 1, headerText2, noteText2);

            await currentBandClient.TileManager.SetPagesAsync(myTile.TileId, myNotePageData, myNotePageData2);


            Message = "Done";
        }
コード例 #4
0
        public ActionScreen()
        {
            //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;

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

            panel.Elements.Add(button);

            wrappedTextBlock                     = new WrappedTextBlock();
            wrappedTextBlock.Font                = WrappedTextBlockFont.Small;
            wrappedTextBlock.AutoHeight          = false;
            wrappedTextBlock.ColorSource         = ElementColorSource.Custom;
            wrappedTextBlock.Color               = new BandColor(255, 255, 255);
            wrappedTextBlock.Rect                = new PageRect(8, 61, 260, 200);
            wrappedTextBlock.ElementId           = 4;
            wrappedTextBlock.Margins             = new Margins(0, 0, 0, 0);
            wrappedTextBlock.HorizontalAlignment = HorizontalAlignment.Left;
            wrappedTextBlock.VerticalAlignment   = VerticalAlignment.Top;

            panel.Elements.Add(wrappedTextBlock);

            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(7, 27, 32, 32);
            textBlock.ElementId           = 3;
            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(64, 199, 243);
            textBlock2.Rect                = new PageRect(7, -1, 32, 32);
            textBlock2.ElementId           = 2;
            textBlock2.Margins             = new Margins(0, 0, 0, 0);
            textBlock2.HorizontalAlignment = HorizontalAlignment.Left;
            textBlock2.VerticalAlignment   = VerticalAlignment.Top;

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

            pageLayoutData = new PageData()
            {
                PageId          = ActionScreen.GUID,
                PageLayoutIndex = 3,
                Data            = { buttonData, wrappedTextBlockData, textBlockData, textBlock2Data }
            };
        }
コード例 #5
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();
            }
        }