I'm porting a wizard library from v1.1/VS2003 to v2/VS2005.
Part of the library involves custom designers for components. These involve the following pattern:
[
Designer(typeof(WizardRootDesigner), typeof(IRootDesigner)),
]
public class Wizard : System.ComponentModel.Component, IPageInfoCollection
{
//...implementation details
}
public class WizardRootDesigner : ComponentDocumentDesigner, IRootDesigner
{
//...other stuff
public object GetView(System.ComponentModel.Design.ViewTechnology technology)
{
if( theView == null ) theView = new WizardDesignerViewHost();
return theView;
}
public System.ComponentModel.Design.ViewTechnology[] SupportedTechnologies
{
get
{
return new ViewTechnology[] { ViewTechnology.Default };
}
}
}
However, neither GetView() nor SupportedTechnologies ever gets called (they both were called properly under v1.1/VS2003). This
causes problems for my custom designer, since theView never gets initialized under v2/VS2005.
I noticed that NET2 sports a bunch of changes in the area of custom designers (e.g., DesignSurface, DesignSurfaceManager). Has the
v1.1 approach to creating custom designers been obsoleted? What approach should I be using under v2/VS2005?
- Mark
Mark Olbert - 16 Apr 2006 03:15 GMT
I spoke too soon: the changed behavior from v1.1/VS2003 is not that GetView() and SupportedTechnologies don't get called. They just
get called later.
Here's a somewhat more detailed code snippet:
[
Designer(typeof(WizardRootDesigner), typeof(IRootDesigner)),
]
public class Wizard : System.ComponentModel.Component, IPageInfoCollection
{
//...implementation details
}
public class WizardRootDesigner : ComponentDocumentDesigner, IRootDesigner
{
public override void Initialize( IComponent component )
{
base.Initialize(component);
chgSvc = (IComponentChangeService) GetService(typeof(IComponentChangeService));
if( chgSvc != null )
chgSvc.ComponentAdded += new ComponentEventHandler(chgSvc_ComponentAdded);
else isValid = false;
desHost = (IDesignerHost) GetService(typeof(IDesignerHost));
if( desHost != null )
desHost.LoadComplete += new EventHandler(desHost_LoadComplete);
else isValid = false;
if( !isValid )
MessageBox.Show(null, @"The designer interface could not be established.", "User Alert");
}
//...other stuff
public object GetView(System.ComponentModel.Design.ViewTechnology technology)
{
if( theView == null ) theView = new WizardDesignerViewHost();
return theView;
}
public System.ComponentModel.Design.ViewTechnology[] SupportedTechnologies
{
get
{
return new ViewTechnology[] { ViewTechnology.Default };
}
}
private void desHost_LoadComplete(object sender, EventArgs e)
{
isLoading = false;
// theView isn't initialized by this point under v2/VS2005, but it is under v1.1/VS2003
theView.ViewControl = new UserControl();
// ... other stuff
}
}
The changed behavior between v1.1/VS2003 and v2/VS2005 is that the IDesignerHost.LoadComplete event fires earlier under v2/VS2005.
Specifically, it fires before the calls to IRootDesigner.GetView() and IRootDesigner.SupportedTechnologies are called.
Can someone explain to me why this behavior was changed, and where I can find the documentation for any other related changes? I
didn't see anything in the v2 help file.
- Mark
"Gary Chang[MSFT]" - 17 Apr 2006 09:47 GMT
Hi Mark,
This newsgroup focuses on this issue about the usage of Visual Studio IDE.
So I suggest you consult this problem in more appropriate newsgroups, you'd
get better and quicker help there:
microsoft.public.dotnet.framework.windowsforms.designtime
microsoft.public.dotnet.framework.windowsforms.controls
The reason why we recommend posting appropriately is you will get the most
qualified pool of respondents, and other partners who the newsgroups
regularly can either share their knowledge or learn from your interaction
with us. Thank you for your understanding.
Thanks for your understanding.
Best regards,
Gary Chang
Microsoft Online Community Support
==================================================
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.
Mark Olbert - 17 Apr 2006 15:41 GMT
Gary,
I'll repost there. But I'd like to point out that GetView() and SupportedTechnologies lie on the interface between VS and the NET
Framework.
- Mark
"Gary Chang[MSFT]" - 18 Apr 2006 03:48 GMT
I appreciate your understanding, Mark.
Good Luck!
Best regards,
Gary Chang
Microsoft Online Community Support
==================================================
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.