ScriptCS-GUI
ScriptCS-GUI is a simple GUI toolkit for ScriptCS. Its main aim is to help the user create fully interactive forms from the REPL without preventing her to use the REPL after the forms are run (on the contrary, tipically, creating and running a form from the console hangs the console). Thanks to a bunch of Windows API's ScriptCS-GUI hides you the complexity of instantiating independent windows forms from the REPL and lets you enjoy the rest.
At the moment the class
- Gui.OpenFileDialog(): open a classic Open File Dialog and return the path of the selected file.
- Gui.SaveFileDialog(): act similar to OpenFileDialog()...
- Gui.PopUp(): open a pop-up and returns a form object. You can use its Sta.Enqueue(action) method to inject code in the form's main thread (e.g. to add controls at runtime) while working inside the console!
- Gui.Drawing(): open a drawing form and returns the Graphics object you can use to draw on the form (the console stays responsive in this case too!)
Here's how to open an Open File Dialog. First install ScriptCS-GUI locally from NuGet with:
C:/anyfolder>scriptcs -install ScriptCs.Gui
Then enter scriptcs REPL and type the following.
var gui = Require<Gui>(); var path = gui.OpenFileDialog(); Console.WriteLine("You selected: '{0}'.", path ?? "nothing");
Launch the script as shown in the picture and enjoy your interaction... :)
The demo in ./demo/gui-demo.csx shows you:
- how to open a PopUp Windows Form from the console and programmatically add controls to it while both the console and the form are responsive!
- how to open a Drawing Windows Form from the console and draw on it from the console using classic Windows.Drawing commands.
- and more... :)