This message was discovered on microsoft.public.dotnet.framework.windowsforms.designtime.
| Christian Benien |
Hi,
I have a custom designer which is deriving from ComponentDesigner. I would like to have a property similar to the 'Modifiers' property in the 'Design' category in ControlDesigner that can change the access modifiers of my designed objects from private to public or protected.
Regards, Chris
|
|
| |
| |
| Joe Stegman |
"Modifiers" will be present on all IComponents that are not root components. Are you not seeing it on your component?
"Christian Benien" <Click here to reveal e-mail address> wrote in message news:Click here to reveal e-mail address... [Original message clipped]
|
|
| |
| |
| Christian Benien |
No, the "Modifiers" property is not visible. I checked the ShapeDesigner sample from gotdotnet.com, but there's no "Modifiers" on any shape in design mode either.
"Joe Stegman" <Click here to reveal e-mail address> wrote in message news:<OGJuBUGdCHA.3752@tkmsftngp08>... [Original message clipped]
|
|
| |
|
| |
| Christian Benien |
No, the "Modifiers" property is not visible on my IComponents. I even checked the ShapeDesigner sample from gotdotnet.com, but there isn't any Modifiers property on any shape either.
"Joe Stegman" <Click here to reveal e-mail address> wrote in message news:<OGJuBUGdCHA.3752@tkmsftngp08>... [Original message clipped]
|
|
| |
|
| |
| Christian Benien |
No, the "Modifiers" property is not visible on my IComponents. I even checked the ShapeDesigner sample from gotdotnet.com, but there isn't any Modifiers property on any shape either.
"Joe Stegman" <Click here to reveal e-mail address> wrote in message news:<OGJuBUGdCHA.3752@tkmsftngp08>... [Original message clipped]
|
|
| |
| |
| Joe Stegman |
Modifiers is offered up through the root designer as an extender provider. The Shape example has it's own root designer - so you don't see the Modifiers.
"Christian Benien" <Click here to reveal e-mail address> wrote in message news:Click here to reveal e-mail address... [Original message clipped]
|
|
| |
| |
| Christian Benien |
Sorry for the duplicates...
Is there any way I can implement this behaviour in my root designer as well? Maybe you have an example or a pointer into the right direction :) I saw this example for extender providers on MSDN, but somehow I have to tell the IDesignerHost to serialize the field declarations as "public".
Cheers, Chris
|
|
| |
| |
| Joe Stegman |
The serializer is looking for a property named "Modifiers" of type System.CodeDom.MemberAttributes. You could offer up this property as an extended property and will get the same behavior. This is the minimum to get something working - however, this will still require fit an finish (to not serialize "Modifiers" to code, MemberAttributes should have a type converter, etc).
There are language specific type converters for MemberAttributes (since public,private, etc is language specific) so if you want the equivalent "Modifiers" drop down list as shown in VS, you'll need to add your own type converter to the "Modifiers" property that delegates requests to the language specific type converter (via the CodeDOM provider):
TypeConverter modifierConverter = null;
if (context != null) { // context is an ITypeDescriptorContext CodeDomProvider provider = (CodeDomProvider)context.GetService(typeof(CodeDomProvider)); if (provider != null) { modifierConverter = provider.GetConverter(typeof(MemberAttributes)); } }
if (modifierConverter == null) { modifierConverter = TypeDescriptor.GetConverter(typeof(MemberAttributes)); }
// Delegate all TypeConverter calls to modifierConverter...
"Christian Benien" <Click here to reveal e-mail address> wrote in message news:Click here to reveal e-mail address... [Original message clipped]
|
|
| |
| |
| Christian Benien |
Thank you, this works great! Nice solution,
Cheers, Christian
|
|
| |
|
|
|
|
|
|
|
|
|
|