-
Notifications
You must be signed in to change notification settings - Fork 437
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
JSB - Add Example to WinForms project
A very simple Multiply example
- Loading branch information
Showing
4 changed files
with
78 additions
and
1 deletion.
There are no files selected for viewing
10 changes: 10 additions & 0 deletions
10
CefSharp.MinimalExample.WinForms/AsyncJavascriptBindingClass.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
namespace CefSharp.MinimalExample.WinForms | ||
{ | ||
public class AsyncJavascriptBindingClass | ||
{ | ||
public double Multiply(double number1, double number2) | ||
{ | ||
return number1 * number2; | ||
} | ||
} | ||
} |
51 changes: 51 additions & 0 deletions
51
CefSharp.MinimalExample.WinForms/AsyncJavascriptBindingDemo.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
<!DOCTYPE html> | ||
|
||
<html lang="en" xmlns="http://www.w3.org/1999/xhtml"> | ||
<head> | ||
<meta charset="utf-8" /> | ||
<title>Async Javascript Binding Example</title> | ||
</head> | ||
<body> | ||
<div> | ||
<h1>Async Binding Example</h1> | ||
<h2>Multiply</h2> | ||
<div> | ||
<table> | ||
<thead> | ||
<tr> | ||
<td>First Number</td> | ||
<td>Second Number</td> | ||
<td>Result</td> | ||
</tr> | ||
</thead> | ||
<tbody> | ||
<tr> | ||
<td><input id="firstNumber" type="text" value="4" /></td> | ||
<td><input id="secondNumber" type="text" value="5" /></td> | ||
<td><input id="result" type="text" readonly="readonly" /></td> | ||
</tr> | ||
<tr> | ||
<td colspan="3"><input type="button" id="calculate" value="Calculate" /></td> | ||
</tr> | ||
</tbody> | ||
</table> | ||
</div> | ||
</div> | ||
<script type="text/javascript"> | ||
(async function () | ||
{ | ||
await CefSharp.BindObjectAsync("boundAsync"); | ||
|
||
document.getElementById('calculate').addEventListener('click', async function () | ||
{ | ||
var number1 = parseInt(document.getElementById('firstNumber').value, 10); | ||
var number2 = parseInt(document.getElementById('secondNumber').value, 10); | ||
|
||
var result = await boundAsync.multiply(number1, number2); | ||
|
||
document.getElementById('result').value = result; | ||
}); | ||
})(); | ||
</script> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters