Last active
January 4, 2018 17:54
-
-
Save richorama/91cde3a5af34217b6118 to your computer and use it in GitHub Desktop.
Display a WPF Window from node.js using edge.js
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
var edge = require('edge'); | |
var hello = edge.func(function () {/* | |
#r "PresentationCore.dll" | |
#r "PresentationFramework.dll" | |
#r "WindowsBase.dll" | |
#r "System.Xaml.dll" | |
#r "System.Threading.dll" | |
using System.Windows; | |
using System.Threading; | |
using System.Windows.Controls; | |
using System.Threading.Tasks; | |
using System; | |
public class Startup | |
{ | |
public Task<object> Invoke(dynamic command) | |
{ | |
var tcs = new TaskCompletionSource<object>(); | |
var ts = new ThreadStart(() => { | |
var app = new Application(); | |
var window = new Window(); | |
var panel = new StackPanel(); | |
window.Content = panel; | |
var button = new Button{ | |
Content = "My Button", | |
}; | |
var txt = new TextBox(); | |
button.Click += (x,y) => { | |
tcs.TrySetResult(txt.Text); | |
}; | |
panel.Children.Add(txt); | |
panel.Children.Add(button); | |
window.Show(); | |
app.Run(); | |
}); | |
var thread = new Thread(ts); | |
thread.TrySetApartmentState(ApartmentState.STA); | |
thread.Start(); | |
return tcs.Task; | |
} | |
} | |
*/}); | |
hello('', function (error, result) { | |
if (error) throw error; | |
console.log(result); | |
}); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment