private static string GetTextForCustom(Dialog.ButtonType buttonType) { switch (buttonType) { case Dialog.ButtonType.Custom1: return(custom1_t); case Dialog.ButtonType.Custom2: return(custom2_t); case Dialog.ButtonType.Custom3: return(custom3_t); default: return(string.Empty); } }
public override void Initialize(Dialog.ButtonType buttons, string title, string message) { WasSomeoneHired = false; GenerateApplicants(Company); IsModal = true; OnClicked += HireDialog_OnClicked; OnClosed += HireDialog_OnClosed; int w = LocalBounds.Width; int h = LocalBounds.Height; int rows = h / 64; int cols = 8; GridLayout layout = new GridLayout(GUI, this, rows, cols); Title = new Label(GUI, layout, title, GUI.TitleFont); layout.SetComponentPosition(Title, 0, 0, 2, 1); GroupBox applicantSelectorBox = new GroupBox(GUI, layout, ""); layout.SetComponentPosition(applicantSelectorBox, 0, 1, rows / 2 - 1, cols - 1); GridLayout selectorLayout = new GridLayout(GUI, applicantSelectorBox, 1, 1); ScrollView view = new ScrollView(GUI, selectorLayout); ApplicantSelector = new ListSelector(GUI, view) { Label = "-Applicants-" }; selectorLayout.SetComponentPosition(view, 0, 0, 1, 1); foreach (Applicant applicant in Applicants) { ApplicantSelector.AddItem(applicant.Level.Name + " - " + applicant.Name); } ApplicantSelector.DrawPanel = false; ApplicantSelector.LocalBounds = new Rectangle(0, 0, 128, Applicants.Count * 24); ApplicantSelector.OnItemSelected += ApplicantSelector_OnItemSelected; CurrentApplicant = Applicants[0]; GroupBox applicantPanel = new GroupBox(GUI, layout, ""); layout.SetComponentPosition(applicantPanel, rows / 2 - 1, 1, rows / 2 - 1, cols - 1); GridLayout applicantLayout = new GridLayout(GUI, applicantPanel, 1, 1); ApplicantPanel = new ApplicationPanel(applicantLayout); applicantLayout.SetComponentPosition(ApplicantPanel, 0, 0, 1, 1); ApplicantPanel.SetApplicant(CurrentApplicant); bool createOK = false; bool createCancel = false; switch (buttons) { case ButtonType.None: break; case ButtonType.OkAndCancel: createOK = true; createCancel = true; break; case ButtonType.OK: createOK = true; break; case ButtonType.Cancel: createCancel = true; break; } if (createOK) { Button okButton = new Button(GUI, layout, "OK", GUI.DefaultFont, Button.ButtonMode.ToolButton, GUI.Skin.GetSpecialFrame(GUISkin.Tile.Check)); layout.SetComponentPosition(okButton, cols - 2, rows - 1, 2, 1); okButton.OnClicked += okButton_OnClicked; } if (createCancel) { Button cancelButton = new Button(GUI, layout, "Cancel", GUI.DefaultFont, Button.ButtonMode.PushButton, GUI.Skin.GetSpecialFrame(GUISkin.Tile.Ex)); layout.SetComponentPosition(cancelButton, cols - 4, rows - 1, 2, 1); cancelButton.OnClicked += cancelButton_OnClicked; } HireButton = new Button(GUI, layout, "Hire", GUI.DefaultFont, Button.ButtonMode.ToolButton, GUI.Skin.GetSpecialFrame(GUISkin.Tile.ZoomIn)); layout.SetComponentPosition(HireButton, cols - 1, rows - 2, 1, 1); HireButton.OnClicked += HireButton_OnClicked; }
public static Dialog.ShowDialogResult ShowDialog(string Message, string Title = "Title", string DefaultInput = "", bool Input = false, Dialog.ButtonType Button1 = Dialog.ButtonType.OK, Dialog.ButtonType Button2 = Dialog.ButtonType.Cancel, Dialog.ButtonType Button3 = Dialog.ButtonType.None, Dialog.DialogIcon Icon = Dialog.DialogIcon.None) { Btn1 = Button1; Btn2 = Button2; Btn3 = Button3; DialogInputForm dialogForm = new DialogInputForm(); // Button 1 if (Btn1 == Dialog.ButtonType.None) { dialogForm.button1.Visible = false; dialogForm.button1.Enabled = false; } else { dialogForm.CancelButton = dialogForm.button1; if (Btn1 >= Dialog.ButtonType.Custom1) { dialogForm.button1.Text = GetTextForCustom(Btn1); } else { dialogForm.button1.Text = Btn1.ToString(); } } // Button 2 if (Btn2 == Dialog.ButtonType.None) { dialogForm.button2.Visible = false; dialogForm.button2.Enabled = false; } else { dialogForm.CancelButton = dialogForm.button2; if (Btn2 >= Dialog.ButtonType.Custom1) { dialogForm.button2.Text = GetTextForCustom(Btn2); } else { dialogForm.button2.Text = Btn2.ToString(); } } // Button 3 if (Btn3 == Dialog.ButtonType.None) { dialogForm.button3.Visible = false; dialogForm.button3.Enabled = false; } else { dialogForm.CancelButton = dialogForm.button3; if (Btn3 >= Dialog.ButtonType.Custom1) { dialogForm.button3.Text = GetTextForCustom(Btn3); } else { dialogForm.button3.Text = Btn3.ToString(); } } DialogResult = Dialog.DialogResult.None; dialogForm.Text = Title; dialogForm.label_text.Text = Message; dialogForm.Input = Input; dialogForm.txt_userInput.Text = DefaultInput; dialogForm.pictureBox1.Visible = true; Icon t_icon = null; switch (Icon) { case Dialog.DialogIcon.None: dialogForm.pictureBox1.Visible = false; break; case Dialog.DialogIcon.Application: t_icon = SystemIcons.Application; break; case Dialog.DialogIcon.Asterisk: t_icon = SystemIcons.Asterisk; break; case Dialog.DialogIcon.Error: t_icon = SystemIcons.Error; break; case Dialog.DialogIcon.Hand: t_icon = SystemIcons.Hand; break; case Dialog.DialogIcon.Exclamation: t_icon = SystemIcons.Exclamation; break; case Dialog.DialogIcon.Shield: t_icon = SystemIcons.Shield; break; case Dialog.DialogIcon.Question: t_icon = SystemIcons.Question; break; case Dialog.DialogIcon.Warning: t_icon = SystemIcons.Warning; break; case Dialog.DialogIcon.Information: t_icon = SystemIcons.Information; break; case Dialog.DialogIcon.WinLogo: t_icon = SystemIcons.WinLogo; break; default: break; } if (t_icon != null) { dialogForm.pictureBox1.Image = t_icon.ToBitmap(); } dialogForm.ShowDialog(); return(new Dialog.ShowDialogResult(dialogForm.Result, DialogResult)); }