/// <summary> /// shows a standard error msg with no responce handling and one ok button /// </summary> /// <param name="title">The Title</param> /// <param name="description">the description</param> public void ShowErrorDialog(string title, string description) { Componates.Clear(); //remove old componates bntFunctions.Clear(); Title = title; //set the title wlText = new WinLable(new Rectangle(50, 50, 0, 0), this) //add the descrition to the lable { Text = description, }; float buttonSpacing = 150 - 45; //calculate spacing between buttons bntFunctions.Add(new Button(new Rectangle((int)(50 + buttonSpacing), 200, 90, 50), this) //add all buttons { Text = "Ok", CloseParent = true, }); Componates.Add(wlText); //add the label for (int i = 0; i < bntFunctions.Count; i++) { Componates.Add(bntFunctions[i]); //add the buttons } this.Activate(true); }
public DialogBox(Action <object> sender, string title, string description, List <string> buttons, float timeout) : base(new Rectangle(30, 30, 40, 40), null) { Units = MesurementUnit.Percentage; Movable = false; _sender = sender; Componates.Clear(); //remove any old compaontas bntFunctions.Clear(); Title = title; //set the title _optionSelected = null; wlText = new WinLable(new Rectangle(50, 50, 0, 0), this) //add the descrition to the lable { Text = description, }; float buttonSpacing = 300 / ((float)buttons.Count + 1); //calculate spacing between buttons for (int i = 0; i < buttons.Count; i++) { bntFunctions.Add(new Button(new Rectangle((int)(50 + buttonSpacing * i), 200, 90, 50), this) //add all buttons { Text = buttons[i], id = buttons[i], CloseParent = true, OnLeftClick = (object parent, Point p) => { _optionSelected = (parent as Button).Text; //set the text for the button presed } }); } Componates.Add(wlText); //add the label for (int i = 0; i < bntFunctions.Count; i++) { Componates.Add(bntFunctions[i]); //add the buttons } if (_timeOut > 0) { _useTimeOut = true; } else { _useTimeOut = false; } _timeOut = timeout; }
private void AddPageButton(string name) { int bntwidth = Convert.ToInt32(Font.MeasureString(name).X) + 6; Componates.Add(new Button(new Rectangle(_lastBntPos, 0, bntwidth, 24), this) { Units = MesurementUnit.Px, Text = name, CustomData = Pages.Count - 1, OnLeftClick = (object sender, Point p) => { Button bnt = sender as Button; SelectPage(Convert.ToInt32(bnt.CustomData)); }, }); _lastBntPos += bntwidth; }
/// <summary> /// shows a new mesage box /// </summary> /// <param name="title">The Title</param> /// <param name="description">the description</param> /// <param name="buttons">list of buttons</param> /// <param name="ResponeHandle">return function</param> public void ShowDialog(string title, string description, List <string> buttons, Action <object, Point> ResponeHandle) { Componates.Clear(); //remove any old compaontas bntFunctions.Clear(); Title = title; //set the title wlText = new WinLable(new Rectangle(50, 50, 0, 0), this) //add the descrition to the lable { Text = description, }; float buttonSpacing = 300 / ((float)buttons.Count + 1); //calculate spacing between buttons for (int i = 0; i < buttons.Count; i++) { bntFunctions.Add(new Button(new Rectangle((int)(50 + buttonSpacing * i), 200, 90, 50), this) //add all buttons { Text = buttons[i], id = buttons[i], CloseParent = true, }); if (ResponeHandle != null) //if we have a retun fucntion { bntFunctions[i].OnLeftClick = ResponeHandle; } } Componates.Add(wlText); //add the label for (int i = 0; i < bntFunctions.Count; i++) { Componates.Add(bntFunctions[i]); //add the buttons } _useTimeOut = false; _timeOut = 0; _responce = ResponeHandle; this.Activate(true); }