Esempio 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);
        }
Esempio 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);
        }
Esempio 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();
            }
        }
        /// <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);
        }