using System;
using System.Collections;
using System.ComponentModel;
using System.ComponentModel.Design.Serialization;
using System.Globalization;
using System.Reflection;

namespace TD.SandDock.Rendering
{
	internal class RendererBaseConverter : TypeConverter
	{
		public override bool b(ITypeDescriptorContext A_0, Type A_1)
		{
			if ((object)A_1 == typeof(string))
			{
				return true;
			}
			if ((object)A_1 == typeof(InstanceDescriptor))
			{
				return true;
			}
			return base.CanConvertTo(A_0, A_1);
		}

		public override object a(ITypeDescriptorContext A_0, CultureInfo A_1, object A_2, Type A_3)
		{
			if ((object)A_3 == typeof(string))
			{
				if (A_2 is string)
				{
					return A_2;
				}
				if (A_2 is RendererBase)
				{
					return A_2.ToString();
				}
				return "(default)";
			}
			if ((object)A_3 == typeof(InstanceDescriptor) && A_2 is RendererBase)
			{
				ConstructorInfo constructor = A_2.GetType().GetConstructor(Type.EmptyTypes);
				object[] arguments = new object[0];
				return new InstanceDescriptor(constructor, arguments, isComplete: true);
			}
			return base.ConvertTo(A_0, A_1, A_2, A_3);
		}

		public override object a(ITypeDescriptorContext A_0, CultureInfo A_1, object A_2)
		{
			if (A_2 is string)
			{
				return (string)A_2 switch
				{
					"Everett" => new EverettRenderer(), 
					"Office 2003" => new Office2003Renderer(), 
					"Whidbey" => new WhidbeyRenderer(), 
					_ => null, 
				};
			}
			return base.ConvertFrom(A_0, A_1, A_2);
		}

		public override bool a(ITypeDescriptorContext A_0, Type A_1)
		{
			if ((object)A_1 == typeof(string))
			{
				return true;
			}
			return base.CanConvertFrom(A_0, A_1);
		}

		public override bool b(ITypeDescriptorContext A_0)
		{
			return true;
		}

		public override bool c(ITypeDescriptorContext A_0)
		{
			return true;
		}

		public override StandardValuesCollection a(ITypeDescriptorContext A_0)
		{
			ArrayList arrayList = new ArrayList();
			if (A_0 != null && A_0.Instance is DockContainer)
			{
				arrayList.Add("(default)");
			}
			arrayList.Add("Everett");
			arrayList.Add("Office 2003");
			arrayList.Add("Whidbey");
			return new StandardValuesCollection(arrayList);
		}
	}
}
