public static void VA_Init1(dynamic vaProxy) { var configThread = new Thread(Dispatcher.Run); configThread.SetApartmentState(ApartmentState.STA); configThread.Start(); for (var i = 0; i < 10; i++) { var dispatcher = Dispatcher.FromThread(configThread); if (dispatcher != null) { dispatcher.UnhandledException += DispatcherOnUnhandledException; dispatcher.Invoke(() => { window = new MainWindow(); }); break; } Thread.Sleep(TimeSpan.FromMilliseconds(500)); } if (window == null) { vaProxy.WriteToLog($"{VA_DisplayName()} did not correctly load.", "red"); return; } var voiceAttackAccessor = new VoiceAttackAccessor(); voiceAttackAccessor.EventSent += (sender, args) => { HandleEvents(args, ref vaProxy); }; voiceAttackAccessor.LogSent += (sender, args) => { WriteToLog(ref vaProxy, args.Message, args.Color); }; voiceAttackAccessor.VariableSent += (sender, args) => { SetVariable(ref vaProxy, args.ValueType, args.VariableName, args.Value); }; EdRouter.Init(new DispatcherAccessor(window.Dispatcher), voiceAttackAccessor); App.IsFromVA = true; vaProxy.WriteToLog($"{VA_DisplayName()} ready!", MessageColor.Green.ToLogColor()); }
protected override void OnStartup(StartupEventArgs e) { base.OnStartup(e); EdRouter.Init(new DispatcherAccessor(Current.Dispatcher), new DummyVoiceAttackAccessor()); }