Esempio n. 1
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);
        }
        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);
        }
Esempio n. 3
0
 private void InitializePageView(object mode)
 {
     FlowPanel.SuspendLayout();
     foreach (Control c in FlowPanel.Controls)
     {
         if (c.GetType() == typeof(PictureBox))
         {
             FlowPanel.Controls.Remove(c);
         }
     }
     for (int i = 1; i <= pdfPageCount; i++)
     {
         PictureBox pictureBox = new PictureBox();
         pictureBox.Name        = i.ToString();
         pictureBox.SizeMode    = PictureBoxSizeMode.AutoSize;
         pictureBox.Height      = FlowPanel.Height - pictureBox.Margin.Top * 2;
         pictureBox.Width       = FlowPanel.Width - pictureBox.Margin.Right * 2 - SystemInformation.VerticalScrollBarWidth;
         pictureBox.MouseUp    += PicImage_MouseUp;
         pictureBox.MouseDown  += PicImage_MouseDown;
         pictureBox.MouseMove  += PicImage_MouseMove;
         pictureBox.MouseClick += FlowPanel_Click;
         FlowPanel.Controls.Add(pictureBox);
         ApplyZoomToPDF(pictureBox, mode);
         GetImageFromPDF(i, pictureBox);
     }
     FlowPanel.ResumeLayout();
     scrollUnitsPerPage = (FlowPanel.VerticalScroll.Maximum - FlowPanel.VerticalScroll.LargeChange) / pdfPageCount;
     pageInitDone       = true;
 }
Esempio n. 4
0
        protected override void Build(Panel buildPanel)
        {
            var rootPanel = new FlowPanel()
            {
                WidthSizingMode  = SizingMode.Fill,
                HeightSizingMode = SizingMode.Fill,
                FlowDirection    = ControlFlowDirection.SingleTopToBottom,
                Parent           = buildPanel
            };

            BuildOverlaySettings(rootPanel);
        }
Esempio n. 5
0
        public static void BuildSingleModuleSettings(Panel buildPanel, object nothing)
        {
            var settingPanels = new FlowPanel()
            {
                Size       = buildPanel.ContentRegion.Size,
                ShowBorder = true,
                Parent     = buildPanel
            };

            var applicationSettingsPanel = new Panel()
            {
                Width       = settingPanels.ContentRegion.Width - 8,
                Title       = "Application Settings",
                CanCollapse = true,
                Height      = 128,
                Parent      = settingPanels,
            };

            var applicationSettingsPadding = new Panel()
            {
                Size     = applicationSettingsPanel.Size - new Point(25),
                Location = new Point(25, 12),
                Parent   = applicationSettingsPanel
            };

            var updatePanel = new Panel()
            {
                Width       = settingPanels.ContentRegion.Width - 8,
                Title       = "Updates",
                Height      = 128,
                CanCollapse = true,
                Collapsed   = false,
                Parent      = settingPanels
            };

            var audioSettingsPanel = new Panel()
            {
                Width       = settingPanels.ContentRegion.Width - 8,
                Title       = "Volume Settings",
                Height      = 128,
                CanCollapse = true,
                Collapsed   = false,
                Parent      = settingPanels
            };

            GameService.Settings.RenderSettingsToPanel(applicationSettingsPadding, GameService.Overlay._applicationSettings.Entries);

            UpdateUIBuilder.BuildUpdateBlishHudSettings(updatePanel, null);
        }
Esempio n. 6
0
 protected override void OnPanelMouseDown(FlowPanel panel, int x, int y, MouseButtons button)
 {
     foreach (var p in Panels)
     {
         if (p != panel)
         {
             var filePanel = p as FileDiffPanel;
             if (filePanel != null)
             {
                 filePanel.DropSelection();
             }
         }
     }
     base.OnPanelMouseDown(panel, x, y, button);
 }
Esempio n. 7
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);
        }
Esempio n. 8
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));
        }
Esempio n. 9
0
        private async Task <bool> CreateLayout(BandTile bandTile)
        {
            bool result = false;

            using (IBandClient bandClient = await BandClientManager.Instance.ConnectAsync(band))
            {
                Microsoft.Band.Tiles.Pages.TextBlock myBandTextBlock = new Microsoft.Band.Tiles.Pages.TextBlock()
                {
                    ElementId = 1, // the Id of the TextBlock element; we'll use it later to set its text to "MY CARD"
                    Rect      = new PageRect(0, 0, 200, 25)
                };

                FlowPanel panel = new FlowPanel(myBandTextBlock)
                {
                    Orientation = FlowPanelOrientation.Vertical,
                    Rect        = new PageRect(60, 50, 250, 100)
                };

                bandTile.PageLayouts.Add(new PageLayout(panel));

                await bandClient.TileManager.RemoveTileAsync(bandTile.TileId);

                try
                {
                    // add the tile to the Band
                    if (await bandClient.TileManager.AddTileAsync(bandTile))
                    {
                        // And create the page with the specified texts and values.
                        PageData page = new PageData(
                            Guid.NewGuid(), // the Id for the page
                            0,              // the index of the layout to be used; we have only one layout in this sample app, but up to 5 layouts can be registered for a Tile
                            new TextBlockData(myBandTextBlock.ElementId.Value, "Hello Band!"));

                        await bandClient.TileManager.SetPagesAsync(bandTile.TileId, page);

                        result = true;
                    }
                }
                catch (Exception ex)
                {
                    result = false;
                }
                return(result);
            }
        }
        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);
        }
Esempio n. 11
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);
        }
Esempio n. 12
0
        private Panel BuildSettingPanel(Rectangle panelBounds)
        {
            var etPanel = new Panel()
            {
                CanScroll = false,
                Size      = panelBounds.Size
            };

            var eventPanel = new FlowPanel()
            {
                FlowDirection  = ControlFlowDirection.LeftToRight,
                ControlPadding = new Vector2(8, 8),
                Location       = new Point(etPanel.Width - 720 - 10 - 20, 50),
                Size           = new Point(748, etPanel.Size.Y - 50 - Panel.BOTTOM_MARGIN),
                Parent         = etPanel,
                CanScroll      = true,
            };

            var ddSortMethod = new Dropdown()
            {
                Parent   = etPanel,
                Location = new Point(etPanel.Right - 150 - 10, 5),
                Width    = 150
            };

            foreach (var meta in Meta.Events)
            {
                var setting = allSettings.DefineSetting("watchEvent:" + meta.Name, true, true, false, "");

                meta.IsWatched = setting.Value;

                var es2 = new DetailsButton {
                    Parent           = eventPanel,
                    BasicTooltipText = meta.Category,
                    Text             = meta.Name,
                    IconSize         = DetailsIconSize.Small,
                    Icon             = string.IsNullOrEmpty(meta.Icon) ? null : GameService.Content.GetTexture(meta.Icon),
                    ShowVignette     = false,
                    HighlightType    = DetailsHighlightType.LightHighlight,
                    ShowToggleButton = true
                };

                var nextTimeLabel = new Label()
                {
                    Size                = new Point(65, es2.ContentRegion.Height),
                    Text                = meta.NextTime.ToShortTimeString(),
                    BasicTooltipText    = GetTimeDetails(meta),
                    HorizontalAlignment = DrawUtil.HorizontalAlignment.Center,
                    VerticalAlignment   = DrawUtil.VerticalAlignment.Middle,
                    Parent              = es2,
                };

                Adhesive.Binding.CreateOneWayBinding(() => nextTimeLabel.Height, () => es2.ContentRegion, (rectangle => rectangle.Height), true);

                if (!string.IsNullOrEmpty(meta.Wiki))
                {
                    var glowWikiBttn = new GlowButton {
                        Icon             = GameService.Content.GetTexture("102530"),
                        ActiveIcon       = GameService.Content.GetTexture("glow-wiki"),
                        BasicTooltipText = "Read about this event on the wiki.",
                        Parent           = es2,
                        GlowColor        = Color.White * 0.1f
                    };

                    glowWikiBttn.Click += delegate {
                        if (Url.IsValid(meta.Wiki))
                        {
                            Process.Start(meta.Wiki);
                        }
                    };
                }

                if (!string.IsNullOrEmpty(meta.Waypoint))
                {
                    var glowWaypointBttn = new GlowButton {
                        Icon             = GameService.Content.GetTexture("waypoint"),
                        ActiveIcon       = GameService.Content.GetTexture("glow-waypoint"),
                        BasicTooltipText = $"Nearby waypoint: {meta.Waypoint}",
                        Parent           = es2,
                        GlowColor        = Color.White * 0.1f
                    };

                    glowWaypointBttn.Click += delegate {
                        System.Windows.Forms.Clipboard.SetText(meta.Waypoint);

                        Controls.Notification.ShowNotification(GameService.Content.GetTexture("waypoint"), "Waypoint copied to clipboard.", 2);
                    };
                }

                var toggleFollowBttn = new GlowButton()
                {
                    Icon             = GameService.Content.GetTexture("605021"),
                    ActiveIcon       = GameService.Content.GetTexture("605019"),
                    BasicTooltipText = "Click to toggle tracking for this event.",
                    ToggleGlow       = true,
                    Checked          = meta.IsWatched,
                    Parent           = es2,
                };

                toggleFollowBttn.Click += delegate {
                    meta.IsWatched = toggleFollowBttn.Checked;
                    setting.Value  = toggleFollowBttn.Checked;
                };

                meta.OnNextRunTimeChanged += delegate {
                    UpdateSort(ddSortMethod, EventArgs.Empty);

                    nextTimeLabel.Text             = meta.NextTime.ToShortTimeString();
                    nextTimeLabel.BasicTooltipText = GetTimeDetails(meta);
                };

                displayedEvents.Add(es2);
            }

            var menuSection = new Panel {
                ShowBorder = true,
                Size       = new Point(etPanel.Width - 720 - 10 - 10 - 5 - 20, eventPanel.Height + Panel.BOTTOM_MARGIN),
                Location   = new Point(5, 50),
                Parent     = etPanel,
                Title      = "Event Categories"
            };

            // Add menu items for each category (and built-in categories)
            var eventCategories = new Menu {
                Size           = menuSection.ContentRegion.Size,
                MenuItemHeight = 40,
                Parent         = menuSection,
            };

            List <IGrouping <string, Meta> > submetas = Meta.Events.GroupBy(e => e.Category).ToList();

            var evAll = eventCategories.AddMenuItem(EC_ALLEVENTS);

            evAll.LeftMouseButtonReleased += delegate {
                displayedEvents.ForEach(de => { de.Visible = true; });

                //RepositionES();
            };

            foreach (IGrouping <string, Meta> e in submetas)
            {
                var ev = eventCategories.AddMenuItem(e.Key);
                ev.LeftMouseButtonReleased += delegate {
                    //displayedEvents.ForEach(de => { de.Visible = de.AssignedMeta.Category == e.Key; });

                    //RepositionES();
                };
            }

            // TODO: Hidden events/timers to be added later
            //eventCategories.AddMenuItem(EC_HIDDEN);

            // Add dropdown for sorting events
            ddSortMethod.Items.Add(DD_ALPHABETICAL);
            ddSortMethod.Items.Add(DD_NEXTUP);

            ddSortMethod.ValueChanged += UpdateSort;

            ddSortMethod.SelectedItem = DD_NEXTUP;
            UpdateSort(ddSortMethod, EventArgs.Empty);

            Console.WriteLine("Main Panel is: " + etPanel.Location.ToString() + " :: " + etPanel.Size.ToString());
            Console.WriteLine("Event Panel is: " + eventPanel.Location.ToString() + " :: " + eventPanel.Size.ToString());
            Console.WriteLine("Menu Section Panel is: " + menuSection.Location.ToString() + " :: " + eventPanel.Size.ToString());

            return(etPanel);
        }
        private Panel BuildModulePanel(WindowBase wnd)
        {
            var homePanel = new Panel
            {
                Parent = wnd,
                Size   = new Point(WindowWidth, WindowHeight)
            };

            thumbnailFlowPanel = new FlowPanel
            {
                Parent         = homePanel,
                Size           = new Point(homePanel.ContentRegion.Size.X - 70, homePanel.ContentRegion.Size.Y - 130),
                Location       = new Point(35, 50),
                FlowDirection  = ControlFlowDirection.LeftToRight,
                ControlPadding = new Vector2(5, 5),
                CanCollapse    = false,
                CanScroll      = true,
                Collapsed      = false,
                ShowTint       = true,
                ShowBorder     = true
            };
            var searchBox = new TextBox
            {
                Parent          = homePanel,
                Location        = new Point(thumbnailFlowPanel.Location.X, thumbnailFlowPanel.Location.Y - 40),
                Size            = new Point(200, 40),
                PlaceholderText = SearchBoxPlaceHolder
            };
            var deleteSearchBoxContentButton = new Blish_HUD.Controls.Image
            {
                Parent   = homePanel,
                Location = new Point(searchBox.Right - 20 - PanelMargin, searchBox.Location.Y + PanelMargin),
                Size     = new Point(20, 20),
                Texture  = _deleteSearchBoxContentIcon,
                Visible  = false
            };

            deleteSearchBoxContentButton.Click += delegate
            {
                searchBox.Text = "";
                deleteSearchBoxContentButton.Hide();
            };
            deleteSearchBoxContentButton.MouseEntered += delegate
            {
                if (deleteSearchBoxContentButton.Visible)
                {
                    GameService.Animation.Tweener.Tween(deleteSearchBoxContentButton, new { Opacity = 1.0f }, 0.2f);
                }
            };
            deleteSearchBoxContentButton.MouseLeft += delegate
            {
                if (deleteSearchBoxContentButton.Visible)
                {
                    GameService.Animation.Tweener.Tween(deleteSearchBoxContentButton, new { Opacity = 0.8f }, 0.2f);
                }

                deleteSearchBoxContentButton.Size     = new Point(20, 20);
                deleteSearchBoxContentButton.Location = new Point(searchBox.Right - 20 - PanelMargin,
                                                                  searchBox.Location.Y + PanelMargin);
            };
            deleteSearchBoxContentButton.LeftMouseButtonPressed += delegate
            {
                deleteSearchBoxContentButton.Width   -= 2;
                deleteSearchBoxContentButton.Height  -= 2;
                deleteSearchBoxContentButton.Location = new Point(deleteSearchBoxContentButton.Location.X + 2,
                                                                  deleteSearchBoxContentButton.Location.Y + 2);
            };
            searchBox.InputFocusChanged += delegate { SortThumbnails(); };
            searchBox.TextChanged       += delegate
            {
                deleteSearchBoxContentButton.Visible = !searchBox.Text.Equals(string.Empty);
                thumbnailFlowPanel.SortChildren(delegate(Panel x, Panel y)
                {
                    var fileNameX  = Path.GetFileNameWithoutExtension(x.BasicTooltipText);
                    var fileNameY  = Path.GetFileNameWithoutExtension(y.BasicTooltipText);
                    x.Visible      = fileNameX.Contains(searchBox.Text);
                    y.Visible      = fileNameY.Contains(searchBox.Text);
                    var favMarkerX = (Blish_HUD.Controls.Image)x.Children.FirstOrDefault(m =>
                                                                                         m.BasicTooltipText != null && (m.BasicTooltipText.Equals(FavoriteMarkerTooltip) ||
                                                                                                                        m.BasicTooltipText.Equals(UnfavoriteMarkerTooltip)));
                    var favMarkerY = (Blish_HUD.Controls.Image)y.Children.FirstOrDefault(m =>
                                                                                         m.BasicTooltipText != null && (m.BasicTooltipText.Equals(FavoriteMarkerTooltip) ||
                                                                                                                        m.BasicTooltipText.Equals(UnfavoriteMarkerTooltip)));
                    if (favMarkerX != null && favMarkerY != null)
                    {
                        var favorite = string.Compare(favMarkerY.BasicTooltipText, favMarkerX.BasicTooltipText,
                                                      StringComparison.InvariantCultureIgnoreCase);
                        if (favorite != 0)
                        {
                            return(favorite);
                        }
                    }

                    return(string.Compare(fileNameX, fileNameY, StringComparison.InvariantCultureIgnoreCase));
                });
            };
            homePanel.Hidden += ToggleFileSystemWatchers;
            homePanel.Hidden += ToggleFileSystemWatchers;
            homePanel.Shown  += LoadImages;
            homePanel.Hidden += DisposeDisplayedThumbnails;
            return(homePanel);
        }
Esempio n. 14
0
        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);
                }
            }
        }
Esempio n. 15
0
        private async void OnAddButtonTileClick(object sender, EventArgs e)
        {
            try
            {
                BitmapFactory.Options options = new BitmapFactory.Options();
                options.InScaled = false;
                BandIcon tileIcon = BandIcon.ToBandIcon(BitmapFactory.DecodeResource(Resources, Resource.Raw.tile, options));

                BandIcon badgeIcon = BandIcon.ToBandIcon(BitmapFactory.DecodeResource(Resources, Resource.Raw.badge, options));

                FilledButton button = new FilledButton(0, 5, 210, 45);
                button.BackgroundColor = Color.Red;
                button.Margins         = new Margins(0, 5, 0, 0);
                button.ElementId       = 12;

                TextButton button2 = new TextButton(0, 0, 210, 45);
                button2.PressedColor = Color.Blue;
                button2.Margins      = new Margins(0, 5, 0, 0);
                button2.ElementId    = 21;

                FlowPanel flowPanel = new FlowPanel(15, 0, 260, 105, FlowPanelOrientation.Vertical);
                flowPanel.AddElements(button);
                flowPanel.AddElements(button2);

                PageLayout pageLayout = new PageLayout(flowPanel);

                BandTile.Builder builder = new BandTile.Builder(Java.Util.UUID.RandomUUID(), mEditTileName.Text, tileIcon);
                if (mCheckboxBadging.Checked)
                {
                    builder.SetTileSmallIcon(badgeIcon);
                }
                if (mCheckboxCustomTheme.Checked)
                {
                    builder.SetTheme(mThemeView.Theme);
                }
                builder.SetPageLayouts(pageLayout);
                BandTile tile = builder.Build();

                try
                {
                    var result = await Model.Instance.Client.TileManager.AddTileTaskAsync(Activity, tile);

                    if (result)
                    {
                        Toast.MakeText(Activity, "Tile added", ToastLength.Short).Show();
                    }
                    else
                    {
                        Toast.MakeText(Activity, "Unable to add tile", ToastLength.Short).Show();
                    }
                }
                catch (Exception ex)
                {
                    Util.ShowExceptionAlert(Activity, "Add tile", ex);
                }

                PageData pageData = new PageData(Java.Util.UUID.RandomUUID(), 0);
                pageData.Update(new FilledButtonData(12, Color.Yellow));
                pageData.Update(new TextButtonData(21, "Text Button"));
                await Model.Instance.Client.TileManager.SetPagesTaskAsync(tile.TileId, pageData);

                Toast.MakeText(Activity, "Page updated", ToastLength.Short).Show();

                // Refresh our tile list and count
                await RefreshData();

                RefreshControls();
            }
            catch (Exception ex)
            {
                Util.ShowExceptionAlert(Activity, "Add tile", ex);
            }
        }
Esempio n. 16
0
        private async void OnAddBarcodeButtonClick(object sender, EventArgs e)
        {
            try
            {
                BitmapFactory.Options options = new BitmapFactory.Options();
                options.InScaled = false;
                BandIcon tileIcon = BandIcon.ToBandIcon(BitmapFactory.DecodeResource(Resources, Resource.Raw.tile, options));

                BandIcon badgeIcon = BandIcon.ToBandIcon(BitmapFactory.DecodeResource(Resources, Resource.Raw.badge, options));

                // create layout 1

                Barcode barcode1 = new Barcode(new PageRect(0, 0, 221, 70), BarcodeType.Code39);
                barcode1.Margins   = new Margins(3, 0, 0, 0);
                barcode1.ElementId = 11;

                TextBlock textBlock1 = new TextBlock(new PageRect(0, 0, 230, 30), TextBlockFont.Small, 0);
                textBlock1.Color     = Color.Red;
                textBlock1.ElementId = 21;

                FlowPanel flowPanel1 = new FlowPanel(new PageRect(15, 0, 245, 105), FlowPanelOrientation.Vertical);
                flowPanel1.AddElements(barcode1);
                flowPanel1.AddElements(textBlock1);

                PageLayout pageLayout1 = new PageLayout(flowPanel1);

                // create layout 2

                Barcode barcode2 = new Barcode(0, 0, 221, 70, BarcodeType.Pdf417);
                barcode2.Margins   = new Margins(3, 0, 0, 0);
                barcode2.ElementId = 11;

                TextBlock textBlock2 = new TextBlock(0, 0, 230, 30, TextBlockFont.Small, 0);
                textBlock2.Color     = Color.Red;
                textBlock2.ElementId = 21;

                FlowPanel flowPanel2 = new FlowPanel(15, 0, 245, 105, FlowPanelOrientation.Vertical);
                flowPanel2.AddElements(barcode2);
                flowPanel2.AddElements(textBlock2);

                PageLayout pageLayout2 = new PageLayout(flowPanel2);

                // create the tile

                BandTile.Builder builder = new BandTile.Builder(Java.Util.UUID.RandomUUID(), mEditTileName.Text, tileIcon);
                if (mCheckboxBadging.Checked)
                {
                    builder.SetTileSmallIcon(badgeIcon);
                }
                if (mCheckboxCustomTheme.Checked)
                {
                    builder.SetTheme(mThemeView.Theme);
                }
                builder.SetPageLayouts(pageLayout1, pageLayout2);
                BandTile tile = builder.Build();

                // add tile

                try
                {
                    var result = await Model.Instance.Client.TileManager.AddTileTaskAsync(Activity, tile);

                    if (result)
                    {
                        Toast.MakeText(Activity, "Tile added", ToastLength.Short).Show();
                    }
                    else
                    {
                        Toast.MakeText(Activity, "Unable to add tile", ToastLength.Short).Show();
                    }
                }
                catch (Exception ex)
                {
                    Util.ShowExceptionAlert(Activity, "Add tile", ex);
                }

                PageData pageData1 = new PageData(Java.Util.UUID.RandomUUID(), 0);
                pageData1.Update(new BarcodeData(11, "MK12345509", BarcodeType.Code39));
                pageData1.Update(new TextButtonData(21, "MK12345509"));

                PageData pageData2 = new PageData(Java.Util.UUID.RandomUUID(), 1);
                pageData2.Update(new BarcodeData(11, "901234567890123456", BarcodeType.Pdf417));
                pageData2.Update(new TextButtonData(21, "901234567890123456"));

                await Model.Instance.Client.TileManager.SetPagesTaskAsync(tile.TileId, pageData1, pageData2);

                Toast.MakeText(Activity, "Page updated", ToastLength.Short).Show();

                // Refresh our tile list and count
                await RefreshData();

                RefreshControls();
            }
            catch (Exception ex)
            {
                Util.ShowExceptionAlert(Activity, "Add tile", ex);
            }
        }
        private Panel BuildSettingPanel(Rectangle panelBounds)
        {
            var etPanel = new Panel()
            {
                CanScroll = false,
                Size      = panelBounds.Size
            };

            var ddSortMethod = new Dropdown()
            {
                Location = new Point(etPanel.Right - 150 - Dropdown.Standard.ControlOffset.X, Dropdown.Standard.ControlOffset.Y),
                Width    = 150,
                Parent   = etPanel,
            };

            int topOffset = ddSortMethod.Bottom + Panel.MenuStandard.ControlOffset.Y;

            var menuSection = new Panel {
                Title      = "Event Categories",
                ShowBorder = true,
                Size       = Panel.MenuStandard.Size - new Point(0, topOffset + Panel.MenuStandard.ControlOffset.Y),
                Location   = new Point(Panel.MenuStandard.PanelOffset.X, topOffset),
                Parent     = etPanel
            };

            var eventPanel = new FlowPanel()
            {
                FlowDirection  = ControlFlowDirection.LeftToRight,
                ControlPadding = new Vector2(8, 8),
                Location       = new Point(menuSection.Right + Panel.MenuStandard.ControlOffset.X, menuSection.Top),
                Size           = new Point(ddSortMethod.Right - menuSection.Right - Control.ControlStandard.ControlOffset.X, menuSection.Height),
                CanScroll      = true,
                Parent         = etPanel
            };

            GameService.Overlay.QueueMainThreadUpdate((gameTime) => {
                var searchBox = new TextBox()
                {
                    PlaceholderText = "Event Search",
                    Width           = menuSection.Width,
                    Location        = new Point(ddSortMethod.Top, menuSection.Left),
                    Parent          = etPanel
                };

                searchBox.TextChanged += delegate(object sender, EventArgs args) {
                    eventPanel.FilterChildren <DetailsButton>(db => db.Text.ToLower().Contains(searchBox.Text.ToLower()));
                };
            });

            foreach (var meta in Meta.Events)
            {
                var setting = _watchCollection.DefineSetting("watchEvent:" + meta.Name, true);

                meta.IsWatched = setting.Value;

                var es2 = new DetailsButton {
                    Parent           = eventPanel,
                    BasicTooltipText = meta.Category,
                    Text             = meta.Name,
                    IconSize         = DetailsIconSize.Small,
                    ShowVignette     = false,
                    HighlightType    = DetailsHighlightType.LightHighlight,
                    ShowToggleButton = true
                };

                if (meta.Texture.HasTexture)
                {
                    es2.Icon = meta.Texture;
                }

                var nextTimeLabel = new Label()
                {
                    Size                = new Point(65, es2.ContentRegion.Height),
                    Text                = meta.NextTime.ToShortTimeString(),
                    BasicTooltipText    = GetTimeDetails(meta),
                    HorizontalAlignment = HorizontalAlignment.Center,
                    VerticalAlignment   = VerticalAlignment.Middle,
                    Parent              = es2,
                };

                Adhesive.Binding.CreateOneWayBinding(() => nextTimeLabel.Height, () => es2.ContentRegion, (rectangle => rectangle.Height), true);

                if (!string.IsNullOrEmpty(meta.Wiki))
                {
                    var glowWikiBttn = new GlowButton {
                        Icon             = GameService.Content.GetTexture("102530"),
                        ActiveIcon       = GameService.Content.GetTexture("glow-wiki"),
                        BasicTooltipText = "Read about this event on the wiki.",
                        Parent           = es2,
                        GlowColor        = Color.White * 0.1f
                    };

                    glowWikiBttn.Click += delegate {
                        if (UrlIsValid(meta.Wiki))
                        {
                            Process.Start(meta.Wiki);
                        }
                    };
                }

                if (!string.IsNullOrEmpty(meta.Waypoint))
                {
                    var glowWaypointBttn = new GlowButton {
                        Icon             = GameService.Content.GetTexture("waypoint"),
                        ActiveIcon       = GameService.Content.GetTexture("glow-waypoint"),
                        BasicTooltipText = $"Nearby waypoint: {meta.Waypoint}",
                        Parent           = es2,
                        GlowColor        = Color.White * 0.1f
                    };

                    glowWaypointBttn.Click += delegate {
                        System.Windows.Forms.Clipboard.SetText(meta.Waypoint);

                        ScreenNotification.ShowNotification("Waypoint copied to clipboard.");
                    };
                }

                var toggleFollowBttn = new GlowButton()
                {
                    Icon             = _textureWatch,
                    ActiveIcon       = _textureWatchActive,
                    BasicTooltipText = "Click to toggle tracking for this event.",
                    ToggleGlow       = true,
                    Checked          = meta.IsWatched,
                    Parent           = es2,
                };

                toggleFollowBttn.Click += delegate {
                    meta.IsWatched = toggleFollowBttn.Checked;
                    setting.Value  = toggleFollowBttn.Checked;
                };

                meta.OnNextRunTimeChanged += delegate {
                    UpdateSort(ddSortMethod, EventArgs.Empty);

                    nextTimeLabel.Text             = meta.NextTime.ToShortTimeString();
                    nextTimeLabel.BasicTooltipText = GetTimeDetails(meta);
                };

                _displayedEvents.Add(es2);
            }

            // Add menu items for each category (and built-in categories)
            var eventCategories = new Menu {
                Size           = menuSection.ContentRegion.Size,
                MenuItemHeight = 40,
                Parent         = menuSection,
                CanSelect      = true
            };

            List <IGrouping <string, Meta> > submetas = Meta.Events.GroupBy(e => e.Category).ToList();

            var evAll = eventCategories.AddMenuItem(EC_ALLEVENTS);

            evAll.Select();
            evAll.Click += delegate {
                eventPanel.FilterChildren <DetailsButton>(db => true);
            };

            foreach (IGrouping <string, Meta> e in submetas)
            {
                var ev = eventCategories.AddMenuItem(e.Key);
                ev.Click += delegate {
                    eventPanel.FilterChildren <DetailsButton>(db => string.Equals(db.BasicTooltipText, e.Key));
                };
            }

            // TODO: Hidden events/timers to be added later
            //eventCategories.AddMenuItem(EC_HIDDEN);

            // Add dropdown for sorting events
            ddSortMethod.Items.Add(DD_ALPHABETICAL);
            ddSortMethod.Items.Add(DD_NEXTUP);

            ddSortMethod.ValueChanged += delegate(object sender, ValueChangedEventArgs args) {
                switch (args.CurrentValue)
                {
                case DD_ALPHABETICAL:
                    eventPanel.SortChildren <DetailsButton>((db1, db2) => string.Compare(db1.Text, db2.Text, StringComparison.CurrentCultureIgnoreCase));
                    break;

                case DD_NEXTUP:
                    break;
                }
            };

            ddSortMethod.SelectedItem = DD_NEXTUP;
            //UpdateSort(ddSortMethod, EventArgs.Empty);

            return(etPanel);
        }
Esempio n. 18
0
        private Panel BuildHomePanel(WindowBase wndw)
        {
            var tdPanel = new Panel()
            {
                CanScroll = false,
                Size      = wndw.ContentRegion.Size
            };


            int topOffset = 40 + Panel.MenuStandard.ControlOffset.Y;

            var menuSection = new Panel
            {
                Title      = "Event Categories",
                ShowBorder = true,
                Size       = Panel.MenuStandard.Size - new Point(0, +topOffset + Panel.MenuStandard.ControlOffset.Y),
                Location   = new Point(Panel.MenuStandard.PanelOffset.X, topOffset),
                Parent     = tdPanel
            };
            var mainPanel = new FlowPanel()
            {
                FlowDirection = ControlFlowDirection.LeftToRight,
                Location      = new Point(menuSection.Right + Panel.MenuStandard.ControlOffset.X, menuSection.Top),
                Size          = new Point(tdPanel.Right - menuSection.Right - (Control.ControlStandard.ControlOffset.X * 2), menuSection.Height),
                CanScroll     = false,
                Parent        = tdPanel,
            };
            var taskPanel = new FlowPanel()
            {
                FlowDirection  = ControlFlowDirection.LeftToRight,
                ControlPadding = new Vector2(8, 8),
                //Location = new Point(menuSection.Right + Panel.MenuStandard.ControlOffset.X, menuSection.Top),
                Size      = new Point(tdPanel.Right - menuSection.Right - (Control.ControlStandard.ControlOffset.X * 2), menuSection.Height - 70),
                CanScroll = true,
                Parent    = mainPanel,
            };

            GameService.Overlay.QueueMainThreadUpdate((gameTime) => {
                var searchBox = new TextBox()
                {
                    PlaceholderText = "Filter Tasks",
                    Width           = menuSection.Width,
                    Location        = new Point(menuSection.Left, TextBox.Standard.ControlOffset.Y),
                    Parent          = tdPanel
                };

                searchBox.TextChanged += delegate(object sender, EventArgs args) {
                    taskPanel.FilterChildren <DetailsButton>(db => db.Text.ToLower().Contains(searchBox.Text.ToLower()));
                };
            });

            foreach (var task in tdTask.Tasks)
            {
                var es2 = new DetailsButton
                {
                    Parent           = taskPanel,
                    BasicTooltipText = task.Category,
                    Text             = task.Description,
                    IconSize         = DetailsIconSize.Small,
                    ShowVignette     = false,
                    HighlightType    = DetailsHighlightType.LightHighlight,
                    ShowToggleButton = true
                };

                if (task.Texture.HasTexture)
                {
                    es2.Icon = task.Texture;
                }
                _displayedTasks.Add(es2);
            }

            var actionPanel = new FlowPanel()
            {
                Size           = new Point(taskPanel.Width, 50),
                CanScroll      = false,
                FlowDirection  = ControlFlowDirection.LeftToRight,
                ShowBorder     = false,
                Parent         = mainPanel,
                ControlPadding = new Vector2(8, 8)

                                 //BackgroundColor = Microsoft.Xna.Framework.Color.Black
            };
            var newTaskButton = new StandardButton
            {
                Parent = actionPanel,
                Text   = "New Task"
            };

            //Create new panel to switch to
            var newtaskPanel = BuildNewTaskPanel(wndw);

            newTaskButton.LeftMouseButtonReleased += delegate { wndw.Navigate(newtaskPanel, true); };

            //Add categories
            var taskCategories = new Menu
            {
                Size           = menuSection.ContentRegion.Size,
                MenuItemHeight = 40,
                Parent         = menuSection,
                CanSelect      = true
            };

            List <IGrouping <string, tdTask> > submetas = tdTask.Tasks.GroupBy(e => e.Category).ToList();

            var evAll = taskCategories.AddMenuItem(EC_ALLEVENTS);

            evAll.Select();
            evAll.Click += delegate {
                taskPanel.FilterChildren <DetailsButton>(db => true);
            };
            foreach (IGrouping <string, tdTask> e in submetas)
            {
                var ev = taskCategories.AddMenuItem(e.Key);
                ev.Click += delegate {
                    taskPanel.FilterChildren <DetailsButton>(db => string.Equals(db.BasicTooltipText, e.Key));
                };
            }
            return(tdPanel);
        }
Esempio n. 19
0
        protected FlowPanelHeader(FlowPanel flowPanel)
        {
            Verify.Argument.IsNotNull(flowPanel, nameof(flowPanel));

            FlowPanel = flowPanel;
        }
Esempio n. 20
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....");
            }
        }
Esempio n. 21
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);
        }
Esempio n. 22
0
 private void DisplayCurrentPage()
 {
     CheckPageBounds();
     FlowPanel.ScrollControlIntoView(FindPictureBox(currentPageNumber.ToString()));
     UpdatePageLabel();
 }
Esempio n. 23
0
 private void FlowPanel_Click(object sender, EventArgs e)
 {
     FlowPanel.Focus();
 }
Esempio n. 24
0
        /// <summary>
        /// Generates the page layout for the first type of page.
        /// </summary>
        /// <returns>The page layout.</returns>
        private static PageLayout GeneratePageOne()
        {
            var titleBlock = new TextBlock
            {
                ColorSource       = ElementColorSource.BandHighlight,
                ElementId         = Common.TitleId,
                Rect              = new PageRect(0, 0, 0, 35),
                AutoWidth         = true,
                Baseline          = 30,
                BaselineAlignment = TextBlockBaselineAlignment.Absolute
            };

            var spacerBlock = new TextBlock
            {
                Color             = new BandColor(0x77, 0x77, 0x77),
                ElementId         = Common.SpacerId,
                Rect              = new PageRect(0, 0, 0, 35),
                Margins           = new Margins(5, 0, 5, 0),
                AutoWidth         = true,
                Baseline          = 30,
                BaselineAlignment = TextBlockBaselineAlignment.Absolute
            };

            var secondaryTitleBlock = new TextBlock
            {
                ColorSource       = ElementColorSource.BandSecondaryText,
                ElementId         = Common.SeondaryTitleId,
                Rect              = new PageRect(0, 0, 0, 35),
                AutoWidth         = true,
                Baseline          = 30,
                BaselineAlignment = TextBlockBaselineAlignment.Absolute
            };

            var topFlowPanel = new FlowPanel(titleBlock, spacerBlock, secondaryTitleBlock)
            {
                Rect        = new PageRect(0, 0, 258, 40),
                Orientation = FlowPanelOrientation.Horizontal
            };

            var contentBlock = new TextBlock
            {
                Color               = new BandColor(0xff, 0xff, 0xff),
                Font                = TextBlockFont.Medium,
                ElementId           = Common.ContentId,
                Rect                = new PageRect(0, 0, 0, 78),
                AutoWidth           = true,
                Baseline            = 91,
                VerticalAlignment   = Microsoft.Band.Tiles.Pages.VerticalAlignment.Bottom,
                HorizontalAlignment = Microsoft.Band.Tiles.Pages.HorizontalAlignment.Center,
                BaselineAlignment   = TextBlockBaselineAlignment.Absolute
            };

            var bottomFlowPanel = new FlowPanel(contentBlock)
            {
                Rect        = new PageRect(0, 0, 258, 68),
                Orientation = FlowPanelOrientation.Horizontal
            };

            var panel = new FlowPanel(topFlowPanel, bottomFlowPanel)
            {
                Rect = new PageRect(15, 0, 258, 128)
            };

            return(new PageLayout(panel));
        }
Esempio n. 25
0
        private async void Button_Click(object sender, RoutedEventArgs e)
        {
            this.viewModel.StatusMessage = "Running ...";

            try
            {
                // Get the list of Microsoft Bands paired to the phone/tablet/PC.
                IBandInfo[] pairedBands = await BandClientManager.Instance.GetBandsAsync();

                if (pairedBands.Length < 1)
                {
                    this.viewModel.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]))
                {
                    // We'll create a Tile that looks like this:
                    // +--------------------+
                    // | MY CARD            |
                    // | |||||||||||||||||  |
                    // | 123456789          |
                    // +--------------------+

                    // First, we'll prepare the layout for the Tile page described above.
                    TextBlock myCardTextBlock = new TextBlock()
                    {
                        Color     = Colors.Blue.ToBandColor(),
                        ElementId = 1, // the Id of the TextBlock element; we'll use it later to set its text to "MY CARD"
                        Rect      = new PageRect(0, 0, 200, 30)
                    };
                    Barcode barcode = new Barcode(BarcodeType.Code39)
                    {
                        ElementId = 2, // the Id of the Barcode element; we'll use it later to set its barcode value to be rendered
                        Rect      = new PageRect(0, 0, 250, 50)
                    };
                    TextBlock digitsTextBlock = new TextBlock()
                    {
                        ElementId = 3, // the Id of the TextBlock element; we'll use it later to set its text to "123456789"
                        Rect      = new PageRect(0, 0, 200, 30)
                    };
                    FlowPanel panel = new FlowPanel(myCardTextBlock, barcode, digitsTextBlock)
                    {
                        Orientation = FlowPanelOrientation.Vertical,
                        Rect        = new PageRect(0, 0, 250, 110)
                    };

                    // Now we'll create the Tile.
                    // WARNING! This tile guid is only an example. Please do not copy it to your test application;
                    // always create a unique guid for each application.
                    // If one application installs its tile, a second application using the same guid will fail to install
                    // its tile due to a guid conflict. In the event of such a failure, the text of the exception will not
                    // report that the tile with the same guid already exists on the band.
                    // There might be other unexpected behavior.
                    Guid     myTileId = new Guid("B747BD8A-D98C-4ED3-9378-8C2CF98EF0F0");
                    BandTile myTile   = new BandTile(myTileId)
                    {
                        Name      = "My Tile",
                        TileIcon  = await LoadIcon("ms-appx:///Assets/SampleTileIconLarge.png"),
                        SmallIcon = await LoadIcon("ms-appx:///Assets/SampleTileIconSmall.png")
                    };
                    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(myTile.TileId);

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

                    // And create the page with the specified texts and values.
                    PageData page = new PageData(
                        Guid.NewGuid(), // the Id for the page
                        0,              // the index of the layout to be used; we have only one layout in this sample app, but up to 5 layouts can be registered for a Tile
                        new TextBlockData(myCardTextBlock.ElementId.Value, "MY CARD"),
                        new BarcodeData(barcode.BarcodeType, barcode.ElementId.Value, "123456789"),
                        new TextBlockData(digitsTextBlock.ElementId.Value, "123456789"));

                    await bandClient.TileManager.SetPagesAsync(myTile.TileId, page);

                    this.viewModel.StatusMessage = "Done. Check the Tile on your Band (it's the last Tile).";
                }
            }
            catch (Exception ex)
            {
                this.viewModel.StatusMessage = ex.ToString();
            }
        }
        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);
        }
        public static void BuildSingleModuleSettings(Panel buildPanel, object module)
        {
            if (!(module is ModuleManager cModuleMan)) return;

            var moduleText = new Label() {
                Text           = "Manage Modules",
                Location       = new Point(24, 0),
                AutoSizeHeight = true,
                AutoSizeWidth  = true,
                StrokeText     = true,
                Parent         = buildPanel
            };

            var moduleHeader = new Image() {
                Texture  = GameService.Content.GetTexture("358411"),
                Location = new Point(0,   moduleText.Bottom - 6),
                Size     = new Point(875, 110),
                Parent   = buildPanel
            };

            var moduleName = new Label() {
                Text           = cModuleMan.Manifest.Name,
                Font           = GameService.Content.DefaultFont32,
                AutoSizeHeight = true,
                AutoSizeWidth  = true,
                StrokeText     = true,
                Location       = new Point(moduleText.Left, moduleText.Bottom),
                Parent         = buildPanel
            };

            var moduleVersion = new Label() {
                Text              = $"v{cModuleMan.Manifest.Version}",
                Height            = moduleName.Height - 6,
                VerticalAlignment = VerticalAlignment.Bottom,
                AutoSizeWidth     = true,
                StrokeText        = true,
                Font              = GameService.Content.DefaultFont12,
                Location          = new Point(moduleName.Right + 8, moduleName.Top),
                Parent            = buildPanel
            };

            var moduleState = new Label() {
                Text              = cModuleMan.State.Enabled ? "Enabled" : "Disabled",
                Height            = moduleName.Height - 6,
                VerticalAlignment = VerticalAlignment.Bottom,
                AutoSizeWidth     = true,
                StrokeText        = true,
                Font              = GameService.Content.DefaultFont12,
                TextColor         = cModuleMan.State.Enabled ? Color.FromNonPremultiplied(0, 255, 25, 255) : Color.Red,
                Location          = new Point(moduleVersion.Right + 8, moduleName.Top),
                Parent            = buildPanel
            };

            // Author & Contributors
            if (cModuleMan.Manifest.Author != null) {
                // Author
                var authorImage = new Image() {
                    Texture  = GameService.Content.GetTexture("733268"),
                    Location = new Point(moduleName.Left, moduleName.Bottom),
                    Size     = new Point(32,              32),
                    Parent   = buildPanel
                };

                var authorName = new Label() {
                    Text           = cModuleMan.Manifest.Author.Name,
                    Font           = GameService.Content.DefaultFont16,
                    AutoSizeWidth  = true,
                    AutoSizeHeight = true,
                    StrokeText     = true,
                    Parent         = buildPanel
                };

                authorName.Location = new Point(authorImage.Right + 2, authorImage.Bottom - authorName.Height);

                var authoredBy = new Label() {
                    Text              = "Authored by",
                    Height            = authorImage.Height - authorName.Height,
                    AutoSizeWidth     = true,
                    StrokeText        = true,
                    VerticalAlignment = VerticalAlignment.Bottom,
                    Font              = GameService.Content.DefaultFont12,
                    Location          = new Point(authorImage.Right + 2, authorImage.Top),
                    Parent            = buildPanel
                };

            } else if (cModuleMan.Manifest.Contributors.Any()) {
                // TODO: Draw out contributors
            }

            // Enable & disable module

            var enableButton = new StandardButton() {
                Location = new Point(buildPanel.Right - 192, moduleHeader.Top + moduleHeader.Height / 4 - StandardButton.STANDARD_CONTROL_HEIGHT / 2),
                Text     = "Enable Module",
                Enabled  = !cModuleMan.State.Enabled,
                Parent   = buildPanel
            };

            var disableButton = new StandardButton() {
                Location = new Point(buildPanel.Right - 192, enableButton.Bottom + 2),
                Text     = "Disable Module",
                Enabled  = cModuleMan.State.Enabled,
                Parent   = buildPanel
            };

            enableButton.Click += delegate {
                enableButton.Enabled = false;
                disableButton.Enabled = false;

                cModuleMan.Enabled = true;

                moduleState.Text      = "Loading";
                moduleState.TextColor = Control.StandardColors.Yellow;

                cModuleMan.ModuleInstance.ModuleLoaded += delegate {
                    enableButton.Enabled  = !cModuleMan.Enabled;
                    disableButton.Enabled = cModuleMan.Enabled;

                    moduleState.Text      = cModuleMan.State.Enabled ? "Enabled" : "Disabled";
                    moduleState.TextColor = cModuleMan.State.Enabled ? Color.FromNonPremultiplied(0, 255, 25, 255) : Color.Red;
                };
            };

            disableButton.Click += delegate {
                enableButton.Enabled = false;
                disableButton.Enabled = false;

                cModuleMan.Enabled = false;

                enableButton.Enabled  = !cModuleMan.Enabled;
                disableButton.Enabled = cModuleMan.Enabled;

                moduleState.Text      = cModuleMan.State.Enabled ? "Enabled" : "Disabled";
                moduleState.TextColor = cModuleMan.State.Enabled ? Color.FromNonPremultiplied(0, 255, 25, 255) : Color.Red;
            };

            // Settings Menu
            var settingsMenu = new ContextMenuStrip();

            var settingsButton = new GlowButton() {
                Location = new Point(enableButton.Right + 12, enableButton.Top),

                Icon       = GameService.Content.GetTexture(@"common\157109"),
                ActiveIcon = GameService.Content.GetTexture(@"common\157110"),

                BasicTooltipText = "Options",

                Parent = buildPanel
            };

            settingsButton.Click += delegate { settingsMenu.Show(settingsButton); };

            var viewModuleLogs = settingsMenu.AddMenuItem("View Module Logs");

            if (cModuleMan.Manifest.Directories.Any()) {
                var directoriesMenu = settingsMenu.AddMenuItem("Directories");
                var subDirectoriesMenu = new ContextMenuStrip();

                foreach (var directory in cModuleMan.Manifest.Directories) {
                    subDirectoriesMenu.AddMenuItem($"Explore '{directory}'");
                }

                directoriesMenu.Submenu = subDirectoriesMenu;
            }

            var deleteModule = settingsMenu.AddMenuItem("Delete Module");

            // Collapse Sections

            var collapsePanel = new FlowPanel() {
                Size          = new Point(buildPanel.Width, buildPanel.Height - moduleName.Bottom + 32 + 4),
                Location      = new Point(0,                moduleName.Bottom + 32                     + 4),
                CanScroll     = true,
                Parent        = buildPanel
            };

            // Description

            var descriptionPanel = new Panel() {
                Size       = new Point(collapsePanel.ContentRegion.Width, 155),
                CanScroll  = true,
                Location = new Point(0, moduleName.Bottom + 32 + 4),
                Title      = "Description",
                ShowBorder = true,
                Parent     = collapsePanel
            };

            var descriptionLabel = new Label() {
                Text           = cModuleMan.Manifest.Description,
                Location       = new Point(8, 8),
                Width          = descriptionPanel.Width - 16,
                AutoSizeHeight = true,
                WrapText       = true,
                Parent         = descriptionPanel
            };

            // Permissions

            var permissionPanel = new FlowPanel() {
                Size                 = descriptionPanel.Size,
                CanScroll            = true,
                Location             = new Point(0, descriptionPanel.Bottom + Panel.MenuStandard.ControlOffset.Y),
                PadLeftBeforeControl = true,
                PadTopBeforeControl  = true,
                ControlPadding       = new Vector2(10),
                Title                = "Permissions",
                ShowBorder           = true,
                Parent               = collapsePanel
            };

            foreach (var perm in cModuleMan.Manifest.ApiPermissions) {
                var permCheckbox = new Checkbox() {
                    Text   = perm.Key.ToString(),
                    Parent = permissionPanel,
                    Width  = permissionPanel.Width / 3
                };
            }
        }
Esempio n. 28
0
        public async Task TestPutTileBand()
        {
            //Manage connection to the band.
            bool connected = await InitializeBandConnection();

            if (connected == false)
            {
                Message = "Can't connect to Band!";
                return;
            }


            //if reach here , mean we have something to work with.


            // We'll create a Tile that looks like this:
            // +--------------------+
            // | MY CARD            |
            // | |||||||||||||||||  |
            // | 123456789          |
            // +--------------------+

            //Prepare the layout for the Tile page described above
            Microsoft.Band.Tiles.Pages.TextBlock myCardTextBlock = new TextBlock();

            //Initialize the style of the textBlock.

            //Get the Color for the text block.
            myCardTextBlock.Color = Windows.UI.Colors.Cyan.ToBandColor();       //ToBandColor() is a method extension from the Band SDK to conver Windows.UI color to the BandColor.

            //Initialize the ID of the TextBlock element, will be used later to set its text to "My Card"
            myCardTextBlock.ElementId = 1;

            //Rectangle?
            myCardTextBlock.Rect = new PageRect(0, 0, 200, 25);


            //Barcode for the page.
            Barcode barcode = new Barcode(BarcodeType.Code39);

            //set the element id for the barcode.
            barcode.ElementId = 2;

            //Rectangle again?
            barcode.Rect = new PageRect(0, 0, 250, 50);


            //ANother Textblock for the number line.
            TextBlock digitsTextBlock = new TextBlock();

            //Initialize the style of the textblock again.
            digitsTextBlock.ElementId = 3;
            digitsTextBlock.Rect      = new PageRect(0, 0, 200, 25);


            //Create a flow panel.
            //Description from SDK: Arranges its child elements sequentially on the page, either horizontally or vertically
            //The constructors add for a list of items to be added to the flow panel.
            Microsoft.Band.Tiles.Pages.FlowPanel bandTileFlowPanel = new FlowPanel(myCardTextBlock, barcode, digitsTextBlock);

            //Set the orientation of the flow panel to flow vertically.
            bandTileFlowPanel.Orientation = FlowPanelOrientation.Vertical;

            //rect again?
            bandTileFlowPanel.Rect = new PageRect(0, 0, 250, 100);


            //Now we actually create a tile.

            //Get a Globally-Unique ID for the tile.
            Guid myTileID = new Guid("D781F673-6D05-4D69-BCFF-EA7E706C3418");

            //Actual Tile.
            Microsoft.Band.Tiles.BandTile myTile = new BandTile(myTileID);

            //Set the properties.
            myTile.Name = "My Own Tile";

            //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 new page layout from the FlowPanel that we have all of our stuffs in it. (page 36 SDK)
            Microsoft.Band.Tiles.Pages.PageLayout myTilePageLayout = new PageLayout(bandTileFlowPanel);

            //Set the just-created page layout to the tile. (as our tile has only 1 page)
            myTile.PageLayouts.Add(myTilePageLayout);


            //EXTRA:
            //This will remove the previous tile that was on the phone, incase of debugging to start fresh.
            //Remove by ID will be the safest, since every GuID is unique.
            await currentBandClient.TileManager.RemoveTileAsync(myTile.TileId);


            //Tile is completed. Sync that over to phone.
            await currentBandClient.TileManager.AddTileAsync(myTile);


            //If reached here, means the tile was sent correctly.
            //Now update that manually with data.
            //we update stuffs on the band tile with PageData.
            Microsoft.Band.Tiles.Pages.PageData bandCustomPagedata = new PageData(
                Guid.NewGuid(),                                                      // The ID for the page?
                0,                                                                   // The index of the layout/page to be used. We only have 1 layout/page. (Can add up to 5)
                new TextBlockData(myCardTextBlock.ElementId.Value, "Scotty's Card"), //from here and now on, is the data for the controls that we have on the layout/page.
                new BarcodeData(barcode.BarcodeType, barcode.ElementId.Value, "091294"),
                new TextBlockData(digitsTextBlock.ElementId.Value, "091294"));


            //Done creating the custom data, add it over.
            await currentBandClient.TileManager.SetPagesAsync(myTile.TileId, bandCustomPagedata);

            //Echo over to the message bar.
            Message = "Done";
        }
Esempio n. 29
0
        private async void CreateLayout2Button_Click(object sender, EventArgs e)
        {
            if (BandHelper.Instance.BandClient == null)
            {
                await BandHelper.Instance.Connect();
            }

            // We'll create a Tile that looks like this:
            // +--------------------+
            // | MY CARD            |
            // | |||||||||||||||||  |
            // | 123456789          |
            // +--------------------+

            // First, we'll prepare the layout for the Tile page described above.
            TextBlock myCardTextBlock = new TextBlock()
            {
                Color     = new Microsoft.Band.Portable.BandColor(0xFF, 0xFF, 0xFF),
                ElementId = 1, // the Id of the TextBlock element; we'll use it later to set its text to "MY CARD"
                Rect      = new PageRect(0, 0, 200, 25)
            };
            Barcode barcode = new Barcode(BarcodeType.Code39)
            {
                ElementId = 2, // the Id of the Barcode element; we'll use it later to set its barcode value to be rendered
                Rect      = new PageRect(0, 0, 250, 50)
            };
            TextBlock digitsTextBlock = new TextBlock()
            {
                ElementId = 3, // the Id of the TextBlock element; we'll use it later to set its text to "123456789"
                Rect      = new PageRect(0, 0, 200, 25)
            };
            FlowPanel panel = new FlowPanel
            {
                Orientation = FlowPanelOrientation.Vertical,
                Rect        = new PageRect(0, 0, 250, 100),
                Elements    = { myCardTextBlock, barcode, digitsTextBlock }
            };


            var myTile = await BandHelper.CreateTile("Step5 Tile - Layout 2");

            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.

            try
            {
                await BandHelper.Instance.BandClient.TileManager.RemoveTileAsync(myTile.Id);
            }
            catch (Exception exception)
            {
            }
            // Create the Tile on the Band.
            await BandHelper.Instance.BandClient.TileManager.AddTileAsync(myTile);

            // And create the page with the specified texts and values.

            var tbd1 = new TextBlockData
            {
                ElementId = myCardTextBlock.ElementId,
                Text      = "MY CARD"
            };
            var bd = new BarcodeData
            {
                ElementId    = barcode.ElementId,
                BarcodeValue = "123456789"
            };
            var tbd2 = new TextBlockData
            {
                ElementId = digitsTextBlock.ElementId,
                Text      = "123456789"
            };

            PageData page = new PageData
            {
                PageId          = Guid.NewGuid(),
                PageLayoutIndex = 0,
                Data            = { tbd1, bd, tbd2 }
            };


            await BandHelper.Instance.BandClient.TileManager.SetTilePageDataAsync(myTile.Id, page);
        }