public IncreaseDecreaseButton() : base() { incr = new TextButton("+") { StaysPressed = true }; incr.Click += (b) => { Value++; }; decr = new TextButton("-") { StaysPressed = true }; decr.Click += (b) => { Value--; }; }
/// <summary> /// Creates a new instance of the <see cref="TAPI.SDK.GUI.MessageBox"/> class. /// </summary> /// <param name="text">The text the message box contains</param> /// <param name="caption">The caption of the message box</param> /// <param name="btn">The button type of the message box</param> public MessageBox(string text, string caption, MessageBoxButton btn) : base(caption) { IsDrawnAfter = true; OnClosed += (w) => { Result(this, null); }; TextBlock t = new TextBlock(text); AddControl(t); if (TextIsCopyable) OnUpdate += (c) => { if (GInput.Mouse.Rectangle.Intersects(Hitbox) && GInput.Mouse.Left) Clipboard.SetText(t.Text); }; switch (btn) { case MessageBoxButton.OK: { TextButton ok = new TextButton("OK"); ok.Click += (b) => { Result(this, true); }; ok.Position = new Vector2(0f, t.Hitbox.Height); AddControl(ok); } break; case MessageBoxButton.YesNo: { TextButton y = new TextButton("Yes"); y.Click += (b) => { Result(this, true); }; y.Position = new Vector2(0f, t.Hitbox.Height + 16f); AddControl(y); TextButton n = new TextButton("No"); n.Click += (b) => { Result(this, false); }; n.Position = new Vector2(0f, t.Hitbox.Height + y.Hitbox.Height + 16f); AddControl(n); } break; } }