Ejemplo n.º 1
0
        /// <summary>
        /// Creates a button.
        /// </summary>
        /// <param name="location"></param>
        /// <param name="dimensions">When this parameter is set to null, automatically set the Dimensions to inhertDimesions(this.Textbox)</param>
        /// <param name="text">The text displayed inside the button.</param>
        /// <param name="onClick">Method called when the button is clicked.</param>
        /// <param name="hoverColor">Color that is drawn over the background of the Button.</param>
        /// <param name="textFont">Font the textbox uses.</param>
        public Button(Location location, Dimensions dimensions, string text, OnClickEventHandler onClick = null, int?edgeThickness = null, Color?hoverColor = null, string textFont = null) : base(location, dimensions)
        {
            hoveringOverlay = new Background(Utility.SolidWhiteTexture, hoverColor ?? Utility.DrawingColorToXNAColor(DefaultUIValues.Default.ButtonHoverColor));

            textBox = new Textbox(CenteredLocation.All, null, text);
            hoveringOverlay.Visible = false;

            edgeTexture = new EdgeTexture(edgeThickness, Utility.DrawingColorToXNAColor(DefaultUIValues.Default.ButtonEdgeColor));

            if (dimensions == null)
            {
                Dimensions = new MeasuredDimensions(textBox, 2 * DefaultUIValues.Default.EdgeThickness, 2 * DefaultUIValues.Default.EdgeThickness);
            }

            Click += (UIComponent component) =>
            {
                GameEnvironment.AssetManager.PlaySound(DefaultUIValues.Default.ButtonSound);
            };

            if (onClick != null)
            {
                Click += onClick;
            }

            AddConstantComponent(hoveringOverlay);
            AddConstantComponent(textBox);
            AddConstantComponent(edgeTexture);
        }
Ejemplo n.º 2
0
 public TextureButton(Location location, Dimensions dimensions, string text, Texture2D texture = null, Color?color = null, OnClickEventHandler onClick = null, int?edgeThickness = null, Color?hoverColor = null, string textFont = null) : base(location, dimensions, text, onClick, edgeThickness, hoverColor, textFont)
 {
     background        = new Background(texture, color);
     background.Parent = this;
     ConstantComponents.Insert(0, background);
 }
Ejemplo n.º 3
0
        public RadioButton(Location location, string text = "", List <RadioButton> radioGroup = null, OnClickEventHandler onClick = null) : base(location, null)
        {
            Dimensions = WrapperDimensions.All;

            RadioGroup = radioGroup;

            button = new Button(SimpleLocation.Zero, new SimpleDimensions(DefaultUIValues.Default.RadioButtonDimen, DefaultUIValues.Default.RadioButtonDimen), "");

            textbox = new Textbox(new SimpleLocation(DefaultUIValues.Default.RadioButtonDimen + distance, 0), null, text, DefaultUIValues.Default.DefaultEditorControlSpriteFont, Color.Black);

            AddConstantComponent(button);
            AddConstantComponent(textbox);
        }
Ejemplo n.º 4
0
 public SpriteSheetButton(Location location, Dimensions dimensions, string text, OnClickEventHandler onClick = null, int?edgeThickness = null, string[] backgroundNames = null, Color?hoverColor = null, string textFont = null, bool tiled = true) : base(location, dimensions, text, onClick, edgeThickness, hoverColor, textFont)
 {
     background        = new UISpriteSheet(SimpleLocation.Zero, InheritDimensions.All, tiled: tiled);
     background.Parent = this;
     background.AddSpritesheets(backgroundNames ?? new string[] { DefaultUIValues.Default.DefaultButtonBackground });
     ConstantComponents.Insert(0, background);
 }