Exemple #1
0
 private void UpdateVisual(UIControl control)
 {
     Position = _control.Position + _control.Margin.TopLeft;
     Size = _control.Size;
     DrawMode = _control.DrawMode;
     _sprite.HorizontalAlignment = _control.HorizontalAlignment;
     _sprite.VerticalAlignment = _control.VerticalAlignment;
 }
Exemple #2
0
        public static object From(UIControl control, SpriteFont font, UIViewStyle style)
        {
            var button = control as Button;
            if (button != null)
            {
                return new TextButtonView(button, font) { Style = style };
            }

            var cb = control as ToggleButton;
            if (cb != null)
            {
                return new CheckBoxView(cb) { Style = style };
            }

            var slider = control as Slider;
            if (slider != null)
            {
                return new GaugeView(slider);
            }

            var label = control as Label;
            if (label != null)
            {
                return new LabelView(label) { Style = style };
            }

            var container = control as UIContainer;
            if (container != null)
            {
                var node = new Node { new BackgroundView(container) { Style = style } };

                foreach (var child in container)
                {
                    node.Add(From(child, font, style));
                }

                return node;
            }

            return null;
        }
Exemple #3
0
        protected override Vector2 GetItemPosition(UIControl control)
        {
            var p = new Vector2(
                Size.Width * control.Anchor.X,
                Size.Height * control.Anchor.Y);

            switch (control.HorizontalAlignment)
            {
                case HorizontalAlignment.None:
                    p.X += Padding.Left;
                    break;
                case HorizontalAlignment.Left:
                    p.X += Padding.Left;
                    break;
                case HorizontalAlignment.Center:
                    p.X -= Padding.Left + control.Size.Width / 2;
                    break;
                case HorizontalAlignment.Right:
                    p.X -= Padding.Left + control.Size.Width;
                    break;
            }

            switch (control.VerticalAlignment)
            {
                case VerticalAlignment.None:
                    p.Y += Padding.Top;
                    break;
                case VerticalAlignment.Top:
                    p.Y += Padding.Top;
                    break;
                case VerticalAlignment.Center:
                    p.Y -= Padding.Top + control.Size.Height / 2;
                    break;
                case VerticalAlignment.Bottom:
                    p.Y -= Padding.Top + control.Size.Height;
                    break;
            }

            return p;
        }
Exemple #4
0
        protected override Vector2 GetItemPosition(UIControl control)
        {
            var p = Position + Padding.TopLeft;

            foreach (var current in Controls)
            {
                if (current == control)
                    return p;

                switch (Orientation)
                {
                    case Orientation.Horizontal:
                        p.X += current.Size.Width + Spacing;
                        break;
                    case Orientation.Vertical:
                        p.Y += current.Size.Height + Spacing;
                        break;
                }
            }

            return p;
        }
Exemple #5
0
 protected virtual void OnInvalidated(UIControl control)
 {
     ItemInvalidated handler = Invalidated;
     if (handler != null) handler(control);
 }
Exemple #6
0
 public static object From(UIControl control, SpriteFont font)
 {
     return From(control, font, UIViewStyle.Default);
 }
Exemple #7
0
 public TreeNode(UIControl content)
 {
     Content = content;
 }
Exemple #8
0
 private void UpdateVisual(UIControl control)
 {
     Position = _control.Position + _control.Margin.TopLeft;
     Size = _control.Size;
     DrawMode = _control.DrawMode;
 }