PoshTimeliner AddTimeliner(string url) { var _url = WebServer.AddURL(url); var port = WebServer.URLPort[_url]; PoshTimeliner timeliner; lock (FPoshTimeliners) { FPoshTimeliners.Add(new PoshTimeliner(_url, port)); timeliner = FPoshTimeliners.Last(); } timeliner.Log = x => Console.WriteLine(x); timeliner.AfterHistoryPublish = () => UpdateCaption(true); timeliner.Shortcut = HandleAction; return(timeliner); }
public MainForm() { // The InitializeComponent() call is required for Windows Forms designer support. InitializeComponent(); Log = x => Console.WriteLine(x); //register a url and receive a unique websocketport for it var url = WebServer.AddURL("poshdemo"); var port = WebServer.URLPort[url]; //create a wampserver/websocket on the given port FPoshServer = new PoshServer(port); FPoshServer.OnDump += PoshGraphDump; FPoshServer.OnSessionCreated += PoshSessionCreated; FPoshServer.OnSessionClosed += PoshSessionClosed; //setup keyboard handlers // FWAMPServer.OnKeyDown += KeyDownHandler; // FWAMPServer.OnKeyUp += KeyUpHandler; // FWAMPServer.OnKeyPress += KeyPressHandler; //create an svg document ViewRoot = new SvgDocument(); //hand the svg document a custom idmanager that talks to the WampServer var manager = new SvgIdManager(ViewRoot, FPoshServer.SvgEventCaller, FPoshServer.RemoteContext); ViewRoot.OverwriteIdManager(manager); //fill the svg document SetupInitialView(); //open the canvas: the window showing the view is a webbrowser navigating to the given url on localhost webBrowser1.Navigate("about:blank"); webBrowser1.Navigate(new Uri("http://localhost:4444/" + url)); //dispose web- and wampserver this.Disposed += (s, e) => { WebServer.Stop(); FPoshServer.Dispose(); }; }