public string showGui(string userDataDirectory) { var panel = O2Gui.open <Panel>("Secret Data Files", 750, 200); var controls = panel.add_1x1("Folder with secret data files", "SecretData", true, 230); directory = controls[0].add_Directory(userDataDirectory); if (userDataDirectory.files().size() == 0) { new SecretData().serialize(userDataDirectory.pathCombine("SecretData.xml")); } directory.parent().insert_Below <Panel>(30) .add_Link("Create new Secret's file", 5, 0, createNewSecretsFile) .append_Link("Save Loaded File", saveLoadedSecretsFile); dataGridView = controls[1].add_DataGridView(); dataGridView.AllowUserToAddRows = true; dataGridView.AllowUserToDeleteRows = true; dataGridView.add_Columns(typeof(Credential)); var contextMenu = dataGridView.add_ContextMenu(); contextMenu.add_MenuItem("Save", saveLoadedSecretsFile); contextMenu.add_MenuItem("Create new File", createNewSecretsFile); directory.afterFileSelect(loadFile); statusLabel = panel.parentForm().add_StatusStrip(); statusMessage("Select Secrets file to load from TreeView on the left"); return("done"); }
public static Credential ask() { var loginDetailsGui = O2Gui.open <ascx_AskUserForLoginDetails>("Enter Login Details", 250, 115); loginDetailsGui.buildGui(); var credential = loginDetailsGui.getAnswer(); loginDetailsGui.close(); return(credential); }
public static string askQuestion(string captchaQuestionUrl) { var captchaQuestion = O2Gui.open <ascx_CaptchaQuestion>("Answer CAPTCHA Question", 400, 200); captchaQuestion.buildGui(captchaQuestionUrl); var captchaAnswer = captchaQuestion.getAnswer(); captchaQuestion.close(); return(captchaAnswer); }
public static Control showAscxInForm(Type controlType, string formTitle, int width, int height) { var controlCreation = new AutoResetEvent(false); Control control = null; O2Thread.staThread( () => { O2Gui o2Gui = null; try { control = (Control)PublicDI.reflection.createObjectUsingDefaultConstructor(controlType); if (control != null) { control.Dock = DockStyle.Fill; o2Gui = new O2Gui(width, height, false); // I might need to adjust these width, height so that the control is the one with this size (and not the hosting form) o2Gui.Text = formTitle; if (width > -1) { control.Width = width; } else { o2Gui.Width = control.Width; // if it is not defined resize the form to fit the control } if (height > -1) { control.Height = height; } else { o2Gui.Height = control.Height; // if it is not defined resize the form to fit the control } o2Gui.clientSize(control.Width, o2Gui.Height); // reset the form size to the control's size o2Gui.Controls.Add(control); o2Gui.Load += (sender, e) => controlCreation.Set(); //o2Gui.showDialog(false); o2Gui.showDialog(false); } else { controlCreation.Set(); } } catch (Exception ex) { "in showAscxInForm: {0}".format(ex).error(); controlCreation.Set(); } finally { if (o2Gui != null) { o2Gui.Dispose(); } } }); var maxTimeOut = System.Diagnostics.Debugger.IsAttached ? -1 : 20000; if (controlCreation.WaitOne(maxTimeOut).failed()) { "[WinForms] Something went wrong with the creation of the {0} control with title '{1}' since it took more than 20s to start".error(controlType, formTitle); } return(control); }