/// <summary> /// Initialize things which must happen on a UI thread. /// </summary> public void InitUIDependantVariables(App args, TaskScheduler scheduler) { UISheduler = scheduler; NetworkSendState = new NetworkSendState(this, UISheduler); NetworkReceiveState = new NetworkReceiveState(this, UISheduler); WCFHost = new WCFHostServiceState(this, UISheduler); Hooker = new NetworkedHooker(this); if (!HookEvents.IsAlreadyRegistered()) { Commands["RegisterETWProvider"].Execute(null); } // use settings from command line if present CaptureKeyboard = args.CaptureKeyboard; CaptureMouseButtonDown = args.CaptureMouseButtonDown; CaptureMouseMove = args.CaptureMouseMove; ScreenshotDirectoryUnexpanded = (args.ScreenshotDirectory ?? Configuration.Default.ScreenshotDirectory); CaptureScreenShots = args.CaptureScreenshots; // This line will also trigger a property change event which instantiates and starts the screenshotrecorder IsKeyBoardEncrypted = !args.IsKeyBoardNotEncrypted; if (args.SendToServer != null) { this.Host = args.SendToServer; } if (args.SendToServerPort != null) { if (int.TryParse(args.SendToServerPort, out int portNumber)) { this.PortNumber = portNumber; } } if (args.SendtoServerSecondaryPort != null) { if (int.TryParse(args.SendtoServerSecondaryPort, out int secondaryPort)) { this.WCFPort = secondaryPort; } } }
/// <summary> /// All button presses are routed via comamnds here which do execute one of these commands /// </summary> /// <returns></returns> private Dictionary <string, ICommand> CreateUICommands() { Dictionary <string, ICommand> commands = new Dictionary <string, ICommand> { { "LogSlow", CreateCommand(_ => Hooker.LogSlowEvent()) }, { "LogFast", CreateCommand(_ => Hooker.LogFastEvent()) }, { "Config", CreateCommand(_ => ShowConfigDialog()) }, { "TraceRefresh", CreateCommand(_ => { TraceSessions = LocalTraceControler.GetTraceSessions(); WCFHost.GetTraceSessions.Execute(); }) }, { "StartTracing", CreateCommand(_ => StartTracing()) }, { "StopTracing", CreateCommand(_ => StopTracing()) }, { "CancelTracing", CreateCommand(_ => CancelTracing()) }, { "RegisterETWProvider", CreateCommand(_ => { string output = HookEvents.RegisterItself(); SetStatusMessage("Registering ETW provider: " + output); }) }, { "ConfigReset", CreateCommand(_ => { Configuration.Default.Reset(); Configuration.Default.Save(); LoadSettings(); }) }, { "ShowMessages", CreateCommand(_ => ShowMessages()) }, { "NetworkSendToggle", CreateCommand(_ => NetworkSendState.NetworkSendChangeState()) }, { "NetworkReceiveToggle", CreateCommand(_ => NetworkReceiveState.NetworkReceiveChangeState()) }, { "ClearStatusMessages", CreateCommand(_ => StatusMessages.Clear()) }, { "ShowCommandLineOptions", CreateCommand(_ => ShowCommandLineOptions()) }, { "About", CreateCommand(_ => AboutBox()) }, }; return(commands); }