Catel.LogAnalyzer.Converters.OutputTypeConverter.Convert C# (CSharp) Метод

Convert() защищенный Метод

Modifies the source data before passing it to the target for display in the UI.
protected Convert ( object value, Type targetType, object parameter ) : object
value object The source data being passed to the target.
targetType System.Type The of data expected by the target dependency property.
parameter object An optional parameter to be used in the converter logic.
Результат object
        protected override object Convert(object value, Type targetType, object parameter)
        {
            Image image = null;

            if (!(value is LogEvent))
            {
                return image;
            }

            var logEvent = (LogEvent)value;
            switch (logEvent)
            {
                case LogEvent.Debug:
                    if (_debugImage == null)
                    {
                        _debugImage = new BitmapImage(new Uri(string.Format("/{0};component/Resources/Images/Debug.png", AssemblyName), UriKind.RelativeOrAbsolute));
                    }

                    image = new Image { Source = _debugImage };
                    break;

                case LogEvent.Error:
                    if (_errorImage == null)
                    {
                        _errorImage = new BitmapImage(new Uri(string.Format("/{0};component/Resources/Images/Error.png", AssemblyName), UriKind.RelativeOrAbsolute));
                    }

                    image = new Image {Source = _errorImage};
                    break;

                case LogEvent.Info:
                    if (_infoImage == null)
                    {
                        _infoImage = new BitmapImage(new Uri(string.Format("/{0};component/Resources/Images/Info.png", AssemblyName), UriKind.RelativeOrAbsolute));
                    }

                    image = new Image { Source = _infoImage };
                    break;

                case LogEvent.Warning:
                    if (_warningImage == null)
                    {
                        _warningImage = new BitmapImage(new Uri(string.Format("/{0};component/Resources/Images/Warning.png", AssemblyName), UriKind.RelativeOrAbsolute));
                    }

                    image = new Image {Source = _warningImage};
                    break;
            }

            if (image != null)
            {
                //// Or hardcoded on 16 x 16?
                //Binding b = new Binding("Width");
                //b.Source = image.Source;
                //image.SetBinding(Image.MaxWidthProperty, b);
                image.MaxWidth = 16;

                //b = new Binding("Height");
                //b.Source = image.Source;
                //image.SetBinding(Image.MaxHeightProperty, b);
                image.MaxHeight = 16;
            }

            return image;
        }
    }
OutputTypeConverter