예제 #1
0
        private ListViewItem.ListViewSubItem MakeSubItem(string text, ColorPair subItemColors)
        {
            ListViewItem.ListViewSubItem result = new ListViewItem.ListViewSubItem();
            result.Text = text;

            if (subItemColors != null)
            {
                result.BackColor = subItemColors.BackColor;
                result.ForeColor = subItemColors.ForeColor;
            }

            return(result);
        }
예제 #2
0
        static ColorUtil()
        {
            TraceLevelPalette[TraceLevel.Fatal]   = new ColorPair(Color.Red, Color.White);
            TraceLevelPalette[TraceLevel.Error]   = new ColorPair(Color.Red, Color.AntiqueWhite);
            TraceLevelPalette[TraceLevel.Warn]    = new ColorPair(Color.Orange);
            TraceLevelPalette[TraceLevel.Info]    = new ColorPair(Color.LightBlue);
            TraceLevelPalette[TraceLevel.Debug]   = new ColorPair(Color.LightGreen);
            TraceLevelPalette[TraceLevel.Verbose] = new ColorPair(Color.Gainsboro);

            // List of ARGB colors generated with the Palette form.
            int[] rgb = new int[] { -16711936, -129, -65281, -8421505, -8388609, -8388737, -32897, /*-16711809,*/ -16711681, -8421377, -8388864, -65409, -33024, -32769, -256, -16744449, -65536 };
            Palette = new ColorPair[rgb.Length];
            for (int i = 0; i < rgb.Length; ++i)
            {
                Palette[i] = new ColorPair(Color.FromArgb(rgb[i]));
            }
        }
예제 #3
0
        // Make a ListViewItem from a Row object.
        public ViewItem MakeItem(Row previousRow)
        {
            ColorPair itemColors = null;

            if (Settings.Default.ColoringEnabled)
            {
                switch (ColorUtil.RowColorDriver)
                {
                case ColorDriver.Custom:
                    ColoringRule rule = MatchColoringRule();
                    if (rule != null)
                    {
                        itemColors = new ColorPair(rule.BackColor, rule.TextColor);
                    }
                    break;

                case ColorDriver.TraceLevels:
                    itemColors = Rec.TLevel.RowColors;
                    break;

                case ColorDriver.ThreadIDs:
                    itemColors = Rec.Thread.RowColors;
                    break;

                case ColorDriver.Sessions:
                    itemColors = Rec.Session.RowColors;
                    break;

                case ColorDriver.ThreadNames:
                    itemColors = Rec.ThreadName.RowColors;
                    break;

                case ColorDriver.Loggers:
                    itemColors = Rec.Logger.RowColors;
                    break;

                case ColorDriver.Methods:
                    if (Rec.MethodName.RowColors != null)
                    {
                        itemColors = Rec.MethodName.RowColors;
                    }
                    else if (ColorRulesDialog.ColorCalledMethods)
                    {
                        Record caller = Rec.Caller;

                        while (caller != null)
                        {
                            if (caller.MethodName.RowColors != null)
                            {
                                itemColors = caller.MethodName.RowColors;
                                break;
                            }

                            caller = caller.Caller;
                        }
                    }

                    break;
                }
            }

            ViewItem item = new ViewItem(MakeSubItems(previousRow, itemColors), ImageIndex);

            item.UseItemStyleForSubItems = false;

            if (itemColors != null)
            {
                item.BColor = itemColors.BackColor;
                item.FColor = itemColors.ForeColor;
            }

            item.Row = this;
            item.Tag = this;

            return(item);
        }
예제 #4
0
        private ListViewItem.ListViewSubItem[] MakeSubItems(Row previousRow, ColorPair itemColors)
        {
            MainForm mainForm = MainForm.TheMainForm;
            var      result   = new ListViewItem.ListViewSubItem[mainForm.TheListView.Columns.Count];

            // If a column has been removed from the ListView,
            // its ListView property will be null.

            if (mainForm.headerText.ListView != null)
            {
                result[mainForm.headerText.Index] = MakeSubItem(Rec.GetLine(Line, Settings.Default.IndentChar, Settings.Default.IndentAmount, true), itemColors);
            }

            if (mainForm.headerSession.ListView != null)
            {
                result[mainForm.headerSession.Index] = MakeSubItem(Rec.Session.Name, Rec.Session.SubitemColors ?? itemColors);
            }

            if (mainForm.headerLine.ListView != null)
            {
                result[mainForm.headerLine.Index] = MakeSubItem(Rec.GetRecordNum(Line), itemColors);
            }

            if (mainForm.headerLevel.ListView != null)
            {
                result[mainForm.headerLevel.Index] = MakeSubItem(Rec.TLevel.Name, Rec.TLevel.SubitemColors ?? itemColors);
            }

            if (mainForm.headerLogger.ListView != null)
            {
                result[mainForm.headerLogger.Index] = MakeSubItem(Rec.Logger.Name, Rec.Logger.SubitemColors ?? itemColors);
            }

            if (mainForm.headerThreadId.ListView != null)
            {
                result[mainForm.headerThreadId.Index] = MakeSubItem(Rec.ThreadId.ToString(), Rec.Thread.SubitemColors ?? itemColors);
            }

            if (mainForm.headerThreadName.ListView != null)
            {
                result[mainForm.headerThreadName.Index] = MakeSubItem(Rec.ThreadName.Name, Rec.ThreadName.SubitemColors ?? itemColors);
            }

            if (mainForm.headerMethod.ListView != null)
            {
                result[mainForm.headerMethod.Index] = MakeSubItem(Rec.MethodName.Name, Rec.GetMethodColor() ?? itemColors);
            }

            if (mainForm.headerTime.ListView != null)
            {
                if (previousRow == null || previousRow.Rec.Time != this.Rec.Time || Settings.Default.DuplicateTimes)
                {
                    if (Settings.Default.RelativeTime)
                    {
                        result[mainForm.headerTime.Index] = MakeSubItem(Program.FormatTimeSpan(Rec.Time - MainForm.ZeroTime), itemColors);
                    }
                    else if (Settings.Default.UseCustomTimeFormat)
                    {
                        result[mainForm.headerTime.Index] = MakeSubItem(Rec.Time.ToLocalTime().ToString(Settings.Default.CustomTimeFormat), itemColors);
                    }
                    else
                    {
                        result[mainForm.headerTime.Index] = MakeSubItem(Rec.Time.ToLocalTime().ToString(@"MM/dd/yy HH:mm:ss.fff"), itemColors);
                    }
                }
                else
                {
                    result[mainForm.headerTime.Index] = MakeSubItem(string.Empty, itemColors);
                }
            }

            return(result);
        }