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; }
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; }
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; }
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; }
protected virtual void OnInvalidated(UIControl control) { ItemInvalidated handler = Invalidated; if (handler != null) handler(control); }
public static object From(UIControl control, SpriteFont font) { return From(control, font, UIViewStyle.Default); }
public TreeNode(UIControl content) { Content = content; }
private void UpdateVisual(UIControl control) { Position = _control.Position + _control.Margin.TopLeft; Size = _control.Size; DrawMode = _control.DrawMode; }