本文整理汇总了C#中ITypeDescriptorContext类的典型用法代码示例。如果您正苦于以下问题:C# ITypeDescriptorContext类的具体用法?C# ITypeDescriptorContext怎么用?C# ITypeDescriptorContext使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
ITypeDescriptorContext类属于命名空间,在下文中一共展示了ITypeDescriptorContext类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ConvertFrom
public override object ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, object value) {
if (value is string) {
var vs = ((string)value).Split(new[] { ", " }, StringSplitOptions.RemoveEmptyEntries);
return vs.Select(v => v.Trim('"')).ToList();
}
return base.ConvertFrom(context, culture, value);
}
示例2: ConvertTo
public override object ConvertTo (ITypeDescriptorContext context, CultureInfo culture, object value, Type destinationType)
{
if (context == null)
return null;
var p = context.GetService (typeof (IXamlNameProvider)) as IXamlNameProvider;
return p != null ? p.GetName (value) : null;
}
示例3: ConvertTo
public override object ConvertTo(ITypeDescriptorContext context, CultureInfo culture, object value, Type destinationType) {
if (destinationType == typeof(string)) {
return "EmbeddedMailObject";
}
return base.ConvertTo(context, culture, value, destinationType);
}
示例4: EditValue
public override object EditValue(ITypeDescriptorContext context, System.IServiceProvider provider, object value)
{
if (context != null && provider != null)
{
edSvc = (IWindowsFormsEditorService)provider.GetService(typeof(IWindowsFormsEditorService));
if (edSvc != null)
{
lb = new ListBox();
lb.Items.AddRange(new object[] {
"Sunday",
"Monday",
"Tuesday",
"Wednesday",
"Thursday",
"Friday",
"Saturday"});
lb.SelectedIndexChanged += new System.EventHandler(lb_SelectedIndexChanged);
edSvc.DropDownControl(lb);
}
return text;
}
return base.EditValue(context, provider, value);
}
示例5: CanConvertTo
public override bool CanConvertTo (ITypeDescriptorContext context, Type destinationType)
{
if (context == null)
return false;
var p = context.GetService (typeof (IXamlNameProvider)) as IXamlNameProvider;
return p != null && destinationType == typeof (string);
}
示例6: ConvertTo
// Overrides the ConvertTo method of TypeConverter.
public override object ConvertTo(ITypeDescriptorContext context, CultureInfo culture, object value, Type destinationType) {
var v = value as IEnumerable<String>;
if (destinationType == typeof(string)) {
return string.Join(", ", v.Select(AddQuotes).ToArray());
}
return base.ConvertTo(context, culture, value, destinationType);
}
示例7: EditValue
/// <summary>
/// <para>Edits the specified object's value using the editor style indicated by <see cref="GetEditStyle"/>. This should be a <see cref="DpapiSettings"/> object.</para>
/// </summary>
/// <param name="context"><para>An <see cref="ITypeDescriptorContext"/> that can be used to gain additional context information.</para></param>
/// <param name="provider"><para>An <see cref="IServiceProvider"/> that this editor can use to obtain services.</para></param>
/// <param name="value"><para>The object to edit. This should be a <see cref="Password"/> object.</para></param>
/// <returns><para>The new value of the <see cref="Password"/> object.</para></returns>
/// <seealso cref="UITypeEditor.EditValue(ITypeDescriptorContext, IServiceProvider, object)"/>
public override object EditValue(ITypeDescriptorContext context, IServiceProvider provider, object value)
{
Debug.Assert(provider != null, "No service provider; we cannot edit the value");
if (provider != null)
{
IWindowsFormsEditorService edSvc = (IWindowsFormsEditorService)provider.GetService(typeof(IWindowsFormsEditorService));
Debug.Assert(edSvc != null, "No editor service; we cannot edit the value");
if (edSvc != null)
{
IWindowsFormsEditorService service =(IWindowsFormsEditorService)provider.GetService(typeof(IWindowsFormsEditorService));
using (PasswordEditorUI dialog = new PasswordEditorUI())
{
if (DialogResult.OK == service.ShowDialog(dialog))
{
return new Password(dialog.Password);
}
else
{
return value;
}
}
}
}
return value;
}
示例8: ConvertTo
/// <summary>
/// Converts a <see cref="Color"/> instance to the specified <paramref name="destinationType"/>
/// </summary>
/// <param name="context">Context of the conversion</param>
/// <param name="culture">Culture to use for the conversion</param>
/// <param name="value"><see cref="Color"/> value to convert</param>
/// <param name="destinationType">Type to convert the <paramref name="value"/> to</param>
/// <returns>An object of type <paramref name="destinationType"/> converted from <paramref name="value"/></returns>
public override object ConvertTo (ITypeDescriptorContext context, CultureInfo culture, object value, Type destinationType)
{
if (destinationType == typeof (string)) {
return ((Color)value).ToHex ();
}
return base.ConvertTo (context, culture, value, destinationType);
}
示例9: CanConvertTo
public override bool CanConvertTo(ITypeDescriptorContext context, Type destinationType)
{
if (destinationType == typeof(char) || destinationType == typeof(string))
return true;
return false;
}
示例10: CanConvertTo
///<summary>Standard type converter method</summary>
public override bool CanConvertTo(ITypeDescriptorContext context, System.Type destinationType) {
if (destinationType == typeof(AtomSource) || destinationType == typeof(AtomFeed)) {
return true;
}
return base.CanConvertTo(context, destinationType);
}
示例11: EditValue
public override object EditValue(ITypeDescriptorContext context, IServiceProvider provider, object value)
{
IDesignerHost service = (IDesignerHost)context.GetService(typeof(IDesignerHost));
DeluxeTree component = (DeluxeTree)context.Instance;
((DeluxeTreeItemsDesigner)service.GetDesigner(component)).InvokeMenuItemCollectionEditor();
return value;
}
示例12: ConvertFrom
public override object ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, object value) {
if (value is string) {
return new TypeAndName((string) value);
}
return base.ConvertFrom(context, culture, value);
}
示例13: ConvertFrom
public override object ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, object value)
{
var valueString = value as string;
if (valueString != null)
{
var values = valueString.Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
var l = new List<Brush>();
foreach (var s in values.Select(x => x.Trim()))
{
if (Regex.IsMatch(s, @"^#[0-9a-fA-F]+"))
{
l.Add(
new SolidColorBrush((Color) (ColorConverter.ConvertFromString(s) ??
Colors.Transparent)));
continue;
}
l.Add(new ImageBrush(new BitmapImage(new Uri(s, UriKind.Relative))));
}
return l.ToArray();
}
return base.ConvertFrom(context, culture, value);
}
示例14: GetProperties
/// <summary>
/// Returns the property descriptors for this instance.
/// </summary>
public override PropertyDescriptorCollection GetProperties(ITypeDescriptorContext context, object value, Attribute[] attributes)
{
Guard.NotNull(() => context, context);
var descriptors = base.GetProperties(context, value, attributes).Cast<PropertyDescriptor>();
// Remove descriptors for the data type of this property (string)
descriptors = descriptors.Where(descriptor => descriptor.ComponentType != typeof(string));
// Get the model element being described
var selection = context.Instance;
ModelElement mel = selection as ModelElement;
var pel = selection as PresentationElement;
if (pel != null)
{
mel = pel.Subject;
}
var element = ExtensionElement.GetExtension<ArtifactExtension>(mel);
if (element != null)
{
// Copy descriptors from owner (make Browsable)
var descriptor1 = new DelegatingPropertyDescriptor(element, TypedDescriptor.CreateProperty(element, extension => extension.OnArtifactActivation),
new BrowsableAttribute(true), new DefaultValueAttribute(element.GetPropertyDefaultValue<ArtifactExtension, ArtifactActivatedAction>(e => e.OnArtifactActivation)));
var descriptor2 = new DelegatingPropertyDescriptor(element, TypedDescriptor.CreateProperty(element, extension => extension.OnArtifactDeletion),
new BrowsableAttribute(true), new DefaultValueAttribute(element.GetPropertyDefaultValue<ArtifactExtension, ArtifactDeletedAction>(e => e.OnArtifactDeletion)));
descriptors = descriptors.Concat(new[] { descriptor1, descriptor2 });
}
return new PropertyDescriptorCollection(descriptors.ToArray());
}
示例15: GetStandardValues
public override StandardValuesCollection GetStandardValues(ITypeDescriptorContext context)
{
if (charSets == null)
PopulateList(context.Instance);
StandardValuesCollection coll = new StandardValuesCollection(charSets);
return coll;
}