### Install NetBeauty as a Global Tool Source: https://github.com/nulastudio/netbeauty2/blob/master/README.md Command to install NetBeauty globally as a .NET Core tool. ```bash dotnet tool install --global nulastudio.nbeauty ``` -------------------------------- ### Customizing AppHost Example Structure Source: https://github.com/nulastudio/netbeauty2/blob/master/README.md Demonstrates a simplified folder structure for a single application using a customized AppHost, with dependencies in a 'libs' folder. ```bash ├── MyApp # Main folder for the app │ ├── libs # Dependencies │ ├── hostfxr.dll ... # DLLs that cannot be moved │ ├── libloader.dll # Loader (moved if using patch) │ ├── MyApp.deps.json │ ├── MyApp.dll │ ├── MyApp.runtimeconfig.json │ └── ... └── MyApp.exe # AppHost ``` -------------------------------- ### Configure NetBeauty in .csproj Source: https://github.com/nulastudio/netbeauty2/blob/master/README.md Example .csproj file demonstrating various NetBeauty configuration options. ```xml Exe netcoreapp3.0 False False ../libraries ./libraries False False auto False True Info ``` -------------------------------- ### Handle GET Request Response Source: https://github.com/nulastudio/netbeauty2/blob/master/NetBeautyTest/ChromelyTest/app/pages/messagerouterdemo.html Parses and displays data from a GET request response. It expects a JSON response with a 'Data' array to populate a table. ```javascript function messageRouterGetResult(res) { $('#messageRouterGetResult tbody').empty(); var jsonData = JSON.parse(res); if (jsonData.ReadyState == 4 && jsonData.Status == 200) { for (var i = 0; i < jsonData.Data.length; i++) { var row = ''; row += '' + jsonData.Data[i].Id + ''; row += '' + jsonData.Data[i].Title + ''; row += '' + jsonData.Data[i].Year + ''; row += '' + jsonData.Data[i].Votes + ''; row += '' + jsonData.Data[i].Rating + ''; row += '' + jsonData.Data[i].Date + ''; row += '' + jsonData.Data[i].RestfulAssembly + ''; row += ''; $('#messageRouterGetResult tbody').append(row); } } } ``` -------------------------------- ### Initiate GET Request Source: https://github.com/nulastudio/netbeauty2/blob/master/NetBeautyTest/ChromelyTest/app/pages/messagerouterdemo.html Constructs and sends a GET request using Chromely's cefQuery. It defines the request method, URL, and handles success and failure callbacks. ```javascript function messageRouterGetRun() { $('#messageRouterGetResult tbody').html(''); var request = { "method": "GET", "url": "/democontroller/movies/get", "parameters": null, "postData": null, }; window.cefQuery({ request: JSON.stringify(request), onSuccess: function (response) { messageRouterGetResult(response); }, onFailure: function (err, msg) { console.log(err, msg); } }); } ``` -------------------------------- ### AJAX GET Request Source: https://github.com/nulastudio/netbeauty2/blob/master/NetBeautyTest/ChromelyTest/app/pages/ajaxdemo.html Performs an AJAX GET request to fetch movie data and appends it to a table. Ensure the target element '#ajaxGetResult tbody' exists. ```javascript function ajaxGetRun() { $('#ajaxGetResult tbody').html(''); var http = new XMLHttpRequest(); var url = "http://chromely.com/democontroller/movies/get"; http.open("GET", url, true); http.onreadystatechange = function () { $('#ajaxGetResult tbody').empty(); if (http.readyState == 4 && http.status == 200) { var jsonData = JSON.parse(http.responseText); for (var i = 0; i < jsonData.length; i++) { var row = ''; row += '' + jsonData[i].Id + ''; row += '' + jsonData[i].Title + ''; row += '' + jsonData[i].Year + ''; row += '' + jsonData[i].Votes + ''; row += '' + jsonData[i].Rating + ''; row += '' + jsonData[i].Date + ''; row += '' + jsonData[i].RestfulAssembly + ''; row += ''; $('#ajaxGetResult tbody').append(row); } } } http.send(); } ``` -------------------------------- ### Chromely JavaScript Request Example Source: https://github.com/nulastudio/netbeauty2/blob/master/NetBeautyTest/ChromelyTest/app/pages/home.html This snippet uses `window.cefQuery` to send a request to the '/info' endpoint and handles the response to update HTML elements. Ensure the Chromely application is running and the '/info' endpoint is configured. ```javascript $(document).ready(function () { var request = { "url": "/info", "parameters": null, "postData": null }; window.cefQuery({ request: JSON.stringify(request), onSuccess: function (response) { var jsonData = JSON.parse(response); if (jsonData.ReadyState == 4 && jsonData.Status == 200) { $('#objective').html("Chromely Main Objective: " + jsonData.Data.objective); $('#platform').html("Platforms: " + jsonData.Data.platform); $('#version').html("Chromium - CefGlue Version: " + jsonData.Data.version); } }, onFailure: function (err, msg) { console.log(err, msg); } }); }); ``` -------------------------------- ### Fetch TODO List Items Source: https://github.com/nulastudio/netbeauty2/blob/master/NetBeautyTest/ChromelyTest/app/pages/todolist.html Retrieves TODO list items based on request type, ID, and completion status. It sends a GET request to the '/todolistcontroller/items' endpoint. ```javascript function getTodoList(reqType, id, todo, completed) { $('#moviesContainer').html(""); var keys = {}; keys["name"] = reqType; keys["id"] = id; keys["todo"] = todo; keys["completed"] = completed.toString(); var parameters = {}; parameters["keys"] = keys; var request = { "method": "GET", "url": "/todolistcontroller/items", "parameters": parameters, "postData": null, }; window.cefQuery({ request: JSON.stringify(request), onSuccess: function (response) { populateTodoList(response); if (reqType == 'clearcompleted') { var checkBox = document.getElementById("checkboxSelectAllTodoItems"); checkBox.checked = false; } }, onFailure: function (err, msg) { console.log(err, msg); } }); } ``` -------------------------------- ### Initialize TODO List and Add Item on Enter Source: https://github.com/nulastudio/netbeauty2/blob/master/NetBeautyTest/ChromelyTest/app/pages/todolist.html Initializes the TODO list on document ready and adds a new TODO item when the Enter key is pressed in the input field. It also fetches all existing items. ```javascript $(document).ready(function(){ $("#textTodoItem").on("keyup",function(e){ if (e.which == 13) { var allItemsSwictchCheckBox = document.getElementById("checkboxSelectAllTodoItems"); allItemsSwictchCheckBox.checked = false; var text = document.getElementById("textTodoItem"); getTodoList("add", "", text.value, 0); document.getElementById("textTodoItem").value = ""; } }); getTodoList("all", "", "", ""); }); ``` -------------------------------- ### Shared Runtime Directory Structure Source: https://github.com/nulastudio/netbeauty2/blob/master/README.md Illustrates a typical directory layout for shared runtime DLLs, including locales and native libraries, alongside application-specific folders. ```bash ├── libraries # Shared runtime DLLs (customizable name) │ ├── locales # Satellite assemblies │ │ ├── en │ │ │ └── *.resources.dll │ │ │ ├── MD5_1 # Allows multiple runtimes between apps │ │ │ │ └── *.resources.dll │ │ │ └── MD5_2 │ │ │ └── *.resources.dll │ │ ├── zh-Hans │ │ │ └── *.resources.dll │ │ │ ├── MD5_1 │ │ │ │ └── *.resources.dll │ │ │ └── MD5_2 │ │ │ └── *.resources.dll │ │ └── ... # Other languages │ ├── *.dll # Shared managed assemblies │ │ ├── MD5_1 │ │ │ └── *.dll │ │ └── MD5_2 │ │ └── *.dll │ └── srm_native # Native DLLs (not shared; each app has its own copy) │ ├── APPID_1 │ │ └── *.dll │ └── APPID_2 │ └── *.dll ├── app1 # Main folder for app1 │ ├── hostfxr.dll ... # DLLs that cannot be moved │ ├── libloader.dll # Loader (moved if using patch) │ ├── app1.deps.json │ ├── app1.dll │ ├── app1.exe │ ├── app1.runtimeconfig.json │ └── ... └── app2 # Main folder for app2 ├── hostfxr.dll ... ├── libloader.dll ├── app2.deps.json ├── app2.dll ├── app2.exe ├── app2.runtimeconfig.json └── ... ``` -------------------------------- ### Shared Runtime with Customized AppHost Layout Source: https://github.com/nulastudio/netbeauty2/blob/master/README.md Shows a structure where multiple applications share a common runtime library folder, with each application having its own folder and executable. ```bash ├── libraries # Shared runtime DLLs (customizable name) ├── app1 # Main folder for app1 │ ├── hostfxr.dll ... │ ├── app1.deps.json │ ├── app1.dll │ ├── app1.runtimeconfig.json │ └── ... ├── app2 # Main folder for app2 │ ├── hostfxr.dll ... │ ├── app2.deps.json │ ├── app2.dll │ ├── app2.runtimeconfig.json │ └── ... ├── app1.exe └── app2.exe ``` -------------------------------- ### Initialize Movie Display on Document Ready Source: https://github.com/nulastudio/netbeauty2/blob/master/NetBeautyTest/ChromelyTest/app/pages/tmdbmovies.html Fetches and displays popular movies when the document is fully loaded. This ensures the movie list is populated upon initial page view. ```javascript $(document).ready(function () { getTmdbMovies('popular', ''); }); ``` -------------------------------- ### Add NetBeauty via NuGet Source: https://github.com/nulastudio/netbeauty2/blob/master/README.md Use this command to add the NetBeauty package to your .NET Core project. ```bash dotnet add package nulastudio.NetBeauty ``` -------------------------------- ### Populate TODO List UI Source: https://github.com/nulastudio/netbeauty2/blob/master/NetBeautyTest/ChromelyTest/app/pages/todolist.html Parses the response from `getTodoList` and dynamically generates the HTML for the TODO list items. It handles styling for completed items. ```javascript function populateTodoList(res) { var itemsContainer = ""; $('#todoItemsContainer').html(itemsContainer); // Begininng itemsContainer += "
"; itemsContainer += ""; itemsContainer += "
"; $('#todoItemsContainer').html(itemsContainer); } ``` -------------------------------- ### NetBeauty Binary Application Usage Source: https://github.com/nulastudio/netbeauty2/blob/master/README.md Command-line usage for the NetBeauty binary application on published projects. The `--hiddens` option is Windows-specific. ```bash # Usage: nbeauty2 [--loglevel=(Error|Detail|Info)] [--srmode] [--enabledebug] [--usepatch] [--hiddens=hiddenFiles] [--noruntimeinfo] [--roll-forward=] [--nbloaderverpolicy=(auto|with|without)] [--apphostentry=] [--apphostdir=] [ []] ``` ```bash nbeauty2 --usepatch --loglevel Detail --hiddens "hostfxr;hostpolicy;*.deps.json;*.runtimeconfig*.json" "/path/to/publishDir" libraries "dll1.dll;lib*;..." ``` -------------------------------- ### JavaScript Execution and Event Handling Source: https://github.com/nulastudio/netbeauty2/blob/master/NetBeautyTest/ChromelyTest/app/pages/javascriptdemo.html This snippet contains the core JavaScript logic for executing commands, updating script content, and managing UI elements based on script length. It uses `window.cefQuery` for communication with the host application. ```javascript document.getElementById("demoscript").value = "alert('Chromely : Build .NET/.NET Core HTML5 desktop apps using cross-platform native GUI API.');"; document.getElementById("demoscript").addEventListener("keyup", scriptUpdate); function scriptUpdate() { var content = document.getElementById("demoscript").value; if (content.length > 5) { $('#execute').removeClass('disabled'); } else { $('#execute').addClass('disabled'); } } function executeResult(res) { var jsonData = JSON.parse(res); if (jsonData.ReadyState == 4 && jsonData.Status == 200) { var row = ''; row += 'Execute'; row += '' + jsonData.Data + ''; row += ''; $('#resulttable tr:last').after(row); } } function executeRun() { var content = document.getElementById("demoscript").value; var postData = {}; postData.framename = "alldemoframe"; postData.script = content; var request = { "method": "POST", "url": "/executejavascript/execute", "parameters": null, "postData": JSON.stringify(postData), }; window.cefQuery({ request: JSON.stringify(request), onSuccess: function (response) { executeResult(response); }, onFailure: function (err, msg) { console.log(err, msg); } }); } ``` -------------------------------- ### Initialize Tooltip Component Source: https://github.com/nulastudio/netbeauty2/blob/master/NetBeautyTest/ChromelyTest/app/index.html Initializes the tooltip component for elements with the 'data-toggle="tooltip"' attribute using jQuery. ```javascript $(function () { $('['data-toggle="tooltip"']').tooltip() }) ``` -------------------------------- ### Initiate POST Request with Data Source: https://github.com/nulastudio/netbeauty2/blob/master/NetBeautyTest/ChromelyTest/app/pages/messagerouterdemo.html Prepares and sends a POST request with movie data using Chromely's cefQuery. It defines the request details and includes a JSON payload with movie information. ```javascript function messageRouterPostRun() { $('#messageRouterPostResult').html(''); var moviesJson = [ { Id: 1, Title: "The Shawshank Redemption", Year: 1994, Votes: 678790, Rating: 9.2 }, { Id: 2, Title: "The Godfather", Year: 1972, votes: 511495, Rating: 9.2 }, { Id: 3, Title: "The Godfather: Part II", Year: 1974, Votes: 319352, Rating: 9.0 }, { Id: 4, Title: "The Good, the Bad and the Ugly", Year: 1966, Votes: 213030, Rating: 8.9 }, { Id: 5, Title: "My Fair Lady", Year: 1964, Votes: 533848, Rating: 8.9 }, { Id: 6, Title: "12 Angry Men", Year: 1957, Votes: 164558, Rating: 8.9 } ]; var reqMovies = {}; reqMovies.movies = moviesJson; var request = { "method": "POST", "url": "/democontroller/movies/post", "parameters": null, "postData": reqMovies, }; window.cefQuery({ request: JSON.stringify(request), onSuccess: function (response) { messageRouterPostResult(response); }, onFailure: function (err, msg) { console.log(err, msg); } }); } ``` -------------------------------- ### Toggle All TODO Items Completion Source: https://github.com/nulastudio/netbeauty2/blob/master/NetBeautyTest/ChromelyTest/app/pages/todolist.html Handles the logic for toggling the completion status of all TODO items based on the state of the 'Select All' checkbox. ```javascript function switchOnOffAllTodoItems() { // Get the checkbox var checkBox = document.getElementById("checkboxSelectAllTodoItems"); var allCompleted = 0; if (checkBox.checked == true){ allCompleted = 1; } getTodoList("toggleall", "", "", allCompleted); } ``` -------------------------------- ### Custom Alert Dialog with Bootbox Source: https://github.com/nulastudio/netbeauty2/blob/master/NetBeautyTest/ChromelyTest/app/index.html Implements a custom alert dialog using the bootbox.js library. This function takes a message string and displays it in a modal alert box. ```javascript function showCustomAlert(message) { bootbox.alert(message); } ``` -------------------------------- ### Custom Prompt Dialog with Bootbox Source: https://github.com/nulastudio/netbeauty2/blob/master/NetBeautyTest/ChromelyTest/app/index.html Enables a custom prompt dialog with an input field using bootbox.js. It displays a message, allows user input, and logs the entered result to the console. ```javascript function showCustomPrompt(message) { bootbox.prompt(message, function (result) { console.log(result); }); } ``` -------------------------------- ### Custom Confirm Dialog with Bootbox Source: https://github.com/nulastudio/netbeauty2/blob/master/NetBeautyTest/ChromelyTest/app/index.html Provides a custom confirmation dialog using bootbox.js. It displays a message and a confirmation button, logging the user's result (true/false) to the console. ```javascript function showCustomConfirm(message) { bootbox.confirm(message, function (result) { console.log(result); }) } ``` -------------------------------- ### Initialize Popover Component Source: https://github.com/nulastudio/netbeauty2/blob/master/NetBeautyTest/ChromelyTest/app/index.html Initializes the popover component for elements with the 'data-toggle="popover"' attribute using jQuery. ```javascript $(function () { $('['data-toggle="popover"']').popover() }) ``` -------------------------------- ### Show Chromely Developer Tools Source: https://github.com/nulastudio/netbeauty2/blob/master/NetBeautyTest/ChromelyTest/app/index.html This function constructs a URL to trigger the display of Chromely's developer tools. It creates an anchor element, sets its href to the developer tools URL, appends it to the document body, and programmatically clicks it. ```javascript function showDevTools() { var url = "http://chromely.com/democontroller/showdevtools"; var link = document.createElement('a'); link.href = url; document.body.appendChild(link); link.click(); } ``` -------------------------------- ### Handle Frameless Window Commands in JavaScript Source: https://github.com/nulastudio/netbeauty2/blob/master/NetBeautyTest/ChromelyTest/app/index_frameless.html Use this function to send commands to the Chromely window, such as close, minimize, or maximize. It constructs a URL and simulates a click on a link to trigger the command. ```javascript function frameCommand(type) { var url = "http://chromely.com/window/" + type; var link = document.createElement('a'); link.href = url; document.body.appendChild(link); link.click(); } ``` -------------------------------- ### Custom Popup Dialog with Iframe using Bootbox Source: https://github.com/nulastudio/netbeauty2/blob/master/NetBeautyTest/ChromelyTest/app/index.html Creates a custom modal dialog using bootbox.js that embeds an iframe. This is useful for displaying external content or forms within a modal window. The dialog includes a 'Close' button. ```javascript function showCustomPopupDialog(title, url) { bootbox.dialog({ title: title, message: "