Ejemplo n.º 1
0
        private void ApplyOptions(DebugWindowLoggerOptions options)
        {
            if (InvokeRequired)
            {
                BeginInvoke((Action)(() => ApplyOptions(options)));
                return;
            }

            Text = !string.IsNullOrEmpty(options.WindowTitle)
                                ? options.WindowTitle
                                : _HostEnvironment.ApplicationName;

            if (NotifyIcon != null)
            {
                NotifyIcon.Text = Text;
            }

            Size = new Size(options.WindowWidth, options.WindowHeight);

            if (options.StartMinimized)
            {
                WindowState = FormWindowState.Minimized;
            }

            _JsonOptions = options.JsonOptions ?? DebugWindowLoggerOptions.DefaultJsonOptions;

            _LoggerGroupCache = new LoggerGroupCache(options.GroupOptions ?? DebugWindowLoggerOptions.DefaultGroupOptions);
        }
Ejemplo n.º 2
0
        /// <inheritdoc />
        public Task StartAsync(CancellationToken cancellationToken)
        {
            DebugWindowLoggerOptions Options = _Options.CurrentValue;

            if (Options.LaunchDebuggerIfNotAttached && !Debugger.IsAttached)
            {
                Debugger.Launch();
            }

            if (Options.ShowDebugWindow)
            {
                if (Options.HideConsoleIfAttachedWhenShowingWindow)
                {
                    _ConsoleWindowHandle = NativeMethods.GetConsoleWindow();
                    if (_ConsoleWindowHandle != IntPtr.Zero)
                    {
                        NativeMethods.ShowWindow(_ConsoleWindowHandle, NativeMethods.SW_HIDE);
                    }
                }

                // This is done here and not in "ConfigureLogging" so we don't pay a performance penalty in prod when not using the UI.
                _LoggerFactory.AddProvider(_DebugWindowLoggerProvider);

                _FormThread = new Thread(FormThreadBody)
                {
                    Priority = ThreadPriority.Normal,
                    Name     = "DebugWindow UI"
                };
                _FormThread.Start();
            }

            return(Task.CompletedTask);
        }
Ejemplo n.º 3
0
        private void CreateDebugWindow()
        {
            DebugWindowLoggerOptions Options = _Options.CurrentValue;

            if (Options.ShowDebugWindow)
            {
                // This is done here and not in "ConfigureLogging" so we don't pay a performance penalty in prod when not using the UI.
                _LoggerFactory.AddProvider(_DebugWindowLoggerProvider);

                _FormThread = new Thread(FormThreadBody)
                {
                    Priority = ThreadPriority.Normal,
                    Name     = "DebugWindow UI"
                };
                _FormThread.Start();
            }
        }
Ejemplo n.º 4
0
        /// <inheritdoc />
        public Task StartAsync(CancellationToken cancellationToken)
        {
            DebugWindowLoggerOptions Options = _Options.CurrentValue;

            if (Options.LaunchDebuggerIfNotAttached && !Debugger.IsAttached)
            {
                Debugger.Launch();
            }

            if (Options.ShowDebugWindow && Options.HideConsoleIfAttachedWhenShowingWindow)
            {
                _ConsoleWindowHandle = NativeMethods.GetConsoleWindow();
                if (_ConsoleWindowHandle != IntPtr.Zero)
                {
                    NativeMethods.ShowWindow(_ConsoleWindowHandle, NativeMethods.SW_HIDE);
                }
            }

            return(Task.CompletedTask);
        }