Encapsulates log entry
        /// <summary>
        /// Initializes a new instance of the <see cref="LogviewDialog"/> class.
        /// </summary>
        /// <param name="logEntry">The log entry.</param>
        public LogviewDialog(LogEntry logEntry)
        {
            InitializeComponent();

            if (logEntry == null)
            {
                this.Close();
            }

            this.lblDateTime.Text = string.Concat("at ", logEntry.LogTime);
            this.txtLogType.Text = logEntry.Logtype.ToString();
            this.txtMessage.Text = logEntry.Message;
            this.txtStackTrace.Text = logEntry.StackTrace;
            this.txtUserName.Text = logEntry.UserName;
            this.txtSource.Text = logEntry.Source;
            this.btnCopyToClipboard.Visible = !string.IsNullOrEmpty(logEntry.StackTrace);
        }
        /// <summary>
        /// Writes to log.
        /// </summary>
        /// <param name="ex">The ex.</param>
        public static void WriteToLog(this Exception ex)
        {
            LogEntry logentry = new LogEntry
            {
                Source = ex.Source,
                Logtype = LogType.Error,
                Message = ex.Message,
                StackTrace = ex.StackTrace,
            };

            logentry.StoreLogEntry();
        }
        /// <summary>
        /// Writes to log.
        /// </summary>
        /// <param name="message">The message.</param>
        public static void WriteToLog(this string message)
        {
            LogEntry logentry = new LogEntry
            {
                Source = string.Empty,
                Logtype = LogType.Information,
                Message = message,
                StackTrace = string.Empty,
            };

            logentry.StoreLogEntry();
        }
        /// <summary>
        /// Handles the CellDoubleClick event of the dgvLogView control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="System.Windows.Forms.DataGridViewCellEventArgs"/> instance containing the event data.</param>
        private void dgvLogView_CellDoubleClick(object sender, DataGridViewCellEventArgs e)
        {
            if (e.RowIndex == -1)
            {
                return;
            }

            DataGridViewRow row = this.dgvLogView.Rows[e.RowIndex];
            LogEntry logentry = new LogEntry
            {
                Logtype = this.GetLogType(this.dgvLogView.Rows[e.RowIndex].Cells["Logtype"].Value.ToString()),
                Message = this.dgvLogView.Rows[e.RowIndex].Cells["Message"].Value.ToString(),
                Source = this.dgvLogView.Rows[e.RowIndex].Cells["Source"].Value.ToString(),
                StackTrace = this.dgvLogView.Rows[e.RowIndex].Cells["StackTrace"].Value.ToString()
            };

            using (LogviewDialog dialog = new LogviewDialog(logentry))
            {
                dialog.TopMost = true;
                if (DialogResult.OK == dialog.ShowDialog(this))
                {
                    this.BringToFront();
                }
            }
        }