Skip to content

Columnizer

zarunbal edited this page Feb 1, 2020 · 4 revisions

Interface: ILogLineColumnizer

Constraints:

  • The class must end with Columnizer

For some insights in the return Interfaces see

Also some informations #13

Normal

This splits a single line into the defined columns. The columns are displayed in the Grid.

GetColumnCount

Returns number of columns this plugin will return for the given line. The LineCount column is handled by LogExpert and must not considered here.

GetColumnNames

Return names of columns. These are the displayed Grid header values. Values are used from left to right.

GetDescription

Description for this columnizer. This is displayed in the columnizer selection dialog.

GetName

Name for the columnizer. This is displayed in the columnizer selection dialog.

SplitLine

Splits the given lines in the defined columns.

Important this is called from the Gui Thread! So the faster the execution is the faster the line can be displayed

If timeshift is supported you have to consider the Offsets set by SetTimeOffset in your Date/Time columns!

IsTimeShiftImplemented

True if functionality is supported by columnizer

GetTimeOffset

Only needed if TimeShift is supported by columnizer. You can throw a NotImplemented if not supported.

The current stored tiemstamp offset (set by SetTimeOffset())

GetTimeStamp

Only needed if TimeShift is supported by columnizer. You can throw a NotImplemented if not supported.

Return the Timestamp for the given line. Return DateTime.MinValue if there is no valid timestamp.

PushValue

Only needed if TimeShift is supported by columnizer. You can throw a NotImplemented if not supported.

This is called if a user changed a value in a column (edit mode in the LogView). This is used to recalculate the new timestamp offset. Important Only handle this call if the given column is a timestamp column

SetTimeOffset

Only needed if TimeShift is supported by columnizer. You can throw a NotImplemented if not supported.

Sets an offset for displaying values. This value has to be stored and added to the timestamp column returned by SplitLine()

Example

class ExampleColumnizer : ILogLineColumnizer
    {
        public string GetName()
        {
            return "Example Columnizer"; //Some great name so everyone knows from just that whats on
        }

        public string GetDescription()
        {
            return "Just a Example columnizer which adds to every line a [Example]"; //Some text what describes your columnizer
        }

        public int GetColumnCount()
        {
            return 1; //We just return a static value or you could e.g. use the configure interface to define the count
        }

        public string[] GetColumnNames()
        {
            return new string[] {"Example column"};
        }

        public IColumnizedLogLine SplitLine(ILogLineColumnizerCallback callback, ILogLine line)
        {
            ColumnizedLogLine columnizedLogLine = new ColumnizedLogLine();
            columnizedLogLine.LogLine = line; // Add the reference to the LogLine 
            columnizedLogLine.ColumnValues = new IColumn[]
            {
                new Column
                {
                    FullValue = string.Format("[Example] {0}", line.FullLine) , //Here you could call some method or do some other work
                    Parent = columnizedLogLine //Just add the reference to the columnizedLogLine
                }
            };


            return columnizedLogLine;
        }

        public bool IsTimeshiftImplemented()
        {
            return false; //This is an example and we don't support timeshift
        }

        public void SetTimeOffset(int msecOffset)
        {
            throw new NotImplementedException(); //Nothing to do here
        }

        public int GetTimeOffset()
        {
            throw new NotImplementedException();  //Nothing to do here
        }

        public DateTime GetTimestamp(ILogLineColumnizerCallback callback, ILogLine line)
        {
            throw new NotImplementedException(); //Nothing to do here
        }

        public void PushValue(ILogLineColumnizerCallback callback, int column, string value, string oldValue)
        {
 //Nothing to do here
        }
    }