private static IFrameDestination ShowVirtualDmd(BaseOptions options) { if (options.VirtualDmdPosition.Length != 3) { throw new InvalidOptionException("Argument --virtual-position must have three values: \"<Left> <Top> <Width>\"."); } var dmd = new VirtualDmd { AlwaysOnTop = options.VirtualDmdOnTop, GripColor = options.VirtualDmdHideGrip ? Brushes.Transparent : Brushes.White, Left = options.VirtualDmdPosition[0], Top = options.VirtualDmdPosition[1], Width = options.VirtualDmdPosition[2], Height = (int)((double)options.VirtualDmdPosition[2] / 4), }; var thread = new Thread(() => { // Create our context, and install it: SynchronizationContext.SetSynchronizationContext(new DispatcherSynchronizationContext(CurrentDispatcher)); // When the window closes, shut down the dispatcher dmd.Closed += (s, e) => CurrentDispatcher.BeginInvokeShutdown(DispatcherPriority.Background); dmd.Dispatcher.Invoke(() => { dmd.Show(); }); // Start the Dispatcher Processing Run(); }); thread.SetApartmentState(ApartmentState.STA); thread.Start(); return(dmd.Dmd); }
private static IDestination ShowVirtualDmd(BaseOptions options) { if (options.VirtualDmdPosition.Length != 3 && options.VirtualDmdPosition.Length != 4) { throw new InvalidOptionException("Argument --virtual-position must have three or four values: \"<Left> <Top> <Width> [<Height>]\"."); } if (options.VirtualDmdDotSize <= 0 || options.VirtualDmdDotSize > 2) { throw new InvalidOptionException("Argument --virtual-dotsize must be larger than 0 and smaller than 10."); } int height; bool ignoreAr; if (options.VirtualDmdPosition.Length == 4) { height = options.VirtualDmdPosition[3]; ignoreAr = true; } else { height = (int)((double)options.VirtualDmdPosition[2] / 4); ignoreAr = false; } var dmd = new VirtualDmd { AlwaysOnTop = options.VirtualDmdOnTop, GripColor = options.VirtualDmdHideGrip ? Brushes.Transparent : Brushes.White, Left = options.VirtualDmdPosition[0], Top = options.VirtualDmdPosition[1], Width = options.VirtualDmdPosition[2], Height = height, IgnoreAspectRatio = ignoreAr, DotSize = options.VirtualDmdDotSize }; var thread = new Thread(() => { // Create our context, and install it: SynchronizationContext.SetSynchronizationContext(new DispatcherSynchronizationContext(CurrentDispatcher)); // When the window closes, shut down the dispatcher dmd.Closed += (s, e) => CurrentDispatcher.BeginInvokeShutdown(DispatcherPriority.Background); dmd.Dispatcher.Invoke(() => { dmd.Dmd.Init(); dmd.Show(); }); // Start the Dispatcher Processing Run(); }); thread.SetApartmentState(ApartmentState.STA); thread.Start(); return(dmd.Dmd); }
/// <summary> /// Tuät ä nii Inschantz vom virtueuä DMD kreiärä und tuät drnah d /// Render-Graphä drabindä. /// </summary> private void CreateVirtualDmd() { var thread = new Thread(() => { _dmd = new VirtualDmd(); SetupGraphs(); // Create our context, and install it: SynchronizationContext.SetSynchronizationContext(new DispatcherSynchronizationContext(CurrentDispatcher)); // When the window closes, shut down the dispatcher _dmd.Closed += (s, e) => CurrentDispatcher.BeginInvokeShutdown(DispatcherPriority.Background); _dmd.Dispatcher.Invoke(SetupVirtualDmd); // Start the Dispatcher Processing Run(); }); thread.SetApartmentState(ApartmentState.STA); thread.Start(); }