Beispiel #1
0
        private void SaveEntry()
        {
            HilightEntry entry = (HilightEntry)this.hilightListBox.SelectedItem;

            //if (entry == null)
            //{
            //  AddNewEntry();
            //  return;
            //}

            entry.ForegroundColor    = (Color)this.foregroundColorBox.SelectedItem;
            entry.BackgroundColor    = (Color)this.backgroundColorBox.SelectedItem;
            entry.SearchText         = this.searchStringTextBox.Text;
            entry.IsRegEx            = this.regexCheckBox.Checked;
            entry.IsCaseSensitive    = this.caseSensitiveCheckBox.Checked;
            this.applyButton.Enabled = false;
            this.applyButton.Image   = null;
            entry.IsLedSwitch        = this.ledCheckBox.Checked;
            entry.IsSetBookmark      = this.bookmarkCheckBox.Checked;
            entry.IsStopTail         = this.stopTailCheckBox.Checked;
            entry.IsActionEntry      = this.pluginCheckBox.Checked;
            entry.ActionEntry        = this.currentActionEntry.Copy();
            entry.BookmarkComment    = this.bookmarkComment;
            entry.IsWordMatch        = this.wordMatchCheckBox.Checked;
            entry.IsBold             = this.boldCheckBox.Checked;
            entry.NoBackground       = this.noBackgroundCheckBox.Checked;
            this.hilightListBox.Refresh();
        }
Beispiel #2
0
        private void AddNewEntry()
        {
            if (this.searchStringTextBox.Text.Length > 0)
            {
                // Create a new entry
                HilightEntry entry = new HilightEntry(this.searchStringTextBox.Text,
                                                      this.foregroundColorBox.SelectedColor,
                                                      this.backgroundColorBox.SelectedColor,
                                                      this.regexCheckBox.Checked,
                                                      this.caseSensitiveCheckBox.Checked,
                                                      this.ledCheckBox.Checked,
                                                      this.stopTailCheckBox.Checked,
                                                      this.bookmarkCheckBox.Checked,
                                                      this.pluginCheckBox.Checked,
                                                      this.currentActionEntry,
                                                      this.wordMatchCheckBox.Checked);
                entry.IsBold       = this.boldCheckBox.Checked;
                entry.NoBackground = this.noBackgroundCheckBox.Checked;
                this.hilightListBox.Items.Add(entry);

                // Select the newly created item
                this.currentGroup.HilightEntryList.Add(entry);
                this.hilightListBox.SelectedItem = entry;
            }
        }
Beispiel #3
0
        private void StartEditEntry()
        {
            HilightEntry entry = (HilightEntry)this.hilightListBox.SelectedItem;

            if (entry != null)
            {
                this.searchStringTextBox.Text        = entry.SearchText;
                this.foregroundColorBox.CustomColor  = entry.ForegroundColor;
                this.backgroundColorBox.CustomColor  = entry.BackgroundColor;
                this.foregroundColorBox.SelectedItem = entry.ForegroundColor;
                this.backgroundColorBox.SelectedItem = entry.BackgroundColor;
                this.regexCheckBox.Checked           = entry.IsRegEx;
                this.caseSensitiveCheckBox.Checked   = entry.IsCaseSensitive;
                this.ledCheckBox.Checked             = entry.IsLedSwitch;
                this.bookmarkCheckBox.Checked        = entry.IsSetBookmark;
                this.stopTailCheckBox.Checked        = entry.IsStopTail;
                this.pluginCheckBox.Checked          = entry.IsActionEntry;
                pluginButton.Enabled = pluginCheckBox.Checked;
                this.bookmarkCommentButton.Enabled = this.bookmarkCheckBox.Checked;
                this.currentActionEntry            = entry.ActionEntry != null?entry.ActionEntry.Copy() : new ActionEntry();

                this.bookmarkComment              = entry.BookmarkComment;
                this.wordMatchCheckBox.Checked    = entry.IsWordMatch;
                this.boldCheckBox.Checked         = entry.IsBold;
                this.noBackgroundCheckBox.Checked = entry.NoBackground;
            }
            this.applyButton.Enabled = false;
            this.applyButton.Image   = null;

            ReEvaluateHilightButtonStates();
        }
Beispiel #4
0
        private void SaveEntry()
        {
            try
            {
                CheckRegex();

                HilightEntry entry = (HilightEntry)hilightListBox.SelectedItem;

                entry.ForegroundColor = (Color)foregroundColorBox.SelectedItem;
                entry.BackgroundColor = (Color)backgroundColorBox.SelectedItem;
                entry.SearchText      = searchStringTextBox.Text;
                entry.IsRegEx         = regexCheckBox.Checked;
                entry.IsCaseSensitive = caseSensitiveCheckBox.Checked;
                applyButton.Enabled   = false;
                applyButton.Image     = null;
                entry.IsLedSwitch     = ledCheckBox.Checked;
                entry.IsSetBookmark   = bookmarkCheckBox.Checked;
                entry.IsStopTail      = stopTailCheckBox.Checked;
                entry.IsActionEntry   = pluginCheckBox.Checked;
                entry.ActionEntry     = _currentActionEntry.Copy();
                entry.BookmarkComment = _bookmarkComment;
                entry.IsWordMatch     = wordMatchCheckBox.Checked;
                entry.IsBold          = boldCheckBox.Checked;
                entry.NoBackground    = noBackgroundCheckBox.Checked;
                hilightListBox.Refresh();
            }
            catch (Exception ex)
            {
                _logger.Error(ex, "Error during save of save highlight entry");
                MessageBox.Show($"Error during save of entry.\r\n{ex.Message}");
            }
        }
Beispiel #5
0
        private void AddNewEntry()
        {
            {
                try
                {
                    CheckRegex();

                    // Create a new entry
                    HilightEntry entry = new HilightEntry(searchStringTextBox.Text,
                                                          foregroundColorBox.SelectedColor,
                                                          backgroundColorBox.SelectedColor,
                                                          regexCheckBox.Checked,
                                                          caseSensitiveCheckBox.Checked,
                                                          ledCheckBox.Checked,
                                                          stopTailCheckBox.Checked,
                                                          bookmarkCheckBox.Checked,
                                                          pluginCheckBox.Checked,
                                                          _currentActionEntry,
                                                          wordMatchCheckBox.Checked);
                    entry.IsBold       = boldCheckBox.Checked;
                    entry.NoBackground = noBackgroundCheckBox.Checked;
                    hilightListBox.Items.Add(entry);

                    // Select the newly created item
                    _currentGroup.HilightEntryList.Add(entry);
                    hilightListBox.SelectedItem = entry;
                }
                catch (Exception ex)
                {
                    _logger.Error(ex, "Error during add of highlight entry");
                    MessageBox.Show($"Error during add of entry.\r\n{ex.Message}");
                }
            }
        }
Beispiel #6
0
		private void AddNewEntry()
		{
			if (this.searchStringTextBox.Text.Length > 0)
			{
				// Create a new entry
				HilightEntry entry = new HilightEntry(this.searchStringTextBox.Text,
					this.foregroundColorBox.SelectedColor,
					this.backgroundColorBox.SelectedColor,
					this.regexCheckBox.Checked,
					this.caseSensitiveCheckBox.Checked,
					this.ledCheckBox.Checked,
					this.stopTailCheckBox.Checked,
					this.bookmarkCheckBox.Checked,
					this.pluginCheckBox.Checked,
					this.currentActionEntry,
					this.wordMatchCheckBox.Checked);
				entry.IsBold = this.boldCheckBox.Checked;
				entry.NoBackground = this.noBackgroundCheckBox.Checked;
				this.hilightListBox.Items.Add(entry);

				// Select the newly created item
				this.currentGroup.HilightEntryList.Add(entry);
				this.hilightListBox.SelectedItem = entry;
			}
		}
Beispiel #7
0
        /// <summary>
        /// Builds a list of HilightMatchEntry objects. A HilightMatchEntry spans over a region that is painted with the same foreground and
        /// background colors.
        /// All regions which don't match a word-mode entry will be painted with the colors of a default entry (groundEntry). This is either the
        /// first matching non-word-mode highlight entry or a black-on-white default (if no matching entry was found).
        /// </summary>
        /// <param name="matchList">List of all highlight matches for the current cell</param>
        /// <param name="groundEntry">The entry that is used as the default.</param>
        /// <returns>List of HilightMatchEntry objects. The list spans over the whole cell and contains color infos for every substring.</returns>
        private static IList <HilightMatchEntry> MergeHighlightMatchEntries(IList <HilightMatchEntry> matchList, HilightMatchEntry groundEntry)
        {
            // Fill an area with lenth of whole text with a default hilight entry
            HilightEntry[] entryArray = new HilightEntry[groundEntry.Length];
            for (int i = 0; i < entryArray.Length; ++i)
            {
                entryArray[i] = groundEntry.HilightEntry;
            }

            // "overpaint" with all matching word match enries
            // Non-word-mode matches will not overpaint because they use the groundEntry
            foreach (HilightMatchEntry me in matchList)
            {
                int endPos = me.StartPos + me.Length;
                for (int i = me.StartPos; i < endPos; ++i)
                {
                    if (me.HilightEntry.IsWordMatch)
                    {
                        entryArray[i] = me.HilightEntry;
                    }
                    //else
                    //{
                    //    //entryArray[i].ForegroundColor = me.HilightEntry.ForegroundColor;
                    //}
                }
            }

            // collect areas with same hilight entry and build new highlight match entries for it
            IList <HilightMatchEntry> mergedList = new List <HilightMatchEntry>();

            if (entryArray.Length > 0)
            {
                HilightEntry currentEntry = entryArray[0];
                int          lastStartPos = 0;
                int          pos          = 0;
                for (; pos < entryArray.Length; ++pos)
                {
                    if (entryArray[pos] != currentEntry)
                    {
                        HilightMatchEntry me = new HilightMatchEntry();
                        me.StartPos     = lastStartPos;
                        me.Length       = pos - lastStartPos;
                        me.HilightEntry = currentEntry;
                        mergedList.Add(me);
                        currentEntry = entryArray[pos];
                        lastStartPos = pos;
                    }
                }
                HilightMatchEntry me2 = new HilightMatchEntry();
                me2.StartPos     = lastStartPos;
                me2.Length       = pos - lastStartPos;
                me2.HilightEntry = currentEntry;
                mergedList.Add(me2);
            }
            return(mergedList);
        }
Beispiel #8
0
        private void hilightListBox_DrawItem(object sender, DrawItemEventArgs e)
        {
            e.DrawBackground();
            if (e.Index >= 0)
            {
                HilightEntry entry     = (HilightEntry)this.hilightListBox.Items[e.Index];
                Rectangle    rectangle = new Rectangle(0, e.Bounds.Top, e.Bounds.Width, e.Bounds.Height);

                if ((e.State & DrawItemState.Selected) != DrawItemState.Selected)
                {
                    e.Graphics.FillRectangle(new SolidBrush(entry.BackgroundColor), rectangle);
                }

                e.Graphics.DrawString(entry.SearchText, e.Font, new SolidBrush(entry.ForegroundColor),
                                      new PointF(rectangle.Left, rectangle.Top));

                e.DrawFocusRectangle();
            }
        }
Beispiel #9
0
        public static void CellPainting(ILogPaintContext logPaintCtx, DataGridView gridView, int rowIndex,
                                        DataGridViewCellPaintingEventArgs e)
        {
            if (rowIndex < 0 || e.ColumnIndex < 0)
            {
                e.Handled = false;
                return;
            }
            ILogLine line = logPaintCtx.GetLogLine(rowIndex);

            if (line != null)
            {
                HilightEntry entry = logPaintCtx.FindHighlightEntry(line, true);
                e.Graphics.SetClip(e.CellBounds);
                if ((e.State & DataGridViewElementStates.Selected) == DataGridViewElementStates.Selected)
                {
                    Color backColor = e.CellStyle.SelectionBackColor;
                    Brush brush;
                    if (gridView.Focused)
                    {
                        brush = new SolidBrush(e.CellStyle.SelectionBackColor);
                    }
                    else
                    {
                        Color color = Color.FromArgb(255, 170, 170, 170);
                        brush = new SolidBrush(color);
                    }
                    e.Graphics.FillRectangle(brush, e.CellBounds);
                    brush.Dispose();
                }
                else
                {
                    Color bgColor = Color.White;
                    if (!DebugOptions.disableWordHighlight)
                    {
                        if (entry != null)
                        {
                            bgColor = entry.BackgroundColor;
                        }
                    }
                    else
                    {
                        if (entry != null)
                        {
                            bgColor = entry.BackgroundColor;
                        }
                    }
                    e.CellStyle.BackColor = bgColor;
                    e.PaintBackground(e.ClipBounds, false);
                }

                if (DebugOptions.disableWordHighlight)
                {
                    e.PaintContent(e.CellBounds);
                }
                else
                {
                    PaintCell(logPaintCtx, e, gridView, false, entry);
                }

                if (e.ColumnIndex == 0)
                {
                    Entities.Bookmark bookmark = logPaintCtx.GetBookmarkForLine(rowIndex);
                    if (bookmark != null)
                    {
                        Rectangle r; // = new Rectangle(e.CellBounds.Left + 2, e.CellBounds.Top + 2, 6, 6);
                        r = e.CellBounds;
                        r.Inflate(-2, -2);
                        Brush brush = new SolidBrush(logPaintCtx.BookmarkColor);
                        e.Graphics.FillRectangle(brush, r);
                        brush.Dispose();
                        if (bookmark.Text.Length > 0)
                        {
                            StringFormat format = new StringFormat();
                            format.LineAlignment = StringAlignment.Center;
                            format.Alignment     = StringAlignment.Center;
                            Brush brush2 = new SolidBrush(Color.FromArgb(255, 190, 100, 0));
                            Font  font   = logPaintCtx.MonospacedFont;
                            e.Graphics.DrawString("i", font, brush2, new RectangleF(r.Left, r.Top, r.Width, r.Height),
                                                  format);
                            brush2.Dispose();
                        }
                    }
                }

                e.Paint(e.CellBounds, DataGridViewPaintParts.Border);
                e.Handled = true;
            }
        }
Beispiel #10
0
        private static void PaintHighlightedCell(ILogPaintContext logPaintCtx, DataGridViewCellPaintingEventArgs e, DataGridView gridView, bool noBackgroundFill, HilightEntry groundEntry)
        {
            object value = e.Value ?? string.Empty;

            IList <HilightMatchEntry> matchList = logPaintCtx.FindHighlightMatches(value as ILogLine);

            // too many entries per line seem to cause problems with the GDI
            while (matchList.Count > 50)
            {
                matchList.RemoveAt(50);
            }

            if (value is Column column)
            {
                if (string.IsNullOrEmpty(column.FullValue) == false)
                {
                    HilightMatchEntry hme = new HilightMatchEntry();
                    hme.StartPos     = 0;
                    hme.Length       = column.FullValue.Length;
                    hme.HilightEntry = new HilightEntry(column.FullValue, groundEntry?.ForegroundColor ?? Color.FromKnownColor(KnownColor.Black), groundEntry?.BackgroundColor ?? Color.Empty, false);
                    matchList        = MergeHighlightMatchEntries(matchList, hme);
                }
            }

            int        leftPad      = e.CellStyle.Padding.Left;
            RectangleF rect         = new RectangleF(e.CellBounds.Left + leftPad, e.CellBounds.Top, e.CellBounds.Width, e.CellBounds.Height);
            Rectangle  borderWidths = BorderWidths(e.AdvancedBorderStyle);
            Rectangle  valBounds    = e.CellBounds;

            valBounds.Offset(borderWidths.X, borderWidths.Y);
            valBounds.Width  -= borderWidths.Right;
            valBounds.Height -= borderWidths.Bottom;
            if (e.CellStyle.Padding != Padding.Empty)
            {
                valBounds.Offset(e.CellStyle.Padding.Left, e.CellStyle.Padding.Top);
                valBounds.Width  -= e.CellStyle.Padding.Horizontal;
                valBounds.Height -= e.CellStyle.Padding.Vertical;
            }


            TextFormatFlags flags =
                TextFormatFlags.Left
                | TextFormatFlags.SingleLine
                | TextFormatFlags.NoPrefix
                | TextFormatFlags.PreserveGraphicsClipping
                | TextFormatFlags.NoPadding
                | TextFormatFlags.VerticalCenter
                | TextFormatFlags.TextBoxControl;

            //          | TextFormatFlags.VerticalCenter
            //          | TextFormatFlags.TextBoxControl
            //          TextFormatFlags.SingleLine
            //TextRenderer.DrawText(e.Graphics, e.Value as String, e.CellStyle.Font, valBounds, Color.FromKnownColor(KnownColor.Black), flags);

            Point wordPos      = valBounds.Location;
            Size  proposedSize = new Size(valBounds.Width, valBounds.Height);

            Rectangle r = gridView.GetCellDisplayRectangle(e.ColumnIndex, e.RowIndex, true);

            e.Graphics.SetClip(e.CellBounds);

            foreach (HilightMatchEntry matchEntry in matchList)
            {
                Font font = matchEntry != null && matchEntry.HilightEntry.IsBold
                    ? logPaintCtx.BoldFont
                    : logPaintCtx.NormalFont;

                Brush bgBrush = matchEntry.HilightEntry.BackgroundColor != Color.Empty
                    ? new SolidBrush(matchEntry.HilightEntry.BackgroundColor)
                    : null;

                string matchWord = string.Empty;
                if (value is Column again)
                {
                    if (string.IsNullOrEmpty(again.FullValue) == false)
                    {
                        matchWord = again.FullValue.Substring(matchEntry.StartPos, matchEntry.Length);
                    }
                }

                Size wordSize = TextRenderer.MeasureText(e.Graphics, matchWord, font, proposedSize, flags);
                wordSize.Height = e.CellBounds.Height;
                Rectangle wordRect = new Rectangle(wordPos, wordSize);

                Color foreColor = matchEntry.HilightEntry.ForegroundColor;
                if ((e.State & DataGridViewElementStates.Selected) != DataGridViewElementStates.Selected)
                {
                    if (!noBackgroundFill && bgBrush != null && !matchEntry.HilightEntry.NoBackground)
                    {
                        e.Graphics.FillRectangle(bgBrush, wordRect);
                    }
                }
                else
                {
                    if (foreColor.Equals(Color.Black))
                    {
                        foreColor = Color.White;
                    }
                }
                TextRenderer.DrawText(e.Graphics, matchWord, font, wordRect, foreColor, flags);

                wordPos.Offset(wordSize.Width, 0);
                bgBrush?.Dispose();
            }
        }
Beispiel #11
0
 private static void PaintCell(ILogPaintContext logPaintCtx, DataGridViewCellPaintingEventArgs e, DataGridView gridView, bool noBackgroundFill, HilightEntry groundEntry)
 {
     PaintHighlightedCell(logPaintCtx, e, gridView, noBackgroundFill, groundEntry);
 }