Exemplo n.º 1
0
 protected ContentControl(GuiSystem guiSystem, XmlElement element) : base(guiSystem, element)
 {
     if (element.HasChildNodes)
     {
         Child = CreateFromXmlType(guiSystem, (XmlElement)element.FirstChild);
     }
 }
Exemplo n.º 2
0
        private void InitializeDrawElements(GuiSystem guiSystem)
        {
            var itemDescriptor = guiSystem.GetSkinItemDescriptor <ButtonSkinItemDescriptor>();

            _normalSprite = new NinePatchSprite(itemDescriptor.SkinTexture, itemDescriptor.NormalRectangle, itemDescriptor.ButtonBorder);
            _hoverSprite  = new NinePatchSprite(itemDescriptor.SkinTexture, itemDescriptor.HoverRectangle, itemDescriptor.ButtonBorder);
        }
Exemplo n.º 3
0
        private void InitializeDrawElements(GuiSystem guiSystem)
        {
            var itemDescriptor = guiSystem.GetSkinItemDescriptor <FrameSkinItemDescriptor>();

            _headerFont    = itemDescriptor.BigFont;
            _contentBorder = new NinePatchSprite(itemDescriptor.SkinTexture, itemDescriptor.SourceRectangle, itemDescriptor.FrameBorder);
            _headerBorder  = new NinePatchSprite(itemDescriptor.SkinTexture, itemDescriptor.SourceRectangle, itemDescriptor.FrameBorder);
        }
Exemplo n.º 4
0
 protected GuiElement(GuiSystem guiSystem)
     : base(guiSystem.Game)
 {
     GuiSystem           = guiSystem;
     Children            = new List <GuiElement>();
     HorizontalAlignment = HorizontalAlignment.Center;
     VerticalAlignment   = VerticalAlignment.Middle;
     IsActive            = true;
 }
Exemplo n.º 5
0
        private void InitializeDrawElements()
        {
            var descriptor = GuiSystem.GetSkinItemDescriptor <TextBlockSkinItemDescriptor>();

            _spriteText = new SpriteText(descriptor.NormalFont);

            _spriteText.HorizontalAlignment = HorizontalAlignment;
            _spriteText.VerticalAlignment   = VerticalAlignment;
        }
Exemplo n.º 6
0
 public TextBlock(GuiSystem guiSystem, XmlElement element)
     : base(guiSystem, element)
 {
     InitializeDrawElements();
     if (element.HasAttribute("Text"))
     {
         Text = element.GetAttribute("Text");
     }
 }
Exemplo n.º 7
0
        public Frame(GuiSystem guiSystem, XmlElement element)
            : base(guiSystem, element)
        {
            InitializeDrawElements(guiSystem);

            if (element.HasAttribute("Title"))
            {
                Title = element.GetAttribute("Title");
            }
        }
Exemplo n.º 8
0
        public Image(GuiSystem guiSystem, XmlElement element)
            : base(guiSystem, element)
        {
            if (element.HasAttribute("Source"))
            {
                Texture = guiSystem.Game.Content.Load <Texture2D>("Textures/" + element.GetAttribute("Source"));
            }

            if (Texture != null)
            {
                SourceRectangle = element.HasAttribute("NormalRectangle") ? element.GetAttribute("NormalRectangle").ParseRectangle() : Texture.Bounds;
            }
        }
Exemplo n.º 9
0
        public ScrollViewer(GuiSystem guiSystem, XmlElement element) : base(guiSystem, element)
        {
            if (element.HasAttribute("CanScrollHorizontally"))
            {
                CanScrollHorizontally = Boolean.Parse(element.GetAttribute("CanScrollHorizontally"));
            }
            if (element.HasAttribute("CanScrollVertically"))
            {
                CanScrollVertically = Boolean.Parse(element.GetAttribute("CanScrollVertically"));
            }

            InitializeDrawElements();
        }
Exemplo n.º 10
0
        public StackPanel(GuiSystem guiSystem, XmlElement element)
            : base(guiSystem, element)
        {
            if (element.HasAttribute("Orientation"))
            {
                Orientation = (Orientation)Enum.Parse(typeof(Orientation), element.GetAttribute("Orientation"));
            }

            foreach (XmlElement childElement in element.ChildNodes)
            {
                AddChild(CreateFromXmlType(guiSystem, childElement));
            }
        }
Exemplo n.º 11
0
        private void InitializeDrawElements()
        {
            var itemDescriptor = GuiSystem.GetSkinItemDescriptor <TextBoxSkinItemDescriptor>();

            _border = new NinePatchSprite(itemDescriptor.SkinTexture, itemDescriptor.NormalRectangle, itemDescriptor.Border);

            _spriteText = new SpriteText(itemDescriptor.NormalFont);
            _spriteText.HorizontalAlignment = HorizontalAlignment.Left;

            _cursorAnimatorTimer = new ActionTimer(OnCursorAnimateTick, 0.5f, true);
            _cursorAnimatorTimer.Start();

            _inputController = new StringInputController(InputType.AlphaNumeric);
        }
Exemplo n.º 12
0
        public Grid(GuiSystem guiSystem, XmlElement element)
            : base(guiSystem, element)
        {
            var columnDefinitionNodes = element.SelectNodes("Grid.ColumnDefinitions/ColumnDefinition");
            var rowDefinitionNodes    = element.SelectNodes("Grid.RowDefinitions/RowDefinition");

            if (columnDefinitionNodes == null || columnDefinitionNodes.Count == 0)
            {
                _columnDefinitions.Add(new GridItemDefinition(GridItemDefinition.MaxSize, 0));
            }
            else
            {
                var index = 0;
                foreach (XmlElement columnElement in columnDefinitionNodes)
                {
                    _columnDefinitions.Add(new GridItemDefinition("Width", index++, columnElement));
                }
            }

            if (rowDefinitionNodes == null || rowDefinitionNodes.Count == 0)
            {
                _rowDefinitions.Add(new GridItemDefinition(GridItemDefinition.MaxSize, 0));
            }
            else
            {
                var index = 0;
                foreach (XmlElement columnElement in rowDefinitionNodes)
                {
                    _rowDefinitions.Add(new GridItemDefinition("Height", index++, columnElement));
                }
            }

            foreach (XmlElement childElement in element.ChildNodes)
            {
                if (childElement.LocalName == "Grid.ColumnDefinitions")
                {
                    continue;
                }
                if (childElement.LocalName == "Grid.RowDefinitions")
                {
                    continue;
                }

                var gridRow         = Math.Min(_rowDefinitions.Count - 1, int.Parse(childElement.GetAttribute("Grid.Row")));
                var gridColumn      = Math.Min(_columnDefinitions.Count - 1, int.Parse(childElement.GetAttribute("Grid.Column")));
                var childGuiElement = CreateFromXmlType(GuiSystem, childElement);

                AddChild(gridColumn, gridRow, childGuiElement);
            }
        }
Exemplo n.º 13
0
        public TextBox(GuiSystem guiSystem, XmlElement element)
            : base(guiSystem, element)
        {
            InitializeDrawElements();

            if (element.HasAttribute("InputType"))
            {
                InputType = (InputType)Enum.Parse(typeof(InputType), element.GetAttribute("InputType"));
            }

            if (element.HasAttribute("MaxInputCharacters"))
            {
                MaxInputCharacters = int.Parse(element.GetAttribute("MaxInputCharacters"));
            }

            if (element.HasAttribute("Text"))
            {
                Text = element.GetAttribute("Text");
            }
        }
Exemplo n.º 14
0
        protected GuiElement(GuiSystem guiSystem, XmlElement element)
            : base(guiSystem.Game)
        {
            GuiSystem           = guiSystem;
            Children            = new List <GuiElement>();
            HorizontalAlignment = HorizontalAlignment.Center;
            VerticalAlignment   = VerticalAlignment.Middle;
            IsActive            = true;

            if (element.HasAttribute("Width"))
            {
                Width = int.Parse(element.GetAttribute("Width"));
            }
            if (element.HasAttribute("Height"))
            {
                Height = int.Parse(element.GetAttribute("Height"));
            }
            if (element.HasAttribute("Margin"))
            {
                Margin = Thickness.Parse(element.GetAttribute("Margin"));
            }
            if (element.HasAttribute("Id"))
            {
                Id = element.GetAttribute("Id");
            }
            if (element.HasAttribute("HorizontalAlignment"))
            {
                HorizontalAlignment =
                    (HorizontalAlignment)
                    Enum.Parse(typeof(HorizontalAlignment), element.GetAttribute("HorizontalAlignment"));
            }

            if (element.HasAttribute("VerticalAlignment"))
            {
                VerticalAlignment =
                    (VerticalAlignment)
                    Enum.Parse(typeof(VerticalAlignment), element.GetAttribute("VerticalAlignment"));
            }
        }
Exemplo n.º 15
0
        public static GuiElement CreateFromXmlType(GuiSystem guiSystem, XmlElement element)
        {
            switch (element.LocalName)
            {
            case "Frame": return(new Frame(guiSystem, element));

            case "TextBlock": return(new TextBlock(guiSystem, element));

            case "StackPanel": return(new StackPanel(guiSystem, element));

            case "Image": return(new Image(guiSystem, element));

            case "Grid": return(new Grid(guiSystem, element));

            case "Button": return(new Button(guiSystem, element));

            case "TextBox": return(new TextBox(guiSystem, element));

            case "ScrollViewer": return(new ScrollViewer(guiSystem, element));
            }

            throw new ArgumentException("Invalid Element Type", "element");
        }
Exemplo n.º 16
0
 public ScrollViewer(GuiSystem guiSystem) : base(guiSystem)
 {
     InitializeDrawElements();
 }
Exemplo n.º 17
0
 protected ContentControl(GuiSystem guiSystem) : base(guiSystem)
 {
 }
Exemplo n.º 18
0
 public Button(GuiSystem guiSystem, XmlElement element) : base(guiSystem, element)
 {
     InitializeDrawElements(guiSystem);
 }
Exemplo n.º 19
0
 public Button(GuiSystem guiSystem) : base(guiSystem)
 {
     InitializeDrawElements(guiSystem);
 }
Exemplo n.º 20
0
 public Frame(GuiSystem guiSystem)
     : base(guiSystem)
 {
 }
Exemplo n.º 21
0
 public StackPanel(GuiSystem guiSystem)
     : base(guiSystem)
 {
 }
Exemplo n.º 22
0
 public Grid(GuiSystem guiSystem)
     : base(guiSystem)
 {
 }
Exemplo n.º 23
0
 public Image(GuiSystem guiSystem)
     : base(guiSystem)
 {
 }
Exemplo n.º 24
0
 public TextBox(GuiSystem guiSystem) : base(guiSystem)
 {
     InitializeDrawElements();
 }