Beispiel #1
0
        /// <summary>
        /// Add a line to the list view of the output window and parse it with the
        /// output line parser provided.
        /// </summary>
        /// <param name="line">The text to add.</param>
        /// <param name="parser">A line parser.</param>
        /// <param name="foreColor">The colour used to display the text.</param>
        public void AddLineToListView(
            string line, IOutputLineParser parser, Color foreColor)
        {
            line = CleanUpLine(line);
            if (String.IsNullOrEmpty(line))
            {
                return;
            }

            ListViewItem lvi = new ListViewItem(line);

            lvi.ForeColor = foreColor;
            ParsedLine parsedLine = null;

            if (parser == null)
            {
                lvi.Tag = null;
            }
            else
            {
                parsedLine = parser.Parse(line);
                lvi.Tag    = parsedLine;
            }

            if (parsedLine != null && parsedLine.IsError)
            {
                lvi.ImageKey = Constants.ERROR_IMAGE;
            }

            _listViewListView.Items.Add(lvi);
        }
Beispiel #2
0
        /*
         * If the user clicks on a parsed line in the output list
         * view, open the relevant document at the indicated line.
         */

        private void ListViewListView_MouseDoubleClick(
            object sender, MouseEventArgs e)
        {
            if (_listViewListView.SelectedItems.Count == 0)
            {
                return;
            }

            ListViewItem lvi = _listViewListView.SelectedItems[0];

            if (lvi == null)
            {
                return;
            }
            if (lvi.Tag == null)
            {
                return;
            }

            ParsedLine line = lvi.Tag as ParsedLine;

            if (line != null)
            {
                try
                {
                    mainForm.LoadDocumentIntoWindow(line.FilePath, true);

                    if (mainForm.ActiveDocument != null)
                    {
                        mainForm.ActiveDocument.SetLocation(0, line.Line);
                    }
                }
                catch
                {
                    // Fail silently if file fails to open.
                    // Lack of response in UI sufficient feedback.
                }
            }
        }