Exemplo n.º 1
0
        public override void LoadContent(IScreen screen)
        {
            Background.LoadContent(screen);

            DropButton = new RelativeLayoutButton()
            {
                Size             = new Vector2(Rect.Height, Rect.Height),
                Horizontal       = HorizontalAlignment.Right,
                Vertical         = VerticalAlignment.Center,
                Highlightable    = true,
                TransitionObject = this.TransitionObject,
            };
            DropButton.OnClick += CreateDropdownList;

            var dropImage = new Image()
            {
                Texture          = Screen.Content.Load <Texture2D>(StyleSheet.DropdownImageResource),
                Size             = new Vector2(Rect.Height, Rect.Height) * 0.75f,
                Horizontal       = HorizontalAlignment.Right,
                Vertical         = VerticalAlignment.Center,
                FillRect         = true,
                TransitionObject = this.TransitionObject,
            };

            DropButton.AddItem(dropImage);
            AddItem(DropButton);

            base.LoadContent(screen);
        }
Exemplo n.º 2
0
        /// <summary>
        /// This method gets called when the parent node is expanded
        /// </summary>
        public void AddToTree(IScreen screen)
        {
            Items.Clear();

            SetScreen(screen);

            Expanded = false;

            //get the size of the brick to add for tabs
            var tab = new Vector2(ItemButton.Rect.Height, ItemButton.Rect.Height) * .5f;

            //Add a brick for each tab
            for (int i = 0; i < _indentation; i++)
            {
                AddItem(new Shim()
                {
                    Size       = tab,
                    Horizontal = HorizontalAlignment.Left,
                    Vertical   = VerticalAlignment.Center,
                });
            }

            //if there are any sub-items, need to add the expand/collapse button
            if (ChildItems.Count > 0)
            {
                //add the expansion button
                ExpandCollapseImage = new Image()
                {
                    Texture    = _expandTexture,
                    Size       = tab,
                    Horizontal = HorizontalAlignment.Center,
                    Vertical   = VerticalAlignment.Center,
                    FillRect   = true,
                };

                //create a stack layout to size teh button correctly
                var expandButton = new RelativeLayoutButton()
                {
                    Size       = tab * 2f,
                    Horizontal = HorizontalAlignment.Center,
                    Vertical   = VerticalAlignment.Center,
                };
                expandButton.AddItem(ExpandCollapseImage);
                expandButton.OnClick += ToggleExpansion;

                AddItem(expandButton);
            }
            else
            {
                AddItem(new Shim()
                {
                    Size = tab * 2f,
                });
            }

            //add that final button
            AddItem(ItemButton);
        }
Exemplo n.º 3
0
        private IButton CreateButton(bool okButton)
        {
            //Create the menu entry "Cancel"
            var label = new Label(okButton ? OkText : CancelText, Content, FontSize.Small)
            {
                Horizontal = HorizontalAlignment.Center,
                Vertical   = VerticalAlignment.Center,
                Layer      = 1,
            };

            //check if there is a background image for this button
            var backgrounImage     = okButton ? StyleSheet.MessageBoxOkImageResource : StyleSheet.MessageBoxCancelImageResource;
            var hasBackgroundImage = !string.IsNullOrEmpty(backgrounImage);

            //Create the menu entry for "OK"
            var button = new RelativeLayoutButton()
            {
                HasBackground = !hasBackgroundImage,
                Horizontal    = HorizontalAlignment.Center,
                Vertical      = VerticalAlignment.Top,
                Size          = new Vector2(Resolution.TitleSafeArea.Width * 0.4f - 16, label.Rect.Height * 2f)
            };

            button.AddItem(label);

            if (hasBackgroundImage)
            {
                button.AddItem(new Image(Content.Load <Texture2D>(backgrounImage))
                {
                    Horizontal         = HorizontalAlignment.Center,
                    Vertical           = VerticalAlignment.Center,
                    Size               = button.Rect.Size.ToVector2(),
                    Highlightable      = false,
                    PulsateOnHighlight = false,
                    FillRect           = true,
                    Layer              = 0
                });
            }

            button.LoadContent(this);
            return(button);
        }