Skip to content

Instantly share code, notes, and snippets.

@richorama
Last active January 4, 2018 17:54
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save richorama/91cde3a5af34217b6118 to your computer and use it in GitHub Desktop.
Save richorama/91cde3a5af34217b6118 to your computer and use it in GitHub Desktop.
Display a WPF Window from node.js using edge.js
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