using System;
using System.Globalization;
using System.Windows.Data;

namespace C1DataGrid_Demo2010
{
    public class ProductGroupConverter : IValueConverter
    {
        #region IValueConverter Members

        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            if (value is string)
            {
                string text = ((string)value).Trim();
                if (text.Length > 1)
                {
                    return text.Substring(0, 2).ToUpper();
                }
                return "";
            }
            return value;
        }

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

        #endregion
    }

    public class ProductGroupNameConverter : IValueConverter
    {
        #region IValueConverter Members

        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            if (value is string && targetType.Name == "String")
            {
                switch (value as string)
                {
                    case "AR":
                        return "AR - Adjustable Race";
                    case "BA":
                        return "BA - Bearing Ball";
                    case "BB":
                        return "BB - Bottom Bracket";
                    case "BC":
                        return "BC - Bottle Cage";
                    case "BE":
                        return "BE - Ball Bearing";
                    case "BK":
                        return "BK - Bike";
                    case "BL":
                        return "BL - Blade";
                    case "CA":
                        return "CA - Cycling Cap";
                    case "CB":
                        return "CB - Chainring Bolts";
                    case "CH":
                        return "CH - Chain";
                    case "CL":
                        return "CL - Bike Wash";
                    case "CN":
                        return "CN - Chainring Nut";
                    case "CR":
                        return "CR - Crown Race";
                    case "CS":
                        return "CS - Crankset";
                    case "DC":
                        return "DC - Decal";
                    case "DT":
                        return "DT - Down Tube";
                    case "EC":
                        return "EC - End Caps";
                    case "FB":
                        return "FB - Front Brakes";
                    case "FC":
                        return "FC - Fork Crown";
                    case "FD":
                        return "FD - Front Derailleur";
                    case "FE":
                        return "FE - Fender Set";
                    case "FH":
                        return "FH - Freewheel";
                    case "FK":
                        return "FK - Fork";
                    case "FL":
                        return "FL - Front Derailleur Linkage";
                    case "FR":
                        return "FR - Frame";
                    case "FW":
                        return "FW - Front Wheel";
                    case "GL":
                        return "GL - Gloves";
                    case "GP":
                        return "GP - Guide Pulley";
                    case "GT":
                        return "GT - Grip Tape";
                    case "HB":
                        return "HB - Handlebars";
                    case "HJ":
                        return "HJ - Hex";
                    case "HL":
                        return "HL - Helmet";
                    case "HN":
                        return "HN - Hex Nut";
                    case "HS":
                        return "HS - Headset";
                    case "HT":
                        return "HT - Head Tube";
                    case "HU":
                        return "HU - Hub";
                    case "HY":
                        return "HY - Hydration";
                    case "KW":
                        return "KW - Keyed Washer";
                    case "LE":
                        return "LE - External Lock";
                    case "LI":
                        return "LI - Internal Lock";
                    case "LJ":
                        return "LJ - Logo Jersey";
                    case "LN":
                        return "LN - Lock Nut";
                    case "LO":
                        return "LO - Cable Lock";
                    case "LR":
                        return "LR - Lock Ring";
                    case "LT":
                        return "LT - Lights";
                    case "LW":
                        return "LW - Lock Washer";
                    case "MA":
                        return "MA - Metal Angle";
                    case "MB":
                        return "MB - Metal Bar";
                    case "MP":
                        return "MP - Metal Plate";
                    case "MS":
                        return "MS - Metal Sheet";
                    case "MT":
                        return "MT - Metal Tread Plate";
                    case "NI":
                        return "NI - Nipple";
                    case "PA":
                        return "PA - Panniers";
                    case "PB":
                        return "PB- Pinch Bolt";
                    case "PD":
                        return "PD - Pedal";
                    case "PK":
                        return "PK - Patch kit";
                    case "PU":
                        return "PU - Pump";
                    case "RA":
                        return "RA - Hitch Rack";
                    case "RB":
                        return "RB - Rear Brakes";
                    case "RD":
                        return "RD - Rear Derailleur";
                    case "RC":
                        return "RC - Rear Derailleur Cage";
                    case "RF":
                        return "RF - Reflector";
                    case "RM":
                        return "RM - Rim";
                    case "RW":
                        return "RW - Rear Wheel";
                    case "SA":
                        return "SA - Seat Assembly";
                    case "SB":
                        return "SB - Bib-Shorts";
                    case "SD":
                        return "SD - Spindle";
                    case "SE":
                        return "SE - Seat";
                    case "SH":
                        return "SH - Shorts";
                    case "SJ":
                        return "SJ - Classic Jersey";
                    case "SK":
                        return "SK - Spokes";
                    case "SL":
                        return "SL - Seat Lug";
                    case "SM":
                        return "SM - Stem";
                    case "SO":
                        return "SO - Socks";
                    case "SP":
                        return "SP - Seat Post";
                    case "SR":
                        return "SR - Steerer";
                    case "SS":
                        return "SS - Seat Stays";
                    case "ST":
                        return "ST - Stand";
                    case "TG":
                        return "TG - Tights";
                    case "TI":
                        return "TI - Tires";
                    case "TO":
                        return "TO - Top Tube";
                    case "TP":
                        return "TP - Tension Pulley";
                    case "TT":
                        return "TT - Tire Tube";
                    case "VE":
                        return "VE - Vest";
                    case "WB":
                        return "WB - Water Bottle ";
                }
            }
            return null;
        }

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

        #endregion
    }
}
