Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
branch: master
Fetching contributors…

Cannot retrieve contributors at this time

file 54 lines (43 sloc) 1.646 kb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Data;
using System.Globalization;
using System.Windows.Media;
using MediaBrowser.Library.Logging;
using System.Windows.Controls;


namespace LogViewer {
    class RowHighlighter : IValueConverter {
        #region IValueConverter Members

        public object Convert(object value, Type targetType, object parameter, CultureInfo culture) {

            Brush brush = Brushes.Black;

            var item = (ListViewItem)value;
            ListView listView = ItemsControl.ItemsControlFromItemContainer(item) as ListView;
            int index = listView.ItemContainerGenerator.IndexFromContainer(item);

            if (!(listView.Items[index] is LogRow)) return Brushes.Black;

            var row = (LogRow)listView.Items[index];

            switch (row.Severity) {
                case LogSeverity.Verbose:
                    brush = Brushes.Gray;
                    break;
                case LogSeverity.Info:
                    brush = Brushes.Black;
                    break;
                case LogSeverity.Warning:
                    brush = Brushes.Blue;
                    break;
                case LogSeverity.Error:
                    brush = Brushes.Red;
                    break;
                default:
                    break;
            }

            return brush;
        }

        public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) {
            return null;
        }

        #endregion
    }
}
Something went wrong with that request. Please try again.