本文整理汇总了C#中System.ComponentModel.PropertyDescriptor.GetEditor方法的典型用法代码示例。如果您正苦于以下问题:C# PropertyDescriptor.GetEditor方法的具体用法?C# PropertyDescriptor.GetEditor怎么用?C# PropertyDescriptor.GetEditor使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.ComponentModel.PropertyDescriptor
的用法示例。
在下文中一共展示了PropertyDescriptor.GetEditor方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetEditor
public PropertyEditorCell GetEditor (PropertyDescriptor pd)
{
PropertyEditorCell cell = pd.GetEditor (typeof(PropertyEditorCell)) as PropertyEditorCell;
if (cell != null)
return cell;
Type editorType = GetEditorType (pd);
if (editorType == null)
return Default;
if (typeof(IPropertyEditor).IsAssignableFrom (editorType)) {
if (!typeof(Gtk.Widget).IsAssignableFrom (editorType))
throw new Exception ("The property editor '" + editorType + "' must be a Gtk Widget");
return Default;
}
cell = cellCache [editorType] as PropertyEditorCell;
if (cell != null)
return cell;
if (!typeof(PropertyEditorCell).IsAssignableFrom (editorType))
throw new Exception ("The property editor '" + editorType + "' must be a subclass of Stetic.PropertyEditorCell or implement Stetic.IPropertyEditor");
cell = (PropertyEditorCell) Activator.CreateInstance (editorType);
cellCache [editorType] = cell;
return cell;
}
示例2: Create
/// <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;
}
示例3: GetUITypeEditor
/// <summary>
/// Gets a UI type editor for the given property descriptor and context</summary>
/// <param name="descriptor">Property descriptor</param>
/// <param name="context">Type descriptor context</param>
/// <returns>UI type editor for the given property descriptor and context</returns>
public static UITypeEditor GetUITypeEditor(
PropertyDescriptor descriptor,
ITypeDescriptorContext context)
{
UITypeEditor editor = descriptor.GetEditor(typeof(UITypeEditor)) as UITypeEditor;
if (editor == null)
{
if (StandardValuesUIEditor.CanCreateStandardValues(descriptor, context))
{
editor = new StandardValuesUIEditor(descriptor);
}
else
{
Type type = descriptor.PropertyType;
editor = TypeDescriptor.GetEditor(type, typeof(UITypeEditor)) as UITypeEditor;
}
}
return editor;
}
示例4: EditItems
/// <summary>
/// Invokes the editor for the items of the designed ImageListView.
/// </summary>
public void EditItems()
{
// IComponentChangeService is used to pass change notifications to the designer
IComponentChangeService ccs = (IComponentChangeService)GetService(typeof(IComponentChangeService));
// Get the collection editor
itemProperty = GetPropertyByName("Items");
UITypeEditor editor = (UITypeEditor)itemProperty.GetEditor(typeof(UITypeEditor));
object value = imageListView.Items;
// Notify the designers of the change
if (ccs != null)
ccs.OnComponentChanging(imageListView, itemProperty);
// Edit the value
value = editor.EditValue(this, this, value);
imageListView.Items = (ImageListView.ImageListViewItemCollection)value;
// Notify the designers of the change
if (ccs != null)
ccs.OnComponentChanged(imageListView, itemProperty, null, null);
designerService.Refresh(Component);
}
示例5: Create
/// <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;
}
示例6: EditColumns
/// <summary>
/// Invokes the editor for the columns of the designed ImageListView.
/// </summary>
public void EditColumns()
{
// TODO: Column editing cannot be undone in the designer.
property = TypeDescriptor.GetProperties(imageListView)["Columns"];
UITypeEditor editor = (UITypeEditor)property.GetEditor(typeof(UITypeEditor));
object value = imageListView.Columns;// property.GetValue(imageListView);
value = editor.EditValue(this, this, value);
SetProperty("Columns", value);
designerService.Refresh(Component);
}
示例7: CreateTypeEditorHost
/// <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;
}
示例8: EditRows
/// <summary>
/// EditRows
/// </summary>
private void EditRows()
{
_PropertyDescriptor = TypeDescriptor.GetProperties(_SuperGrid.PrimaryGrid)["Rows"];
UITypeEditor editor = (UITypeEditor)_PropertyDescriptor.GetEditor(typeof(UITypeEditor));
if (editor != null)
editor.EditValue(this, this, _SuperGrid.PrimaryGrid.Rows);
}
示例9: CreateEditorControl
internal static Control CreateEditorControl(PropertyDescriptor descriptor)
{
if (descriptor == null)
throw new ArgumentNullException("descriptor");
var propertyType = descriptor.PropertyType;
object editor = null;
try
{
editor = descriptor.GetEditor(typeof(IEditorPartField));
}
catch (Exception e)
{
Logger.WriteException(e);
}
var propName = descriptor.Name;
if (editor != null)
{
var partField = editor as IEditorPartField;
if (partField != null)
{
partField.Options = GetEditorOptionsAttribute(descriptor.Attributes);
partField.TitleContainerCssClass = "sn-iu-label";
partField.TitleCssClass = "sn-iu-title";
partField.DescriptionCssClass = "sn-iu-desc";
partField.ControlWrapperCssClass = "sn-iu-control";
partField.Title = GetDisplayName(descriptor);
partField.Description = GetDescription(descriptor);
partField.EditorPartCssClass = "sn-inputunit ui-helper-clearfix sn-custom-editorpart-text sn-editorpart-" + propName;
partField.PropertyName = propName;
if (propertyType == typeof (bool))
partField.EditorPartCssClass = "sn-inputunit ui-helper-clearfix sn-custom-editorpart-boolean sn-editorpart-" + propName;
if (typeof (Enum).IsAssignableFrom(propertyType))
{
// TODO: fill the instance of the EditorPart control with datas. Best solution is extend the IEditorPartField interface with Fill method
}
var result = partField as Control;
result.ID = "Custom" + propName;
return result;
}
}
if (propertyType == typeof (bool))
{
var checkBox = new CheckBoxEditorPartField();
checkBox.ID = "CheckBox" + propName;
checkBox.Options = GetEditorOptionsAttribute(descriptor.Attributes);
checkBox.EditorPartCssClass = "sn-inputunit ui-helper-clearfix sn-custom-editorpart-boolean sn-editorpart-" + propName;
checkBox.Title = GetDisplayName(descriptor);
checkBox.Description = GetDescription(descriptor);
checkBox.TitleContainerCssClass = "sn-iu-label";
checkBox.TitleCssClass = "sn-iu-title";
checkBox.DescriptionCssClass = "sn-iu-desc";
checkBox.ControlWrapperCssClass = "sn-iu-control";
checkBox.PropertyName = propName;
return checkBox;
}
if (typeof (Enum).IsAssignableFrom(propertyType))
{
ICollection standardValues = descriptor.Converter.GetStandardValues();
if (standardValues != null)
{
var list = new DropDownPartField();
list.ID = "DropDown" + propName;
list.Options = GetEditorOptionsAttribute(descriptor.Attributes);
list.EditorPartCssClass = "sn-inputunit ui-helper-clearfix sn-custom-editorpart-enum sn-editorpart-" + propName;
list.Title = GetDisplayName(descriptor);
list.Description = GetDescription(descriptor);
list.TitleContainerCssClass = "sn-iu-label";
list.TitleCssClass = "sn-iu-title";
list.DescriptionCssClass = "sn-iu-desc";
list.ControlWrapperCssClass = "sn-iu-control";
list.PropertyName = propName;
foreach (object value in standardValues)
{
var resourceKey = String.Concat("Enum-", propName, "-", value.ToString());
var text = SenseNetResourceManager.Current.GetStringOrNull("PortletFramework", resourceKey) as string;
if (string.IsNullOrEmpty(text))
text = descriptor.Converter.ConvertToString(value);
list.Items.Add(new ListItem(text, value.ToString()));
}
return list;
}
return null;
}
var textBox = new TextEditorPartField();
textBox.ID = "TextBox" + propName;
textBox.Options = GetEditorOptionsAttribute(descriptor.Attributes);
textBox.EditorPartCssClass = "sn-inputunit ui-helper-clearfix sn-custom-editorpart-text sn-editorpart-" + propName;
textBox.Title = GetDisplayName(descriptor);
textBox.Description = GetDescription(descriptor);
textBox.TitleContainerCssClass = "sn-iu-label";
//.........这里部分代码省略.........