mirror of
https://github.com/AlexMacocian/MonoGame.Extended.git
synced 2026-07-24 12:06:37 +00:00
e962cec448
* mostly restored the tiled importer unit tests * code cleanup * code cleanup * almost got tiled maps serialization independent of the content pipeline * refactored the tiled map content importer so that tiled maps can be loaded at runtime * code cleanup * removed nuspec files * experimenting with an XML based GUI markup parser * a few more markup parser features * finally got a working open file dialog * experimenting with markup bindings * attached properties * working on the gui stuff again * working on a better textbox * multiline textboxing * new text box is really coming along * removed the content explorer experiment * restored the old gui demo back to the way it was before (for now)
65 lines
1.8 KiB
C#
65 lines
1.8 KiB
C#
using Microsoft.Xna.Framework;
|
|
|
|
namespace MonoGame.Extended.Gui.Controls
|
|
{
|
|
public class CheckBox : CompositeControl
|
|
{
|
|
public CheckBox()
|
|
{
|
|
_contentLabel = new Label();
|
|
_checkLabel = new Box {Width = 20, Height = 20};
|
|
|
|
_toggleButton = new ToggleButton
|
|
{
|
|
Margin = 0,
|
|
Padding = 0,
|
|
BackgroundColor = Color.Transparent,
|
|
BorderThickness = 0,
|
|
HoverStyle = null,
|
|
CheckedStyle = null,
|
|
PressedStyle = null,
|
|
Content = new StackPanel
|
|
{
|
|
Margin = 0,
|
|
Orientation = Orientation.Horizontal,
|
|
Items =
|
|
{
|
|
_checkLabel,
|
|
_contentLabel
|
|
}
|
|
}
|
|
};
|
|
|
|
_toggleButton.CheckedStateChanged += (sender, args) => OnIsCheckedChanged();
|
|
Template = _toggleButton;
|
|
OnIsCheckedChanged();
|
|
}
|
|
|
|
private readonly Label _contentLabel;
|
|
private readonly ToggleButton _toggleButton;
|
|
private readonly Box _checkLabel;
|
|
|
|
protected override Control Template { get; }
|
|
|
|
public override object Content
|
|
{
|
|
get => _contentLabel.Content;
|
|
set => _contentLabel.Content = value;
|
|
}
|
|
|
|
public bool IsChecked
|
|
{
|
|
get => _toggleButton.IsChecked;
|
|
set
|
|
{
|
|
_toggleButton.IsChecked = value;
|
|
OnIsCheckedChanged();
|
|
}
|
|
}
|
|
|
|
private void OnIsCheckedChanged()
|
|
{
|
|
_checkLabel.FillColor = IsChecked ? Color.White : Color.Transparent;
|
|
}
|
|
}
|
|
} |