Click on Install Package - Visual studio Code debian package
After installing the package Visual Studio code will show up in the menu:
Visual studio code in the menu
3. Install the C# Extension
Click on the extensions icon to the left and search for C#. Then click install.
Visual studio csharp extension
4. Creating an ASP.NET Core Project
Now its time to create an ASP.NET MVC project from the terminal. These commands are copied from the Microsoft documentation
dotnet new mvc -o MvcMovie
This creates a new mvc project in a folder called MvcMovie.
We can use the command line to open the newly created project in VS Code:
code -r MvcMovie
And to run the application run:
dotnet run --project MvcMovie/
... omitted text from command
Hosting environment: Development
Now listening on: https://localhost:5001
Now listening on: http://localhost:5000
The code above proposes a path and a filename to the user when opening the save dialog with defaultPath. It uses app.getPath to get the path to our users document folder and then appends a filename.pdf
I’ve also changed so that the callback method is used which gives us the path. I’d recommend to look at the showSaveDialog documentation to see what more options you can use.
But that would only display a box with no info and an OK-button. The dialog would return a response which contains the index of the button the user clicked.
An empty showMessageBox
Adding more info to the message box
Lets add more info the the box, A question and two buttons and use the callback method as well.
constoptions={type:'question',buttons:['Cancel','Yes, please','No, thanks'],defaultId:2,title:'Question',message:'Do you want to do this?',detail:'It does not really matter',checkboxLabel:'Remember my answer',checkboxChecked:true,};dialog.showMessageBox(null,options,(response,checkboxChecked)=>{console.log(response);console.log(checkboxChecked);});
The code above would produce a message box looking like this:
Show message box
type displays different icons in the messagebox.
buttons is an array of strings that will be displayed as buttons.
defaultId sets which of the buttons should be selected when opening the box.
title displays a title on some platforms.
message displays a message.
detail displays more text below the message.
checkboxLabel the box can display a checkbox as well. this is the label for it.
checkboxChecked the initial value of the checkbox.
Checkout the dialog documentation to get more info and what values you can set for the different settings.