public NotebookTab(IUIStyle style) : base(style) { activationRequestedSupport = new EventSupport <EventArgs>(); closeRequestedSupport = new EventSupport <EventArgs>(); emptyContent = new Label(UIStyle) { Anchor = AnchoredRect.CreateHorizontallyStretched() }; closeButton = new Button(UIStyle); closeButton.AddStyleClass(CloseButtonStyleClass); closeButton.Anchor = AnchoredRect.CreateCentered(); closeButton.ActionPerformed += OnCloseButtonOnClicked; InternalContent = new DockPanel(UIStyle); InternalContent.LastChildFill = true; InternalContent.Add(closeButton, DockPanelConstraint.Right); InternalContent.Add(emptyContent, DockPanelConstraint.Left); KeyPressed += OnKeyPressed; MouseClicked += OnMouseClick; Focusable = true; }
IWidget SetupUi() { var styleSystem = uiManager.UIStyle; var mapX = new TextField(styleSystem); mapX.Anchor = AnchoredRect.CreateCentered(100); mapX.Content.Document.DocumentModified += (_, _) => navModel.MapXText = mapX.Text; var mapY = new TextField(styleSystem); mapY.Anchor = AnchoredRect.CreateCentered(100); mapY.Content.Document.DocumentModified += (_, _) => navModel.MapYText = mapY.Text; var button = new Button(styleSystem, "Go!"); button.ActionPerformed += (_, _) => navModel.TryNavigate(GameRendering); navModel.PropertyChanged += (_, _) => button.Enabled = navModel.Valid; var rotateLeftButton = new Button(styleSystem, "Left"); rotateLeftButton.ActionPerformed += (_, _) => GameRendering.RotationSteps = (GameRendering.RotationSteps + 1) % 4; var rotateRightButton = new Button(styleSystem, "Right"); rotateRightButton.ActionPerformed += (_, _) => GameRendering.RotationSteps = (GameRendering.RotationSteps - 1) % 4; var hbox = new BoxGroup(styleSystem, Orientation.Horizontal, 5); hbox.Anchor = AnchoredRect.CreateBottomLeftAnchored(); hbox.AddStyleClass("opaque-root"); hbox.Add(new Label(styleSystem, "Move to: X: ")); hbox.Add(mapX); hbox.Add(new Label(styleSystem, "Y: ")); hbox.Add(mapY); hbox.Add(button); hbox.Add(rotateLeftButton); hbox.Add(rotateRightButton); group = new Group(styleSystem); group.Add(hbox); group.Focusable = true; group.MouseDragged += OnMouseDragged; group.MouseDown += OnMouseDragStarted; group.MouseUp += OnMouseDragFinished; group.KeyReleased += Root_KeyReleased; group.MouseMoved += OnMouseMoved; group.Focused = true; group.Anchor = AnchoredRect.Full; return(group); }
public void MeasureCheckMark() { var style = LayoutTestStyle.Create(); var checkMark = new Button(style) { Anchor = AnchoredRect.CreateCentered() }; style.StyleResolver.AddRoot(checkMark); checkMark.Measure(Size.Auto); checkMark.DesiredSize.Should().Be(new Size(40, 40)); }
public void ArrangeHugeAnchored() { var g = new BoxGroup(LayoutTestStyle.Create()); g.Spacing = 5; g.Orientation = Orientation.Horizontal; g.Add(LayoutTestWidget.FixedSize(2000, 1000).WithAnchorRect(AnchoredRect.CreateCentered(500, 500))); g.Add(LayoutTestWidget.FixedSize(150, 50).WithAnchorRect(AnchoredRect.CreateFull(10))); g.Arrange(new Rectangle(10, 20, 400, 300)); g.DesiredSize.Should().Be(new Size(675, 500)); // 500 + 150 + 20 (from full-anchor) + 5 g[0].DesiredSize.Should().Be(new Size(2000, 1000)); g[1].DesiredSize.Should().Be(new Size(150, 50)); g.LayoutRect.Should().Be(new Rectangle(10, 20, 675, 300)); g[0].LayoutRect.Should().Be(new Rectangle(10, -80, 500, 500)); g[1].LayoutRect.Should().Be(new Rectangle(525, 30, 150, 280)); }
public MainMenu(IUIStyle s, Game1 parent) : base(s) { var lab = new Label(s, "Welcome to the game") { Anchor = AnchoredRect.CreateCentered() }; var play = new Button(s, "Play") { Anchor = AnchoredRect.CreateFixed(0, 0, 100, 60), Color = Color.Aquamarine, OnActionPerformed = (se, a) => { parent.State = Game1.GameState.Playing; } }; this.Add(lab); this.Add(play); }
public CheckBox(IUIStyle style) : base(style) { label = new Label(UIStyle) { Enabled = false }; label.AddStyleClass(CheckBoxLabelStyleClass); checkMark = new Button(UIStyle) { Anchor = AnchoredRect.CreateCentered() }; checkMark.AddStyleClass(CheckBoxButtonStyleClass); checkMark.ActionPerformed += OnActionPerformed; Content = new DockPanel(style) { { checkMark, DockPanelConstraint.Left }, { label, DockPanelConstraint.Left } }; Selected = SelectionState.Selected; }
IWidget CreateContent(IUIStyle style) { var btSelectDungeonDemo = new Button(style, "Dungeon Game Demo"); btSelectDungeonDemo.ActionPerformed += OnDungeonDemoSelected; var btSelectStrategyDemo = new Button(style, "Strategy Game Demo"); btSelectStrategyDemo.ActionPerformed += OnStrategyDemoSelected; var g = new Group(style) { new BoxGroup(style, Orientation.Vertical, 5) { btSelectDungeonDemo, btSelectStrategyDemo } }; g.Anchor = AnchoredRect.CreateCentered(); return(g); }
protected override void Initialize() { base.Initialize(); IsMouseVisible = true; var uiManager = UIManagerComponent.CreateAndInit(this, new InputManager(this), "Content").Manager; var styleSystem = uiManager.UIStyle; var styles = styleSystem.LoadStyles("Content/UI/Metro/style.xml", "UI/Metro", GraphicsDevice); styleSystem.StyleResolver.StyleRules.AddRange(styles); uiManager.Root.Content = new Group(styleSystem) { new Label(styleSystem) { Text = "Hello World", Anchor = AnchoredRect.CreateCentered() } }; this.CenterOnScreen(); }