https://github.com/pulsejet/WinFormsToHTML
A quick converter from WinForms to HTML
https://github.com/pulsejet/WinFormsToHTML
converter html winforms
Last synced: about 2 months ago
JSON representation
A quick converter from WinForms to HTML
- Host: GitHub
- URL: https://github.com/pulsejet/WinFormsToHTML
- Owner: pulsejet
- License: apache-2.0
- Archived: true
- Created: 2017-10-01T12:49:49.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2017-10-04T05:44:06.000Z (over 7 years ago)
- Last Synced: 2024-10-24T12:09:34.872Z (6 months ago)
- Topics: converter, html, winforms
- Language: Visual Basic
- Size: 60.5 KB
- Stars: 1
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# WinFormsToHTML
A quick converter from WinForms to HTML. The converter is written in VB.NET, but can be easily converted to C# since the two languages are equivalent.This project does not serve the purpose of converting an entire WinForms application to a web application. The aim is to be able to get a head-start into converting a WinForms application to a webapp. All on form actions must be performed using JavaScript, which must be written separately. The `map.js` file that is created is used by data based applications to store database mappings for easy access.
A js script with some useful functions (`common.js`) is also provided.
### Supported Controls
* Label
* TextBox (including multi-line)
* PictureBox
* DateTimePicker *(partial)*
* CheckBox
* ListBox
* ComboBox
* Button
* TableLayoutPanel
* Panel
* GroupBox
* DataGridView *(partial)*
* TabControl and TabPage
* MenuStrips *(partial)*### Styling
All styling including colors, hovering etc. must be done using external CSS. All controls must have the `position:absolute` directive to be positioned properly. It is recommendable to use the provided formstyle1.css as a starting point.### Custom HTML Headers
The `` is read from a template and appropriate values are filled in. This can be customized to include any other js files, CSS etc.### Multiple form support *(partial)*
Multiple forms have been crudely implemented with the help of ``. A modal form `Form1` will open on clicking on `Button2` in the demo.### common.js Functions
Below explained are some common.js functions in no particular order:
***Note**: common.js requries jQuery and some functions require Moment.js with moment-precise-range. Sorting grids requires jQuery tablesorter.*
**Important:** *common.js is required for TabControls to work.***General Functions:**
* `$(document).ready`
On loading the document, common.js will perform some functions automatically, including adding the Return key handler to the AcceptButton and the Escape key handler to the CancelButton. It will also add the required markup for showing modals.
* `showModal(URL)`
Shows a modal box with the given URL.
* `closeModal()`
Closes the open modal box.
* `closeModalOnClick(control)`
Assigns the close event to a control on click.
* `addctrlShortcut(shortcutkey, control)`
Adds a Ctrl+Key shortcut to a control. shortcutkey must be an ASCII value.
Sample Usage: `addctrlShortcut(toAscii('B'), $('#Button1'));`
* `addaltrShortcut(shortcutkey, control)`
Adds a Alt+Key shortcut to a control. shortcutkey must be an ASCII value.
* `selectFirst(control)`
Marks the first `option` as `selected`**Tools:**
* `getParameterByName(name, url)`
Get query string from URL. No URL specified defaults to the current URL of the window.
* `escapeXml(unsafe)`
Escapes unsafe characters from XML.
* `toAscii(str)`
Returns the ASCII value of the first character of a string.
* `addValuesChangedAlert()`
Adds an alert that values have been changed while closing the page if the user has pressed a key inside a TextBox.**Data Helpers:**
All exchange of data fro DataGridView Controls takes place as XML. The format is the same as the one generated by DataTable's WriteXML.
* `initGrids()`:
Initializes the grids on the form.
* `fillDataGrid(control, data)`
Fills up the grid with id=control with XML data from XML data.
* `fillList(data, datalist)`
Adds `option`s to a datalist or a select from the first column of XML data.
* `getDataGrid(control, tablename)`
Converts the edited grid to XML. Deleted rows are present with an additional node ``. tablename is the name for each row.
* `getJsonMapping(data, pkey)`
Gets a JSON mapping from an XML datatable where pkey is the primary key, and each key is associated with another JSON object with keys as column names and values as the associated data.
* `setControlsDatafromJSON(dataJson, controllist)`
Sets data to a list of controls from a Json Mapping. Usually used in conjunction with the JSON control object in `map.js`
* `getXMLfromForm()`
Gets an XML datatable from controls listed in `map.js`.
* `getJSONfromXML(data, rowno)`
Gets a JSON object from one row of an XML datatable.### Contribute
The project is licensed under the Apache license, so feel free to use it for any application, commercial or otherwise, and to contribute back in any way!