Exemplo n.º 1
0
 private void CreateRatePoll()
 {
     TextBlock nameTextBlock = new TextBlock() { Color = Colors.Blue.ToBandColor(), ElementId = 1, Rect = new PageRect(0, 0, 200, 30) };
     WrappedTextBlock questionBlock = new WrappedTextBlock() { ElementId = 2, Rect = new PageRect(0, 0, 200, 70) };
     TextButton button1 = new TextButton() { ElementId = 3, Rect = new PageRect(0, 0, 40, 100), PressedColor = new BandColor(0xFF, 0x00, 0x00) };
     TextButton button2 = new TextButton() { ElementId = 4, Rect = new PageRect(0, 0, 40, 100), PressedColor = new BandColor(0xFF, 0x00, 0x00) };
     TextButton button3 = new TextButton() { ElementId = 5, Rect = new PageRect(0, 0, 40, 100), PressedColor = new BandColor(0xFF, 0x00, 0x00) };
     TextButton button4 = new TextButton() { ElementId = 6, Rect = new PageRect(0, 0, 40, 100), PressedColor = new BandColor(0xFF, 0x00, 0x00) };
     TextButton button5 = new TextButton() { ElementId = 7, Rect = new PageRect(0, 0, 40, 100), PressedColor = new BandColor(0xFF, 0x00, 0x00) };
     FlowPanel panel1 = new FlowPanel(nameTextBlock, questionBlock)
     {
         Orientation = FlowPanelOrientation.Vertical,
         Rect = new PageRect(0, 0, 200, 102)
     };
     FlowPanel panel2 = new FlowPanel(button1, button2, button3, button4, button5)
     {
         Orientation = FlowPanelOrientation.Horizontal,
         Rect = new PageRect(0, 0, 200, 102)
     };
     ScrollFlowPanel panelRate = new ScrollFlowPanel(panel1, panel2)
     {
         Orientation = FlowPanelOrientation.Horizontal,
         Rect = new PageRect(0, 0, 200, 102),
         ScrollBarColorSource = ElementColorSource.BandBase
     };
     PageLayout pageLayout = new PageLayout(panelRate);
     PageLayouts.Add(pageLayout);
 }
        private static PageLayout CreateMessageWithButtonLayout()
        {
            var customMessageWrappedTextBlock = new WrappedTextBlock()
            {
                ElementId = PageElementKind.CustomMessageText2,
                Rect = new PageRect(0, 0, 258, 102),
                HorizontalAlignment = HorizontalAlignment.Left,
                VerticalAlignment = VerticalAlignment.Top
            };

            var customMessageButton = new TextButton()
            {
                ElementId = PageElementKind.CustomMessageButton,
                Margins = new Margins(25, 10, 25, 10),
                Rect = new PageRect(0, 0, 170, 45),
                HorizontalAlignment = HorizontalAlignment.Center,
                VerticalAlignment = VerticalAlignment.Center
            };

            var customMessageWithAckButtonPanel = new ScrollFlowPanel(customMessageWrappedTextBlock, customMessageButton)
            {
                Orientation = FlowPanelOrientation.Vertical,
                Rect = new PageRect(0, 0, 258, 102),
                HorizontalAlignment = HorizontalAlignment.Left,
                VerticalAlignment = VerticalAlignment.Top,
            };

            var customMessageWithAckButtonLayout = new PageLayout(customMessageWithAckButtonPanel);
            return customMessageWithAckButtonLayout;
        }
        private static PageLayout CreateMessageLayout()
        {
            var messageWrappedTextBlock = new WrappedTextBlock()
            {
                ElementId = PageElementKind.CustomMessageText,
                Rect = new PageRect(0, 0, 258, 102),
                HorizontalAlignment = HorizontalAlignment.Left,
                VerticalAlignment = VerticalAlignment.Top
            };

            var messageWithoutAckButtonPanel = new ScrollFlowPanel(messageWrappedTextBlock)
            {
                Orientation = FlowPanelOrientation.Vertical,
                Rect = new PageRect(0, 0, 258, 102),
                HorizontalAlignment = HorizontalAlignment.Left,
                VerticalAlignment = VerticalAlignment.Top,
            };

            var messageWithoutAckButtonLayout = new PageLayout(messageWithoutAckButtonPanel);
            return messageWithoutAckButtonLayout;
        }
Exemplo n.º 4
0
        private void CreateLayout(BandTile tile)
        {
            ScrollFlowPanel panel = new ScrollFlowPanel()
            {
                Rect = new PageRect(0, 0, 245, 102),
                Orientation = FlowPanelOrientation.Vertical
            };

            Icon icon = new Icon()
            {
                ElementId = 3,
                Rect = new PageRect(0, 0, 245, 102),
                Margins = new Margins(15, 0, 15, 0),
                VerticalAlignment = VerticalAlignment.Top,
            };

            var nombre = new WrappedTextBlock
            {
                ElementId = 1,
                Rect = new PageRect(0, 0, 245, 102),
                Margins = new Margins(15, 0, 15, 0),
                Color = new BandColor(0xFF, 0xFF, 0xFF),
                Font = WrappedTextBlockFont.Small,
                VerticalAlignment = VerticalAlignment.Top
            };

            var motto = new WrappedTextBlock
            {
                ElementId = 2,
                Rect = new PageRect(0, 0, 245, 102),
                Margins = new Margins(15, 0, 15, 0),
                Color = new BandColor(0xFF, 0xFF, 0xFF),
                Font = WrappedTextBlockFont.Small,
                VerticalAlignment = VerticalAlignment.Top
            };

            panel.Elements.Add(icon); 
            panel.Elements.Add(nombre);
            panel.Elements.Add(motto);

            PageLayout layout = new PageLayout(panel);
            tile.PageLayouts.Add(layout);
        }
Exemplo n.º 5
0
 private void Message()
 {
     TextBlock nameTextBlock = new TextBlock() { Color = Colors.Blue.ToBandColor(), ElementId = 1, Rect = new PageRect(0, 0, 200, 30) };
     WrappedTextBlock questionBlock = new WrappedTextBlock() { ElementId = 2, Rect = new PageRect(0, 0, 200, 60) };
     ScrollFlowPanel panelRate = new ScrollFlowPanel(nameTextBlock, questionBlock)
     {
         Orientation = FlowPanelOrientation.Vertical,
         Rect = new PageRect(0, 0, 200, 102),
         ScrollBarColorSource = ElementColorSource.BandBase
     };
     PageLayout pageLayout = new PageLayout(panelRate);
     PageLayouts.Add(pageLayout);
 }
Exemplo n.º 6
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();
            }
        }