Example #1
0
        /// <summary>
        ///     Factory method for creating the appropriate drop-down control based on the given property descriptor
        /// </summary>
        /// <param name="propertyDescriptor">
        ///     Property descriptor used to create the drop-down.  If the property descriptor supports a UITypeEditor,
        ///     that will be used first.  Otherwise, the type converter will be used.
        /// </param>
        /// <param name="instance">Instance of the object being edited.</param>
        /// <param name="editStyle">
        ///     In the case that a UITypeEditor is used, controls the style of drop-down created.  This
        ///     parameter is not used in the TypeConverter case.
        /// </param>
        /// <returns>A DropDownControl instance if the given property descriptor supports it, null otherwise.</returns>
        internal static TypeEditorHost CreateTypeEditorHost(
            PropertyDescriptor propertyDescriptor, object instance, TypeEditorHostEditControlStyle editControlStyle)
        {
            TypeEditorHost dropDown = null;

            if (propertyDescriptor != null)
            {
                var uiTypeEditor = propertyDescriptor.GetEditor(typeof(UITypeEditor)) as UITypeEditor;
                if (uiTypeEditor != null) // UITypeEditor case
                {
                    dropDown = new TreeGridDesignerInPlaceEditDropDown(uiTypeEditor, propertyDescriptor, instance, editControlStyle);
                }
                else
                {
                    var converter = propertyDescriptor.Converter;
                    if (converter != null &&
                        converter.GetStandardValuesSupported(null))    // converter case
                    {
                        dropDown = new TreeGridDesignerInPlaceEditCombo(converter, propertyDescriptor, instance, editControlStyle);
                    }
                }
            }

            return(dropDown);
        }
Example #2
0
		/// <summary>
		/// Factory method for creating the appropriate drop-down control based on the given property descriptor.
		/// If the property descriptor supports a UITypeEditor, a TypeEditorHost will be created with that editor.
		/// If not, and the TypeConverver attached to the PropertyDescriptor supports standard values, a
		/// TypeEditorHostListBox will be created with this TypeConverter.
		/// </summary>
		/// <param name="propertyDescriptor">A property descriptor describing the property being set</param>
		/// <param name="instance">The object instance being edited</param>
		/// <param name="editControlStyle">The type of control to show in the edit area.</param>
		/// <returns>A TypeEditorHost instance if the given property descriptor supports it, null otherwise.</returns>
		public static new TypeEditorHost Create(PropertyDescriptor propertyDescriptor, object instance, TypeEditorHostEditControlStyle editControlStyle)
		{
			TypeEditorHost host = null;
			if (propertyDescriptor != null)
			{
				UITypeEditor editor = propertyDescriptor.GetEditor(typeof(UITypeEditor)) as UITypeEditor;
				if (editor != null)
				{
					return new OnScreenTypeEditorHost(editor, propertyDescriptor, instance, editControlStyle);
				}
				TypeConverter typeConverter = propertyDescriptor.Converter;
				if ((typeConverter != null) && typeConverter.GetStandardValuesSupported(null))
				{
					host = new OnScreenTypeEditorHostListBox(typeConverter, propertyDescriptor, instance, editControlStyle);
				}
			}
			return host;
		}
Example #3
0
 /// <summary>
 ///     Creates a new drop-down control to display the given UITypeEditor
 /// </summary>
 protected internal TreeGridDesignerInPlaceEditDropDown(
     UITypeEditor editor, PropertyDescriptor propertyDescriptor, object instance, TypeEditorHostEditControlStyle editStyle)
     : base(editor, propertyDescriptor, instance, editStyle)
 {
 }
        protected internal TypeEditorHostListBox(
            TypeConverter typeConverter, PropertyDescriptor propertyDescriptor, object instance,
            TypeEditorHostEditControlStyle editControlStyle)
            :
                base(UITypeEditorEditStyle.DropDown, propertyDescriptor, instance, editControlStyle)
        {
            _typeConverter = typeConverter;

            // UNDONE: currently, this class only supports exclusive values.

            // create the list box
            _listBox = new ListBox { BorderStyle = BorderStyle.None };
            _listBox.MouseUp += OnDropDownMouseUp;

            _listBox.BackColor = VSColorTheme.GetThemedColor(EnvironmentColors.ComboBoxBackgroundColorKey);
            _listBox.ForeColor = VSColorTheme.GetThemedColor(EnvironmentColors.ComboBoxTextColorKey);

            if (_typeConverter != null
                && _typeConverter.GetStandardValuesSupported(this))
            {
                // populate it with values from the type converter
                foreach (var value in _typeConverter.GetStandardValues())
                {
                    _listBox.Items.Add(value);
                }
            }

            // set list box as the drop control
            SetComponent(_listBox);
        }
        /// <summary>
        ///     Factory method for creating the appropriate drop-down control based on the given property descriptor.
        ///     If the property descriptor supports a UITypeEditor, a TypeEditorHost will be created with that editor.
        ///     If not, and the TypeConverver attached to the PropertyDescriptor supports standard values, a
        ///     TypeEditorHostListBox will be created with this TypeConverter.
        /// </summary>
        /// <param name="propertyDescriptor">A property descriptor describing the property being set</param>
        /// <param name="instance">The object instance being edited</param>
        /// <param name="editControlStyle">The type of control to show in the edit area.</param>
        /// <returns>A TypeEditorHost instance if the given property descriptor supports it, null otherwise.</returns>
        public static TypeEditorHost Create(
            PropertyDescriptor propertyDescriptor, object instance, TypeEditorHostEditControlStyle editControlStyle)
        {
            TypeEditorHost dropDown = null;

            if (propertyDescriptor != null)
            {
                var uiTypeEditor = propertyDescriptor.GetEditor(typeof(UITypeEditor)) as UITypeEditor;
                if (uiTypeEditor != null) // UITypeEditor case
                {
                    dropDown = new TypeEditorHost(uiTypeEditor, propertyDescriptor, instance, editControlStyle);
                }
                else
                {
                    var converter = propertyDescriptor.Converter;
                    if (converter != null
                        && converter.GetStandardValuesSupported(null)) // converter case
                    {
                        dropDown = new TypeEditorHostListBox(converter, propertyDescriptor, instance, editControlStyle);
                    }
                }
            }

            return dropDown;
        }
        /// <summary>
        ///     Creates a new TypeEditorHost with the given editStyle.
        /// </summary>
        /// <param name="editStyle">Style of editor to create.</param>
        /// ///
        /// <param name="propertyDescriptor">Property descriptor used to get/set values in the drop-down.</param>
        /// <param name="instance">Instance object used to get/set values in the drop-down.</param>
        /// <param name="editControlStyle">Style of text box to create.</param>
        protected TypeEditorHost(
            UITypeEditorEditStyle editStyle, PropertyDescriptor propertyDescriptor, object instance,
            TypeEditorHostEditControlStyle editControlStyle)
        {
            if (m_inPlaceHelper != null)
            {
                return; // only allow initialization once
            }

            _editStyle = editStyle;
            _editControlStyle = editControlStyle;
            CurrentPropertyDescriptor = propertyDescriptor;
            CurrentInstance = instance;

            // initialize VirtualTree in-place edit stuff
            m_inPlaceHelper = VirtualTreeControl.CreateInPlaceControlHelper(this);
            m_inPlaceHelper.Flags &= ~VirtualTreeInPlaceControls.SizeToText; // size to full item width by default

            // set accessible role of the parent control of the text box/button to combo box, 
            // so accessibility clients have a clue they're dealing with a combo box-like control.
            AccessibleRole = AccessibleRole.ComboBox;
            TabStop = false;
        }
 /// <summary>
 ///     Creates a new TypeEditorHost to display the given UITypeEditor
 /// </summary>
 /// <param name="editor">The UITypeEditor instance to host</param>
 /// <param name="editControlStyle">The type of control to show in the edit area.</param>
 /// <param name="propertyDescriptor">Property descriptor used to get/set values in the drop-down.</param>
 /// <param name="instance">Instance object used to get/set values in the drop-down.</param>
 protected TypeEditorHost(
     UITypeEditor editor, PropertyDescriptor propertyDescriptor, object instance, TypeEditorHostEditControlStyle editControlStyle)
     :
         this(UITypeEditorEditStyle.DropDown, propertyDescriptor, instance, editControlStyle)
 {
     _uiTypeEditor = editor;
     if (editor != null)
     {
         _editStyle = editor.GetEditStyle(this);
     }
 }
Example #8
0
        /// <summary>
        /// Factory method for creating the appropriate drop-down control based on the given property descriptor.
        /// If the property descriptor supports a UITypeEditor, a TypeEditorHost will be created with that editor.
        /// If not, and the TypeConverver attached to the PropertyDescriptor supports standard values, a
        /// TypeEditorHostListBox will be created with this TypeConverter.
        /// </summary>
        /// <param name="propertyDescriptor">A property descriptor describing the property being set</param>
        /// <param name="instance">The object instance being edited</param>
        /// <param name="editControlStyle">The type of control to show in the edit area.</param>
        /// <returns>A TypeEditorHost instance if the given property descriptor supports it, null otherwise.</returns>
        public static new TypeEditorHost Create(PropertyDescriptor propertyDescriptor, object instance, TypeEditorHostEditControlStyle editControlStyle)
        {
            TypeEditorHost host = null;

            if (propertyDescriptor != null)
            {
                UITypeEditor editor = propertyDescriptor.GetEditor(typeof(UITypeEditor)) as UITypeEditor;
                if (editor != null)
                {
                    return(new OnScreenTypeEditorHost(editor, propertyDescriptor, instance, editControlStyle));
                }
                TypeConverter typeConverter = propertyDescriptor.Converter;
                if ((typeConverter != null) && typeConverter.GetStandardValuesSupported(null))
                {
                    host = new OnScreenTypeEditorHostListBox(typeConverter, propertyDescriptor, instance, editControlStyle);
                }
            }
            return(host);
        }
Example #9
0
 /// <summary>
 /// Creates a new drop-down list to display the given type converter.
 /// The type converter must support a standard values collection.
 /// </summary>
 /// <param name="typeConverter">The TypeConverter instance to retrieve drop-down values from</param>
 /// <param name="propertyDescriptor">Property descriptor used to get/set values in the drop-down.</param>
 /// <param name="instance">Instance object used to get/set values in the drop-down.</param>
 /// <param name="editControlStyle">Edit control style.</param>
 public OnScreenTypeEditorHostListBox(TypeConverter typeConverter, PropertyDescriptor propertyDescriptor, object instance, TypeEditorHostEditControlStyle editControlStyle)
     : base(typeConverter, propertyDescriptor, instance, editControlStyle)
 {
 }
Example #10
0
 /// <summary>
 /// Creates a new TypeEditorHost with the given editStyle.
 /// </summary>
 /// <param name="editStyle">Style of editor to create.</param>
 /// /// <param name="propertyDescriptor">Property descriptor used to get/set values in the drop-down.</param>
 /// <param name="instance">Instance object used to get/set values in the drop-down.</param>
 /// <param name="editControlStyle">Style of text box to create.</param>
 protected OnScreenTypeEditorHost(UITypeEditorEditStyle editStyle, PropertyDescriptor propertyDescriptor, object instance, TypeEditorHostEditControlStyle editControlStyle)
     : base(editStyle, propertyDescriptor, instance, editControlStyle)
 {
 }
 /// <summary>
 ///     Creates a new drop-down list to display the given type converter.
 ///     The type converter must support a standard values collection.
 /// </summary>
 internal TreeGridDesignerInPlaceEditCombo(
     TypeConverter converter, PropertyDescriptor propertyDescriptor, object instance, TypeEditorHostEditControlStyle editStyle)
     : base(converter, propertyDescriptor, instance, editStyle)
 {
 }
 /// <summary>
 ///     Creates a new drop-down control to display the given UITypeEditor
 /// </summary>
 protected internal TreeGridDesignerInPlaceEditDropDown(
     UITypeEditor editor, PropertyDescriptor propertyDescriptor, object instance, TypeEditorHostEditControlStyle editStyle)
     : base(editor, propertyDescriptor, instance, editStyle)
 {
 }
 /// <summary>
 ///     Creates a new drop-down list to display the given type converter.
 ///     The type converter must support a standard values collection.
 /// </summary>
 internal TreeGridDesignerInPlaceEditCombo(
     TypeConverter converter, PropertyDescriptor propertyDescriptor, object instance, TypeEditorHostEditControlStyle editStyle)
     : base(converter, propertyDescriptor, instance, editStyle)
 {
 }
Example #14
0
			/// <summary>
			/// Creates a new drop-down list to display the given type converter.
			/// The type converter must support a standard values collection.
			/// </summary>
			/// <param name="typeConverter">The TypeConverter instance to retrieve drop-down values from</param>
			/// <param name="propertyDescriptor">Property descriptor used to get/set values in the drop-down.</param>
			/// <param name="instance">Instance object used to get/set values in the drop-down.</param>
			/// <param name="editControlStyle">Edit control style.</param>
			public OnScreenTypeEditorHostListBox(TypeConverter typeConverter, PropertyDescriptor propertyDescriptor, object instance, TypeEditorHostEditControlStyle editControlStyle)
				: base(typeConverter, propertyDescriptor, instance, editControlStyle)
			{
			}
Example #15
0
		/// <summary>
		/// Creates a new TypeEditorHost with the given editStyle.
		/// </summary>
		/// <param name="editStyle">Style of editor to create.</param>
		/// /// <param name="propertyDescriptor">Property descriptor used to get/set values in the drop-down.</param>
		/// <param name="instance">Instance object used to get/set values in the drop-down.</param>
		/// <param name="editControlStyle">Style of text box to create.</param>
		protected OnScreenTypeEditorHost(UITypeEditorEditStyle editStyle, PropertyDescriptor propertyDescriptor, object instance, TypeEditorHostEditControlStyle editControlStyle)
			: base(editStyle, propertyDescriptor, instance, editControlStyle)
		{
		}
        /// <summary>
        ///     Factory method for creating the appropriate drop-down control based on the given property descriptor
        /// </summary>
        /// <param name="propertyDescriptor">
        ///     Property descriptor used to create the drop-down.  If the property descriptor supports a UITypeEditor,
        ///     that will be used first.  Otherwise, the type converter will be used.
        /// </param>
        /// <param name="instance">Instance of the object being edited.</param>
        /// <param name="editStyle">
        ///     In the case that a UITypeEditor is used, controls the style of drop-down created.  This
        ///     parameter is not used in the TypeConverter case.
        /// </param>
        /// <returns>A DropDownControl instance if the given property descriptor supports it, null otherwise.</returns>
        internal static TypeEditorHost CreateTypeEditorHost(
            PropertyDescriptor propertyDescriptor, object instance, TypeEditorHostEditControlStyle editControlStyle)
        {
            TypeEditorHost dropDown = null;

            if (propertyDescriptor != null)
            {
                var uiTypeEditor = propertyDescriptor.GetEditor(typeof(UITypeEditor)) as UITypeEditor;
                if (uiTypeEditor != null) // UITypeEditor case
                {
                    dropDown = new TreeGridDesignerInPlaceEditDropDown(uiTypeEditor, propertyDescriptor, instance, editControlStyle);
                }
                else
                {
                    var converter = propertyDescriptor.Converter;
                    if (converter != null
                        && converter.GetStandardValuesSupported(null)) // converter case
                    {
                        dropDown = new TreeGridDesignerInPlaceEditCombo(converter, propertyDescriptor, instance, editControlStyle);
                    }
                }
            }

            return dropDown;
        }