/// <summary> /// The draw label. /// </summary> /// <param name="context"> /// The context. /// </param> /// <param name="layout"> /// The layout. /// </param> /// <param name="label"> /// The label. /// </param> public void DrawLabel(IRenderContext context, Rectangle layout, Label label) { this.m_RenderUtilities.RenderText( context, new Vector2(layout.Center.X, layout.Center.Y), label.Text, this.m_AssetManager.Get<FontAsset>("font.Default"), HorizontalAlignment.Center, VerticalAlignment.Center, label.OverrideColor); }
public IContainer Process(XmlNode node, Action<UserInterfaceBehaviourEvent, object> eventCallback, out Action<XmlNode, IContainer> processChild) { var label = new Label(); label.Text = node?.Attributes?["text"]?.Value ?? string.Empty; var fontName = node?.Attributes?["font"]?.Value; if (!string.IsNullOrWhiteSpace(fontName)) { label.Font = _assetManager.TryGet<FontAsset>(fontName); } var textColorRaw = node?.Attributes?["color"]?.Value; if (!string.IsNullOrWhiteSpace(textColorRaw)) { var textColor = _nodeColorParser.Parse(textColorRaw); if (textColor != null) { label.TextColor = textColor.Value; } } var shadowEnabled = node?.Attributes?["shadowEnabled"]?.Value; if (shadowEnabled == "false") { label.RenderShadow = false; } else if (shadowEnabled == "true") { label.RenderShadow = true; } var shadowColorRaw = node?.Attributes?["shadowColor"]?.Value; if (!string.IsNullOrWhiteSpace(shadowColorRaw)) { var shadowColor = _nodeColorParser.Parse(textColorRaw); if (shadowColor != null) { label.ShadowColor = shadowColor.Value; } } switch (node?.Attributes?["halign"]?.Value) { case "left": label.HorizontalAlignment = HorizontalAlignment.Left; break; case "center": label.HorizontalAlignment = HorizontalAlignment.Center; break; case "right": label.HorizontalAlignment = HorizontalAlignment.Right; break; } switch (node?.Attributes?["valign"]?.Value) { case "top": label.VerticalAlignment = VerticalAlignment.Top; break; case "center": label.VerticalAlignment = VerticalAlignment.Center; break; case "bottom": label.VerticalAlignment = VerticalAlignment.Bottom; break; } processChild = (xmlNode, container) => { throw new InvalidDataException("The '" + xmlNode.LocalName + "' control can not have any children."); }; return label; }
public void PromptForCreation(string createType, EventHandler submit) { this.PromptName = new TextBox(); var label = new Label(); label.Text = "Enter the name of the new " + createType + ":"; var form = new Form(); form.AddControl("Name: ", this.PromptName); var submitButton = new Button(); submitButton.Text = "Create"; submitButton.Click += (sender, e) => { submit(sender, e); this.m_CanvasEntity.Windows.Remove(this.PromptWindow); this.PromptWindow = null; this.PromptName = null; }; var cancelButton = new Button(); cancelButton.Text = "Cancel"; cancelButton.Click += (sender, e) => { this.m_CanvasEntity.Windows.Remove(this.PromptWindow); this.PromptWindow = null; this.PromptName = null; }; var horizontalContainer = new HorizontalContainer(); horizontalContainer.AddChild(submitButton, "50%"); horizontalContainer.AddChild(cancelButton, "50%"); var verticalContainer = new VerticalContainer(); verticalContainer.AddChild(label, "24"); verticalContainer.AddChild(form, "*"); verticalContainer.AddChild(horizontalContainer, "24"); this.PromptWindow = new Window(); this.PromptWindow.Modal = true; this.PromptWindow.Bounds = new Microsoft.Xna.Framework.Rectangle( (int)this.m_CanvasEntity.Width / 2 - 150, (int)this.m_CanvasEntity.Height / 2 - 75, 300, 150); this.PromptWindow.SetChild(verticalContainer); this.m_CanvasEntity.Windows.Add(this.PromptWindow); this.MainMenu.Active = false; foreach (var item in this.MainMenu.Children.Cast<MenuItem>()) item.Active = false; }
public void DrawLabel(IRenderContext context, Rectangle layout, Label label) { this.m_BasicSkin.DrawLabel(context, layout, label); }