public void CanConvertFrom ()
		{
			var tc = XamlLanguage.Type.TypeConverter.ConverterInstance;
			Assert.IsFalse (tc.CanConvertFrom (null, typeof (string)), "#1");
			Assert.IsFalse (tc.CanConvertFrom (null, typeof (Type)), "#2");
			Assert.IsFalse (tc.CanConvertFrom (null, typeof (Type)), "#3");
			Assert.IsTrue (tc.CanConvertFrom (null, typeof (InstanceDescriptor)), "#4");

			var idc = new TypeDescriptorContext () {Instance = "x:Int32", Service = new XamlTypeResolver ()}; // gives no difference ...
			Assert.IsFalse (tc.CanConvertFrom (idc, typeof (string)), "#5");
			Assert.IsFalse (tc.CanConvertFrom (idc, typeof (Type)), "#6");
			Assert.IsFalse (tc.CanConvertFrom (idc, typeof (TypeExtension)), "#7");
		}
 private LineInfo ProcessTaskItem(DesignerActionList list, DesignerActionItem item)
 {
     Line line = null;
     if (item is DesignerActionMethodItem)
     {
         line = new MethodLine(this._serviceProvider, this);
     }
     else if (item is DesignerActionPropertyItem)
     {
         DesignerActionPropertyItem item2 = (DesignerActionPropertyItem) item;
         PropertyDescriptor propDesc = TypeDescriptor.GetProperties(list)[item2.MemberName];
         if (propDesc == null)
         {
             throw new InvalidOperationException(System.Design.SR.GetString("DesignerActionPanel_CouldNotFindProperty", new object[] { item2.MemberName, list.GetType().FullName }));
         }
         TypeDescriptorContext context = new TypeDescriptorContext(this._serviceProvider, propDesc, list);
         UITypeEditor editor = (UITypeEditor) propDesc.GetEditor(typeof(UITypeEditor));
         bool standardValuesSupported = propDesc.Converter.GetStandardValuesSupported(context);
         if (editor == null)
         {
             if (propDesc.PropertyType == typeof(bool))
             {
                 if (IsReadOnlyProperty(propDesc))
                 {
                     line = new TextBoxPropertyLine(this._serviceProvider, this);
                 }
                 else
                 {
                     line = new CheckBoxPropertyLine(this._serviceProvider, this);
                 }
             }
             else if (standardValuesSupported)
             {
                 line = new EditorPropertyLine(this._serviceProvider, this);
             }
             else
             {
                 line = new TextBoxPropertyLine(this._serviceProvider, this);
             }
         }
         else
         {
             line = new EditorPropertyLine(this._serviceProvider, this);
         }
     }
     else
     {
         if (!(item is DesignerActionTextItem))
         {
             return null;
         }
         if (item is DesignerActionHeaderItem)
         {
             line = new HeaderLine(this._serviceProvider, this);
         }
         else
         {
             line = new TextLine(this._serviceProvider, this);
         }
     }
     return new LineInfo(list, item, line);
 }
 public override bool GetPaintValueSupported(ITypeDescriptorContext context)
 {
     ITypeDescriptorContext wrappedContext = new TypeDescriptorContext(context, actualInstance);
     return uiTypeEditor.GetPaintValueSupported(wrappedContext);
 }
 public override UITypeEditorEditStyle GetEditStyle(ITypeDescriptorContext context)
 {
     ITypeDescriptorContext wrappedContext = new TypeDescriptorContext(context, actualInstance);
     return uiTypeEditor.GetEditStyle(wrappedContext);
 }
 public override object EditValue(ITypeDescriptorContext context,
                                  IServiceProvider provider,
                                  object value)
 {
     ITypeDescriptorContext wrappedContext = new TypeDescriptorContext(context, actualInstance);
     return uiTypeEditor.EditValue(wrappedContext, provider, value);
 }
 public override bool IsValid(ITypeDescriptorContext context,
                              object value)
 {
     ITypeDescriptorContext wrappedContext = new TypeDescriptorContext(context, actualInstance);
     return actualTypeConverter.IsValid(wrappedContext, value);
 }
 public override bool GetStandardValuesSupported(ITypeDescriptorContext context)
 {
     ITypeDescriptorContext wrappedContext = new TypeDescriptorContext(context, actualInstance);
     return actualTypeConverter.GetStandardValuesSupported(wrappedContext);
 }
 public override StandardValuesCollection GetStandardValues(ITypeDescriptorContext context)
 {
     ITypeDescriptorContext wrappedContext = new TypeDescriptorContext(context, actualInstance);
     return actualTypeConverter.GetStandardValues(wrappedContext);
 }
 public override object ConvertTo(ITypeDescriptorContext context,
                                  CultureInfo culture,
                                  object value,
                                  Type destinationType)
 {
     ITypeDescriptorContext wrappedContext = new TypeDescriptorContext(context, actualInstance);
     return actualTypeConverter.ConvertTo(wrappedContext, culture, value, destinationType);
 }
 public override bool CanConvertTo(ITypeDescriptorContext context,
                                   Type destinationType)
 {
     ITypeDescriptorContext wrappedContext = new TypeDescriptorContext(context, actualInstance);
     return actualTypeConverter.CanConvertTo(wrappedContext, destinationType);
 }
 public override bool CanConvertFrom(ITypeDescriptorContext context,
                                     Type sourceType)
 {
     ITypeDescriptorContext wrappedContext = new TypeDescriptorContext(context, actualInstance);
     return actualTypeConverter.CanConvertFrom(wrappedContext, sourceType);
 }
Example #12
0
        private void SetupControl()
        {
            var editorType = EditorType.Default;

            this.context = GetTypeDescriptorContext(ValueProperty);
            if (this.context != null)
            {
                this.typeEditor = (UITypeEditor)this.context.PropertyDescriptor.GetEditor(typeof(UITypeEditor));
                if (this.typeEditor != null && this.typeEditor.GetEditStyle(null) != UITypeEditorEditStyle.DropDown)
                {
                    editorType = EditorType.TypeEditor;
                }
                else if (this.context.PropertyDescriptor.Converter.GetStandardValuesSupported())
                {
                    editorType = EditorType.StandardValues;
                }
            }

            this.SetValue(EditorTypePropertyKey, editorType);
        }