Exemple #1
0
        private void DrawNodeText(DrawTreeNodeEventArgs e)
        {
            if (e.Node.Bounds.IsEmpty)
            {
                return;
            }

            Rectangle bounds = e.Node.Bounds;

            Font font = FontCache.GetFontFromIdentifier(
                tvLoggerTree.Font.Name
                , tvLoggerTree.Font.Size
                , tvLoggerTree.Font.Style);

            bounds.Width = TextRenderer.MeasureText(e.Node.Text, font).Width;
            bounds.Y    -= 1;
            bounds.X    += 1;

            if (e.Node.Level == 0 && e.Node.PrevNode == null)
            {
                bounds = new Rectangle(
                    tvLoggerTree.Margin.Size.Width + ThemeManager.CurrentApplicationTheme.Resources.Images["FrmLogTreeNodeExpanded"].Width + 9
                    , 0
                    , bounds.Width
                    , bounds.Height);
            }

            TextRenderer.DrawText(e.Graphics, e.Node.Text, font, bounds, e.Node.ForeColor);
        }
Exemple #2
0
        /// <summary>
        /// Decreases the size of the <see cref="ILogPresenter"/> content.
        /// </summary>
        /// <returns><c>True</c> if further decreasing is possible, otherwise <c>false</c>.</returns>
        public bool ZoomOut()
        {
            if (tblLogMessage.Font.Size > MIN_ZOOM_LEVEL)
            {
                try
                {
                    this.SuspendDrawing();

                    tblLogMessage.Font = FontCache.GetFontFromIdentifier(
                        Font.Name
                        , tblLogMessage.Font.Size - 1
                        , FontStyle.Regular);

                    mBoldCaptionFont = FontCache.GetFontFromIdentifier(
                        Font.Name
                        , mBoldCaptionFont.Size - 1
                        , FontStyle.Bold);

                    lblCaptionNumber.Font    = mBoldCaptionFont;
                    lblCaptionLevel.Font     = mBoldCaptionFont;
                    lblCaptionTime.Font      = mBoldCaptionFont;
                    lblCaptionProcessId.Font = mBoldCaptionFont;
                    lblCaptionMessage.Font   = mBoldCaptionFont;

                    return(tblLogMessage.Font.Size > MIN_ZOOM_LEVEL);
                }
                finally
                {
                    this.ResumeDrawing();
                }
            }

            return(false);
        }
        /// <summary>
        /// Increases the size of the <see cref="ILogPresenter"/> content.
        /// </summary>
        /// <returns><c>True</c> if further increasing is possible, otherwise <c>false</c>.</returns>
        public bool ZoomIn()
        {
            if (tblLogMessage.Font.Size < MAX_ZOOM_LEVEL)
            {
                try
                {
                    this.SuspendDrawing();

                    tblLogMessage.Font = FontCache.GetFontFromIdentifier(
                        Font.Name
                        , tblLogMessage.Font.Size + 1
                        , FontStyle.Regular);

                    mBoldCaptionFont = FontCache.GetFontFromIdentifier(
                        Font.Name
                        , mBoldCaptionFont.Size + 1
                        , FontStyle.Bold);

                    lblCaptionLogger.Font   = mBoldCaptionFont;
                    lblCaptionLevel.Font    = mBoldCaptionFont;
                    lblCaptionThread.Font   = mBoldCaptionFont;
                    lblCaptionDateTime.Font = mBoldCaptionFont;
                    lblCaptionMessage.Font  = mBoldCaptionFont;

                    return(tblLogMessage.Font.Size < MAX_ZOOM_LEVEL);
                }
                finally
                {
                    this.ResumeDrawing();
                }
            }

            return(false);
        }
        /// <summary>
        /// Creates a new instance of the <see cref="FrmLogWindow"/> window.
        /// </summary>
        /// <param name="logProvider">The <see cref="ILogProvider"/> that sends messages to this window.</param>
        /// <param name="logContainer">The <see cref="ILogContainer"/> that contains the source for <see cref="LogMessage"/>s.</param>
        public FrmLogWindow(ILogProvider logProvider, ILogContainer logContainer)
        {
            InitializeComponent();

            mLogcontainer = logContainer;
            mBookmarks    = new List <LogMessage>();
            InitializeColumns(logProvider);

            if (!logProvider.HasLoggerTree)
            {
                // Remove the synchronize tree menu item if no tree is available.
                cmLogMessage.Items.Remove(cmsSynchronizeTree);
                cmLogMessage.Items.Remove(cmsSeperator);
            }

            ThemeManager.ApplyTo(this);

            if (!string.IsNullOrEmpty(Settings.Default.LogMessagesFontName))
            {
                try
                {
                    dtgLogMessages.DefaultCellStyle.Font = FontCache.GetFontFromIdentifier(
                        Settings.Default.LogMessagesFontName
                        , Settings.Default.LogMessagesFontSize
                        , FontStyle.Regular);
                }
                catch
                {
                    // Reset the font on error.
                    dtgLogMessages.Font = FontCache.GetFontFromIdentifier(
                        DEFAULT_FONT_NAME
                        , DEFAULT_FONT_SIZE
                        , FontStyle.Regular);

                    mRowHeight = dtgLogMessages.RowTemplate.Height;

                    // Save the changed settings as new default.
                    Settings.Default.LogMessagesFontName = DEFAULT_FONT_NAME;
                    Settings.Default.LogMessagesFontSize = DEFAULT_FONT_SIZE;

                    Settings.Default.SaveSettings();
                }
            }

            if (Settings.Default.EnableColorMap)
            {
                tableLayoutPanel1.SetColumnSpan(dtgLogMessages, 1);
                colorMap1.Visible = true;
            }
            else
            {
                colorMap1.Visible = false;
                tableLayoutPanel1.SetColumnSpan(dtgLogMessages, 2);
            }

            // Listening for settings changes.
            Settings.Default.SettingChanging += DefaultSettingChanging;
        }
Exemple #5
0
        /// <summary>
        /// Creates anew instance of the <see cref="WinDebugDetailsControl"/> <see cref="Control"/>.
        /// </summary>
        public WinDebugDetailsControl()
        {
            InitializeComponent();

            // Apply the current application theme to the control.
            ThemeManager.ApplyTo(this);

            mBoldCaptionFont = FontCache.GetFontFromIdentifier(
                Font.Name
                , Font.Size
                , FontStyle.Bold);

            lblCaptionNumber.Font    = mBoldCaptionFont;
            lblCaptionLevel.Font     = mBoldCaptionFont;
            lblCaptionTime.Font      = mBoldCaptionFont;
            lblCaptionProcessId.Font = mBoldCaptionFont;
            lblCaptionMessage.Font   = mBoldCaptionFont;
        }
Exemple #6
0
        /// <summary>
        /// Decreases the size of the <see cref="ILogPresenter"/> content.
        /// </summary>
        /// <returns><c>True</c> if further decreasing is possible, otherwise <c>false</c>.</returns>
        public bool ZoomOut()
        {
            if (tblLogMessage.Font.Size > MIN_ZOOM_LEVEL)
            {
                try
                {
                    this.SuspendDrawing();

                    tblLogMessage.Font = FontCache.GetFontFromIdentifier(
                        Font.Name
                        , tblLogMessage.Font.Size - 1
                        , FontStyle.Regular);

                    mBoldCaptionFont = FontCache.GetFontFromIdentifier(
                        Font.Name
                        , mBoldCaptionFont.Size - 1
                        , FontStyle.Bold);

                    lblCaptionNumber.Font = mBoldCaptionFont;

                    foreach (Control ctrl in tblLogMessage.Controls)
                    {
                        Label lblCaption = ctrl as Label;

                        if (lblCaption == null || !(lblCaption.Tag is LogColumn))
                        {
                            // Ignore not matching textboxes.
                            continue;
                        }

                        lblCaption.Font = mBoldCaptionFont;
                    }

                    return(tblLogMessage.Font.Size > MIN_ZOOM_LEVEL);
                }
                finally
                {
                    this.ResumeDrawing();
                }
            }

            return(false);
        }
        /// <summary>
        /// Creates anew instance of the <see cref="Log4NetDetailsControl"/> <see cref="Control"/>.
        /// </summary>
        public Log4NetDetailsControl()
        {
            InitializeComponent();

            // Apply the current application theme to the control.
            ThemeManager.ApplyTo(this);

            mBoldCaptionFont = FontCache.GetFontFromIdentifier(
                Font.Name
                , Font.Size
                , FontStyle.Bold);

            lblCaptionLogger.Font     = mBoldCaptionFont;
            lblCaptionLevel.Font      = mBoldCaptionFont;
            lblCaptionThread.Font     = mBoldCaptionFont;
            lblCaptionDateTime.Font   = mBoldCaptionFont;
            lblCaptionMessage.Font    = mBoldCaptionFont;
            lblCaptionLocation.Font   = mBoldCaptionFont;
            lblCaptionProperties.Font = mBoldCaptionFont;
        }
Exemple #8
0
        /// <summary>
        /// Creates anew instance of the <see cref="SyslogDetailsControl"/> <see cref="Control"/>.
        /// </summary>
        public SyslogDetailsControl()
        {
            InitializeComponent();

            // Apply the current application theme to the control.
            ThemeManager.ApplyTo(this);

            mBoldCaptionFont = FontCache.GetFontFromIdentifier(
                Font.Name
                , Font.Size
                , FontStyle.Bold);

            lblCaptionNumber.Font           = mBoldCaptionFont;
            lblCaptionSeverity.Font         = mBoldCaptionFont;
            lblCaptionTime.Font             = mBoldCaptionFont;
            lblCaptionLocalMachineTime.Font = mBoldCaptionFont;
            lblCaptionFacility.Font         = mBoldCaptionFont;
            lblCaptionSender.Font           = mBoldCaptionFont;
            lblCaptionMessage.Font          = mBoldCaptionFont;
        }
        /// <summary>
        /// Creates anew instance of the <see cref="Log4NetDetailsControl"/> <see cref="Control"/>.
        /// </summary>
        public Socks5DetailsControl()
        {
            InitializeComponent();

            // Apply the current application theme to the control.
            ThemeManager.ApplyTo(this);

            mBoldCaptionFont = FontCache.GetFontFromIdentifier(
                Font.Name
                , Font.Size
                , FontStyle.Bold);

            lblCaptionLogger.Font   = mBoldCaptionFont;
            lblCaptionLevel.Font    = mBoldCaptionFont;
            lblCaptionThread.Font   = mBoldCaptionFont;
            lblCaptionDateTime.Font = mBoldCaptionFont;
            lblCaptionMessage.Font  = mBoldCaptionFont;

            _resetHexBoxEmpty();
        }
Exemple #10
0
        /// <summary>
        /// Creates anew instance of the <see cref="CustomDetailsControl"/> <see cref="Control"/>.
        /// </summary>
        public CustomDetailsControl(Columnizer columnizer)
        {
            InitializeComponent();

            mColumnizer      = columnizer;
            mBoldCaptionFont = FontCache.GetFontFromIdentifier(
                Font.Name
                , Font.Size
                , FontStyle.Bold);

            lblCaptionNumber.Font = mBoldCaptionFont;

            foreach (LogColumn column in columnizer.Columns)
            {
                AddLogMsgRowItem(column);
            }

            // Apply the current application theme to the control.
            ThemeManager.ApplyTo(this);
        }
        /// <summary>
        /// Creates anew instance of the <see cref="SyslogDetailsControl"/> <see cref="Control"/>.
        /// </summary>
        public EventLogDetailsControl()
        {
            InitializeComponent();

            // Apply the current application theme to the control.
            ThemeManager.ApplyTo(this);

            mBoldCaptionFont = FontCache.GetFontFromIdentifier(
                Font.Name
                , Font.Size
                , FontStyle.Bold);

            lblCaptionNumber.Font      = mBoldCaptionFont;
            lblCaptionLevel.Font       = mBoldCaptionFont;
            lblCaptionLogger.Font      = mBoldCaptionFont;
            lblCaptionDateAndTime.Font = mBoldCaptionFont;
            lblCaptionCategory.Font    = mBoldCaptionFont;
            lblCaptionUsername.Font    = mBoldCaptionFont;
            lblCaptionInstanceId.Font  = mBoldCaptionFont;
            lblCaptionMessage.Font     = mBoldCaptionFont;
        }
        /// <summary>
        /// Decreases the size of the <see cref="ILogPresenter"/> content.
        /// </summary>
        /// <returns><c>True</c> if further decreasing is possible, otherwise <c>false</c>.</returns>
        public bool ZoomOut()
        {
            if (dtgLogMessages.Font.Size > MIN_ZOOM_LEVEL)
            {
                using (new WaitCursor(Cursors.Default, Settings.Default.WaitCursorTimeout))
                {
                    try
                    {
                        dtgLogMessages.SuspendDrawing();

                        dtgLogMessages.DefaultCellStyle.Font = FontCache.GetFontFromIdentifier(
                            dtgLogMessages.DefaultCellStyle.Font.Name
                            , dtgLogMessages.DefaultCellStyle.Font.Size - 1
                            , FontStyle.Regular);

                        dtgLogMessages.Font = dtgLogMessages.DefaultCellStyle.Font;

                        --mRowHeight;

                        dtgLogMessages.AutoResizeRows(
                            DataGridViewAutoSizeRowsMode.DisplayedCells);

                        if (dtgLogMessages.RowCount > 0)
                        {
                            // Force a refresh of the layout after zoom.
                            dtgLogMessages.UpdateRowHeightInfo(0, true);
                        }
                    }
                    finally
                    {
                        dtgLogMessages.ResumeDrawing();
                    }
                }

                return(dtgLogMessages.DefaultCellStyle.Font.Size > MIN_ZOOM_LEVEL);
            }

            return(false);
        }
        /// <summary>
        /// Decreases the size of the <see cref="ILogPresenter"/> content.
        /// </summary>
        /// <returns><c>True</c> if further decreasing is possible, otherwise <c>false</c>.</returns>
        public bool ZoomOut()
        {
            if (dgvBookmarks.Font.Size > MIN_ZOOM_LEVEL)
            {
                try
                {
                    dgvBookmarks.SuspendDrawing();

                    dgvBookmarks.Font = FontCache.GetFontFromIdentifier(
                        Font.Name
                        , dgvBookmarks.Font.Size - 1
                        , FontStyle.Regular);

                    return(dgvBookmarks.Font.Size > MIN_ZOOM_LEVEL);
                }
                finally
                {
                    dgvBookmarks.ResumeDrawing();
                }
            }

            return(false);
        }
Exemple #14
0
        /// <summary>
        /// Increases the size of the <see cref="ILogPresenter"/> content.
        /// </summary>
        /// <returns><c>True</c> if further increasing is possible, otherwise <c>false</c>.</returns>
        public bool ZoomIn()
        {
            if (dgvFilter.Font.Size < MAX_ZOOM_LEVEL)
            {
                try
                {
                    dgvFilter.SuspendDrawing();

                    dgvFilter.Font = FontCache.GetFontFromIdentifier(
                        Font.Name
                        , dgvFilter.Font.Size + 1
                        , FontStyle.Regular);

                    return(dgvFilter.Font.Size < MAX_ZOOM_LEVEL);
                }
                finally
                {
                    dgvFilter.ResumeDrawing();
                }
            }

            return(false);
        }
Exemple #15
0
        /// <summary>
        /// Decreases the size of the <see cref="ILogPresenter"/> content.
        /// </summary>
        /// <returns><c>True</c> if further decreasing is possible, otherwise <c>false</c>.</returns>
        public bool ZoomOut()
        {
            if (tvLoggerTree.Font.Size > MIN_ZOOM_LEVEL)
            {
                try
                {
                    tvLoggerTree.SuspendDrawing();

                    tvLoggerTree.Font = FontCache.GetFontFromIdentifier(
                        Font.Name
                        , tvLoggerTree.Font.Size - 1
                        , FontStyle.Regular);

                    return(tvLoggerTree.Font.Size > MIN_ZOOM_LEVEL);
                }
                finally
                {
                    tvLoggerTree.ResumeDrawing();
                }
            }

            return(false);
        }
Exemple #16
0
        /// <summary>
        /// Increases the size of the <see cref="ILogPresenter"/> content.
        /// </summary>
        /// <returns><c>True</c> if further increasing is possible, otherwise <c>false</c>.</returns>
        public bool ZoomIn()
        {
            if (tblLogMessage.Font.Size < MAX_ZOOM_LEVEL)
            {
                try
                {
                    this.SuspendDrawing();

                    tblLogMessage.Font = FontCache.GetFontFromIdentifier(
                        Font.Name
                        , tblLogMessage.Font.Size + 1
                        , FontStyle.Regular);

                    mBoldCaptionFont = FontCache.GetFontFromIdentifier(
                        Font.Name
                        , mBoldCaptionFont.Size + 1
                        , FontStyle.Bold);

                    lblCaptionNumber.Font           = mBoldCaptionFont;
                    lblCaptionSeverity.Font         = mBoldCaptionFont;
                    lblCaptionTime.Font             = mBoldCaptionFont;
                    lblCaptionLocalMachineTime.Font = mBoldCaptionFont;
                    lblCaptionFacility.Font         = mBoldCaptionFont;
                    lblCaptionSender.Font           = mBoldCaptionFont;
                    lblCaptionTime.Font             = mBoldCaptionFont;

                    return(tblLogMessage.Font.Size < MAX_ZOOM_LEVEL);
                }
                finally
                {
                    this.ResumeDrawing();
                }
            }

            return(false);
        }
        /// <summary>
        /// Handles the CellPainting event of the <see cref="DataGridView"/>.
        /// </summary>
        private void DtgLogMessagesCellPainting(object sender, DataGridViewCellPaintingEventArgs e)
        {
            if (e.RowIndex >= mFilteredLogMessages.Count || e.RowIndex < 0)
            {
                return;
            }

            if ((e.State & DataGridViewElementStates.Visible) == DataGridViewElementStates.None)
            {
                return;
            }

            Color     foreColor       = SystemColors.WindowText;
            Color     backColor       = SystemColors.Window;
            Brush     backgroundBrush = null;
            FontStyle fontStyle       = FontStyle.Regular;

            switch (mFilteredLogMessages[e.RowIndex].Level)
            {
            case LogLevel.Trace:
                foreColor       = Settings.Default.ForegroundColorTrace;
                backColor       = Settings.Default.BackgroundColorTrace;
                fontStyle       = Settings.Default.FontStyleTrace;
                backgroundBrush = GdiCache.GetBrushFromColor(backColor);
                break;

            case LogLevel.Debug:
                foreColor       = Settings.Default.ForegroundColorDebug;
                backColor       = Settings.Default.BackgroundColorDebug;
                fontStyle       = Settings.Default.FontStyleDebug;
                backgroundBrush = GdiCache.GetBrushFromColor(backColor);
                break;

            case LogLevel.Info:
                foreColor       = Settings.Default.ForegroundColorInfo;
                backColor       = Settings.Default.BackgroundColorInfo;
                fontStyle       = Settings.Default.FontStyleInfo;
                backgroundBrush = GdiCache.GetBrushFromColor(backColor);
                break;

            case LogLevel.Warning:
                foreColor       = Settings.Default.ForegroundColorWarning;
                backColor       = Settings.Default.BackgroundColorWarning;
                fontStyle       = Settings.Default.FontStyleWarning;
                backgroundBrush = GdiCache.GetBrushFromColor(backColor);
                break;

            case LogLevel.Error:
                foreColor       = Settings.Default.ForegroundColorError;
                backColor       = Settings.Default.BackgroundColorError;
                fontStyle       = Settings.Default.FontStyleError;
                backgroundBrush = GdiCache.GetBrushFromColor(backColor);
                break;

            case LogLevel.Fatal:
                foreColor       = Settings.Default.ForegroundColorFatal;
                backColor       = Settings.Default.BackgroundColorFatal;
                fontStyle       = Settings.Default.FontStyleFatal;
                backgroundBrush = GdiCache.GetBrushFromColor(backColor);
                break;
            }

            if ((e.State & DataGridViewElementStates.Selected) == DataGridViewElementStates.Selected)
            {
                if (Settings.Default.UseInvertedColorForSelection)
                {
                    // Invert the colors for selected items.
                    Color tmpForecolor = foreColor;

                    foreColor       = backColor;
                    backColor       = tmpForecolor;
                    backgroundBrush = GdiCache.GetBrushFromColor(tmpForecolor);
                }
                else
                {
                    // Use the default system colors for selected items.
                    foreColor       = SystemColors.HighlightText;
                    backColor       = SystemColors.MenuHighlight;
                    backgroundBrush = GdiCache.GetBrushFromColor(backColor);
                }
            }

            if (backgroundBrush != null)
            {
                e.Graphics.FillRectangle(
                    backgroundBrush
                    , e.CellBounds);

                if (e.ColumnIndex == 0)
                {
                    // the first column may be an image.
                    e.PaintContent(e.CellBounds);
                }
                else
                {
                    Font logFont = FontCache.GetFontFromIdentifier(
                        e.CellStyle.Font.Name
                        , e.CellStyle.Font.Size
                        , fontStyle);

                    TextRenderer.DrawText(
                        e.Graphics
                        , e.Value.ToString()
                        , logFont
                        , e.CellBounds
                        , foreColor
                        , backColor
                        , TextFormatFlags.SingleLine | TextFormatFlags.VerticalCenter);
                }

                e.Graphics.DrawRectangle(
                    Settings.Default.LogWindowDrawGrid
            ? GdiCache.GetPenFromColor(dtgLogMessages.GridColor)
            : GdiCache.GetPenFromColor(backColor)
                    , e.CellBounds);

                e.Handled = true;
            }
        }
        /// <summary>
        /// Handles the SettingChanging event of the <see cref="Application"/>.
        /// </summary>
        private void DefaultSettingChanging(object sender, System.Configuration.SettingChangingEventArgs e)
        {
            if (!string.IsNullOrEmpty(Settings.Default.LogMessagesFontName))
            {
                try
                {
                    Settings.Default.SettingChanging -= DefaultSettingChanging;

                    dtgLogMessages.DefaultCellStyle.Font = FontCache.GetFontFromIdentifier(
                        Settings.Default.LogMessagesFontName
                        , Settings.Default.LogMessagesFontSize
                        , FontStyle.Regular);
                }
                catch
                {
                    // Reset the font on error.
                    dtgLogMessages.Font = FontCache.GetFontFromIdentifier(
                        DEFAULT_FONT_NAME
                        , DEFAULT_FONT_SIZE
                        , FontStyle.Regular);

                    mRowHeight = dtgLogMessages.RowTemplate.Height;

                    // Save the changed settings as new default.
                    Settings.Default.LogMessagesFontName = DEFAULT_FONT_NAME;
                    Settings.Default.LogMessagesFontSize = DEFAULT_FONT_SIZE;

                    Settings.Default.SaveSettings();
                }
                finally
                {
                    Settings.Default.SettingChanging += DefaultSettingChanging;
                }
            }

            // Hide the color map control.
            SuspendLayout();

            try
            {
                if (Settings.Default.EnableColorMap)
                {
                    tableLayoutPanel1.SetColumnSpan(dtgLogMessages, 1);
                    colorMap1.Visible = true;

                    colorMap1.UpdateColorMap(mFilteredLogMessages);
                }
                else
                {
                    colorMap1.Visible = false;
                    tableLayoutPanel1.SetColumnSpan(dtgLogMessages, 2);
                }
            }
            finally
            {
                ResumeLayout(true);
            }

            if (e.SettingName.Equals("ColorMapAnnotation"))
            {
                // Force a redraw of the color map control.
                colorMap1.UpdateColorMap(mFilteredLogMessages);
            }

            dtgLogMessages.Refresh();
        }