Ejemplo n.º 1
0
        // Constructors
        public LogWindow(LogReader logReader)
        {
            if (logReader == null)
            {
                throw new ArgumentNullException("logReader");
            }

            this.initialize(logReader);
        }
Ejemplo n.º 2
0
        // Initialisation
        private void initialize(LogReader logReader, ColumnDefinition[] columns = null, ParseRule[] parseRules = null, HighlightRule[] highlightRules = null)
        {
            // Form initialisation
            InitializeComponent();
            this.dgvLogMessages.DefaultCellStyle.WrapMode = DataGridViewTriState.True;

            // Setup rules
            this.columns        = columns?.ToList() ?? new List <ColumnDefinition>();
            this.parseRules     = parseRules?.ToList() ?? new List <ParseRule>();
            this.highlightRules = highlightRules?.ToList() ?? new List <HighlightRule>();

            // Setup message handling
            this.lineHistory      = new Queue <string>();
            logReader.LogMessage += onLogMessage;

            // Column initialisation
            this.updateColumns();
        }
Ejemplo n.º 3
0
        public LogWindow(LogReader logReader, ColumnDefinition[] columns, ParseRule[] parseRules, HighlightRule[] highlightRules)
        {
            if (logReader == null)
            {
                throw new ArgumentNullException("logReader");
            }
            if (parseRules == null)
            {
                throw new ArgumentNullException("parseRules");
            }
            if (highlightRules == null)
            {
                throw new ArgumentNullException("highlightRules");
            }
            if (columns == null)
            {
                throw new ArgumentNullException("columns");
            }

            this.initialize(logReader, columns, parseRules, highlightRules);
        }
Ejemplo n.º 4
0
        private void Form1_Shown(object sender, EventArgs e)
        {
            this.statusStrip_Resize(sender, e);

            // Force the window to be on top for agressive prompt
            this.BringToFront();

            // Prompt for log file
            DialogResult result      = DialogResult.No;
            string       logFilePath = null;

            while (result == DialogResult.No)
            {
                logFilePath = this.selectLogFile();
                if (!string.IsNullOrEmpty(logFilePath))
                {
                    break;
                }

                result = MessageBox.Show("No valid log file has been selected, would you like to exit?", "No log file", MessageBoxButtons.YesNo, MessageBoxIcon.Error);
                if (result == DialogResult.Yes)
                {
                    this.Close();
                    return;
                }
            }

            // Initialise log reader
            result = DialogResult.Retry;
            while (result == DialogResult.Retry)
            {
                try
                {
                    this.logReader = new LogReader(logFilePath);
                    break;
                }
                catch (Exception ex)
                {
                    result = MessageBox.Show($"An error occured while trying to open the log file for reading. Please use the following error message to resolve the issue and retry:{Environment.NewLine}{ex.Message}", ex.GetType().Name, MessageBoxButtons.RetryCancel, MessageBoxIcon.Error);
                    if (result == DialogResult.Cancel)
                    {
                        this.Close();
                        return;
                    }
                }
            }

            this.logReader.Exception += LogReader_Exception;
            this.logReader.Progress  += LogReader_Progress;

            // Initialise windows
            this.loadWindowsFromSettings();

            // Tile windows
            this.tileHorizontalToolStripMenuItem_Click(sender, e);

            // Unhandled messages window
            this.unhandledMessages = new UnhandledMessages(this.logReader)
            {
                MdiParent = this
            };

            // Prompt for skipping to end of log
            this.logReader.Run(MessageBox.Show("Do you want to skip to the end of the log file?", "Skip past log", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button1) == DialogResult.Yes);
        }
 public UnhandledMessages(LogReader logReader)
 {
     InitializeComponent();
     this.logReader = logReader;
 }