예제 #1
0
        private static IDestination ShowVirtualDmd(IVirtualDmdConfig config)
        {
            var dmd = new VirtualDmd {
                AlwaysOnTop       = config.StayOnTop,
                Left              = config.Left,
                Top               = config.Top,
                Width             = config.Width,
                Height            = config.Height,
                IgnoreAspectRatio = config.IgnoreAr,
                DotSize           = config.DotSize
            };
            var thread = new Thread(() => {
                // Create our context, and install it:
                SynchronizationContext.SetSynchronizationContext(new DispatcherSynchronizationContext(CurrentDispatcher));

                dmd.Dispatcher.Invoke(() => {
                    dmd.Dmd.Init();
                    dmd.Show();
                });

                // Start the Dispatcher Processing
                Run();
            });

            // On closing the window, shut down the dispatcher associated with the thread.
            // This will allow the thread to exit after the window is closed and all of
            // the events resulting from the window close have been processed.
            dmd.Closed += (s, e) => Dispatcher.FromThread(thread).BeginInvokeShutdown(DispatcherPriority.Background);

            // run the thread
            thread.SetApartmentState(ApartmentState.STA);
            thread.Start();
            return(dmd.VirtualControl);
        }
예제 #2
0
        /// <summary>
        /// Tuät ä nii Inschantz vom virtueuä DMD kreiärä und tuät drnah d
        /// Render-Graphä drabindä.
        /// </summary>
        private void CreateVirtualDmd()
        {
            // set up an event object to synchronize with the thread startup
            var ev = new EventWaitHandle(false, EventResetMode.AutoReset);

            // launch a thrtead for the virtual DMD window event handler
            var thread = new Thread(() => {
                // create the virtual DMD window and create the render grahps
                _dmd = new VirtualDmd();
                //---_alphaNumericDisplay = new VirtualAlphaNumericDisplay();
                SetupGraphs();

                // Create our context, and install it:
                SynchronizationContext.SetSynchronizationContext(new DispatcherSynchronizationContext(Dispatcher.CurrentDispatcher));

                // When the window closes, shut down the dispatcher
                _dmd.Closed += (s, e) => _dmd.Dispatcher.BeginInvokeShutdown(DispatcherPriority.Background);
                _dmd.Dispatcher.Invoke(SetupVirtualDmd);

                // we're done with the setup - let the calling thread proceed
                ev.Set();

                // Start the Dispatcher Processing
                Dispatcher.Run();
            });

            thread.SetApartmentState(ApartmentState.STA);
            thread.Start();

            // wait until the virtual DMD window is fully set up, to avoid any
            // race conditions with the UI thread
            ev.WaitOne();
            ev.Dispose();
        }
예제 #3
0
        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);
        }
예제 #4
0
        private static IDestination ShowVirtualDmd(IConfiguration config)
        {
            var dmd = new VirtualDmd {
                Left   = config.VirtualDmd.Left,
                Top    = config.VirtualDmd.Top,
                Width  = config.VirtualDmd.Width,
                Height = config.VirtualDmd.Height
            };

            dmd.Setup(config as Configuration, config is Configuration iniConfig ? iniConfig.GameName : null);
            var thread = new Thread(() => {
                // Create our context, and install it:
                SynchronizationContext.SetSynchronizationContext(new DispatcherSynchronizationContext(CurrentDispatcher));

                dmd.Dispatcher.Invoke(() => {
                    dmd.Dmd.Init();
                    dmd.Show();
                });

                // Start the Dispatcher Processing
                Run();
            });

            // On closing the window, shut down the dispatcher associated with the thread.
            // This will allow the thread to exit after the window is closed and all of
            // the events resulting from the window close have been processed.
            dmd.Closed += (s, e) => Dispatcher.FromThread(thread).BeginInvokeShutdown(DispatcherPriority.Background);

            // run the thread
            thread.SetApartmentState(ApartmentState.STA);
            thread.Start();
            return(dmd.VirtualControl);
        }
예제 #5
0
        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));

                // create the window
                dmd.Dispatcher.Invoke(() => {
                    dmd.Dmd.Init();
                    dmd.Show();
                });

                // Start the Dispatcher Processing
                Run();
            });

            // On closing the window, shut down the dispatcher associated with the thread.
            // This will allow the thread to exit after the window is closed and all of
            // the events resulting from the window close have been processed.
            dmd.Closed += (s, e) => Dispatcher.FromThread(thread).BeginInvokeShutdown(DispatcherPriority.Background);

            // run the thread
            thread.SetApartmentState(ApartmentState.STA);
            thread.Start();
            return(dmd.Dmd);
        }
예제 #6
0
        /// <summary>
        /// Tuät aui Renderer ahautä unds virtueua DMD vrschteckä.
        /// </summary>
        public void Close()
        {
            Logger.Info("Closing up.");
            _graphs.ClearDisplay();
            _graphs.Dispose();
            try {
                _virtualDmd?.Dispatcher.Invoke(() => _virtualDmd.Close());
                _virtualDmd = null;
            } catch (TaskCanceledException e) {
                Logger.Warn(e, "Could not hide DMD because task was already canceled.");
            }

            _color          = RenderGraph.DefaultColor;
            _palette        = null;
            _gray2Colorizer = null;
            _gray4Colorizer = null;
            _coloring       = null;
            _isOpen         = false;
        }
예제 #7
0
        /// <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();
        }