/// <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> /// Shows a messagebox with the OK and cancel options. Action is only performed on OK. /// </summary> public static void ShowOKCancel(LayerContainer Container, string Title, string Message, ClickHandler OnOKClick, MessageBoxStyle Style) { MessageBoxOptions mbo = new MessageBoxOptions(); mbo.AddButton("OK", OnOKClick); mbo.AddButton("Cancel", null); mbo.Title = Title; mbo.Message = Message; mbo.Style = Style; Show(Container, mbo); }