public Scrollbar(ScrollbarStyle Style, Axis Direction) { this._Style = Style; this._Direction = Direction; if (Direction == Axis.Horizontal) { this._TopLeftButton = new Button(Style.LeftButtonStyle); this._BottomRightButton = new Button(Style.RightButtonStyle); } else { this._TopLeftButton = new Button(Style.UpButtonStyle); this._BottomRightButton = new Button(Style.DownButtonStyle); } this._TopLeftButton.Click += delegate { this.Value = this._Value - this._MinorIncrement; }; this._BottomRightButton.Click += delegate { this.Value = this._Value + this._MinorIncrement; }; this._Value = 0.0; this._SliderSize = 0.1; this._MinorIncrement = 0.1; this._MajorIncrement = 0.3; this._Enabled = true; }
/// <summary> /// Shows a messagebox with the specified options. /// </summary> public static void Show(LayerContainer LayerContainer, MessageBoxOptions Options) { MessageBoxStyle style = Options.Style; // Message Label message = new Label(Options.Message, style.MessageColor, style.MessageLabelStyle); ClickHandler anyclick = null; // Buttons FlowContainer buttonflow = new FlowContainer(style.ButtonSeperation, Axis.Horizontal); ButtonStyle bstyle = style.ButtonStyle; foreach (MessageBoxOptions._Button b in Options._Buttons) { string name = b.Name; Label label = new Label(name, bstyle.TextColor, bstyle.TextStyle); Button button = new Button(bstyle); button.Client = label; button.Click += b.Click; button.Click += delegate { anyclick(); }; buttonflow.AddChild(button, button.GetFullSize(label.SuggestSize).X); } // Main flow container FlowContainer mainflow = new FlowContainer(style.MessageButtonSeperation, Axis.Vertical); mainflow.AddChild(message, message.GetHeight(style.ContentWidth)); mainflow.AddChild(buttonflow.WithCenterAlign(new Point(buttonflow.SuggestLength, style.ButtonHeight)), style.ButtonHeight); // Margin and border MarginContainer margin = mainflow.WithMargin(style.Margin); Point finalsize = margin.GetSize(new Point(style.ContentWidth, mainflow.SuggestLength)); Control final = margin; if (style.BorderSize > 0.0) { double bs = style.BorderSize; final = final.WithBorder(style.BorderColor, bs, bs, bs, bs); finalsize += new Point(bs, bs) * 2.0; } // Form (finally) Form form = new Form(final, Options.Title); form.ClientSize = finalsize; LayerContainer.AddControl(form, LayerContainer.Size * 0.5 - form.Size * 0.5); // Make it modal ModalOptions mo = new ModalOptions() { Lightbox = true, LowestModal = form, MouseFallthrough = false }; LayerContainer.Modal = mo; // Create destruction procedure. anyclick = delegate { LayerContainer.Modal = null; form.Dismiss(); }; }
/// <summary> /// Adds a button the the right of the titlebar of the form. Buttons will have no text on them and will be distinguishable only by style. /// </summary> public Button AddTitlebarButton(ButtonStyle Style, Control Client) { Button b = new Button(Style); if (Client != null) { b.Client = Client; } this.AddTitlebarItem(b, this._Style.TitleBarButtonWidth); return b; }
/// <summary> /// Creates a function that displays the selection to the user. /// </summary> public Action<GUIControlContext> Display(GameBoardView BoardView) { return delegate(GUIControlContext Context) { LayerContainer lc; Point offset; if (Context.FindAncestor<LayerContainer>(out lc, out offset)) { FlowContainer options = new FlowContainer(20.0, Axis.Horizontal); Pane pane = new Pane(new SunkenContainer(options.WithMargin(20.0)).WithBorder(1.0)); ModalOptions mo = new ModalOptions() { Lightbox = false, LowestModal = pane, MouseFallthrough = false }; foreach (_Possible p in this._Items) { _Possible ip = p; Button button = new Button(ButtonStyle.CreateSolid(Skin.Default), new _PieceIcon(p.Move.NewState).CreateControl()); options.AddChild(button, 150.0); button.Click += delegate { lc.Modal = null; pane.Dismiss(); BoardView.MakeMove(ip.Move, ip.Board); }; } pane.ClientSize = new Point(options.SuggestLength + 42.0, 190.0); Rectangle merect = new Rectangle(offset, Context.Control.Size); lc.AddControl(pane, merect.Location + merect.Size * 0.5 - pane.Size * 0.5); lc.Modal = mo; } }; }