Hi There
I'm creating an application which hosts the window forms designer using the DesignSurface Class
When I place a Control on to the designSurface all the adornments for that control show up apart from the SmartTag button.
I'm just wondering, do I need to create my own implementation of the smart tag panel
and
If so, am I right in thinking that I just need to create my own SmartTag Adorner (with relevant glyph and behavior) and add that to the behaviorService provided by the IDesignerhost (I've tried this method and It seems to work)
Thanks
Trev

Smart Tag Display On Design Surface
MollyBos -- MSFT
Hi,
Looks to me like you are missing a couple of steps. Here are my comments from above:
Create a DesignerOptions object. Set DesignerOptions.UseSmartTag to true. Get the DesignerOptionsService, and call DesignerOptionsService.CreateOptionCollection with the DesignerOptions object.
Try that and let me know how it goes.
slo7h
Thanks to the excellant suggestions here I too have smart tags displaying - but that then leads to a couple of other issues:
1) The default background appears to be the same as that of the form so you get the effect almost of the text 'floating' which looks wierd. I note that in VS2005 the tags appear to have different backgrounds anyone know how this is done
2) Although I can open/close the tags using the glyph if I have a tag open and then select another component on the form the tag stays open. In VS2005 selecting a new component automatically closes the open tag - agian how is this done
TIA
Graham
casali-andrea
I've tried your suggestion on designsurface without any problem. But my question is how to turn the smarttag on the custom implemented designerhost, specifically the MSKB 2004 sample. Could you please kindly try it out
Thanks.
Alan
netnav
The SmartTag gets its colors via the IUIService if available, and if not, uses some built-in default colors.
The IUIService in turns calls the IVsUIShell service and gets the color through the GetVSSysColorEx method.
Hope that helps.
Martin
jonathan seale
I think the Snaplines and so forth are activated by default, try something like this:
class MyDesignerOptionService : DesignerOptionService
{
public MyDesignerOptionService()
: base()
{
}
/// <summary>
/// Populates an option collection with the settings for the DesignSurface.
/// </summary>
/// <param name="options"></param>
protected override void PopulateOptionCollection(DesignerOptionCollection options)
{
if (options.Parent == null)
{
DesignerOptions opt = new DesignerOptions();
opt.UseSmartTags = true;
opt.UseSnapLines = true;
opt.SnapToGrid = true;
opt.ShowGrid = true;
opt.ObjectBoundSmartTagAutoShow = true;
DesignerOptionCollection wfdc = this.CreateOptionCollection(options, "WindowsFormsDesigner", null);
DesignerOptionCollection wfdgc = this.CreateOptionCollection(wfdc, "General", opt);
}
}
}
The options must be at the right place in the options tree, so "/WindowsFormsDesigner/General".
I added this OptionsService to my DesignSurface like this:
this.designerOptionService = new MyDesignerOptionService();
this.ServiceContainer.AddService(typeof(DesignerOptionService), this.designerOptionService);
Hope that works for you
SimonQ
Graham (or anybody else)
did you manage to solve the background color problem
I have also got the smart tags displaying but could not find out how to display them in vs style
George102ci
Hi,
can you please share some information about how you made the SmartTag appear in the DesignSurface
I host a DesignSurface and it works fine with my custom Toolbox, MenuCommandService and so forth, but I did not yet manage to get SmartTags to appear in any way...
AtleH
Hi Martin,
I've implemented a custom designerhost following the MSKB article. But I cannot get the smarttag to work. I've added the designeroptionservice to the deisgnerhost as below:
----------------------------------------------------------------------------------
DesignerOptionService dos = new System.Windows.Forms.Design.WindowsFormsDesignerOptionService();
dos.Options.Properties.Find("UseSmartTags", true).SetValue(dos, true);
serviceContainer.AddService(typeof(DesignerOptionService), dos);
//serviceContainer is the hosting service container.
----------------------------------------------------------------------------------
It seems to me that the designerhost has to implement some other things to enable the designeroptionservice. The new designsurface class has a default designerhost implementation, which can display smarttag correctly. Could some MVPs or form designer gurus please show me the path
Thank you very much in advance!
Alan
Dana Ballinger
Hi,
Create a DesignerOptions object. Set DesignerOptions.UseSmartTag to true. Get the DesignerOptionsService, and call DesignerOptionsService.CreateOptionCollection with the DesignerOptions object.
Dave Bettin
Thanks for the pointers Martin
I got it working, however I had to create my own implementation of the DesignerOptionService to Add the Options.
Is this correct
The documentation for the designSurface class suggests that I should have this service available to me already!
I found the following link very useful, it also highlights a "feature" of the design surface which still exists in the DesignSurface in the RTM Build.
http://lab.msdn.microsoft.com/ProductFeedback/viewFeedback.aspx feedbackid=71e75114-7334-427d-86d3-61c9742c346a
Qadian
Thanks, that did it...
I thought I had do set a flag directly on the surface or implement a DesignerAction(Something)Service.
lapo3399
Martin,
Thanks for the kind reply. I did implement the steps as you described. The below is my DesignerOptions and DesignerOptionService implementation (benefited from this forum)
using System;
using System.Windows.Forms;
using System.Windows.Forms.Design;
using System.ComponentModel.Design;
namespace MyDesignerHost
{
public class AtlasOptionServiceProvider : IServiceProvider
{
private DesignerOptionService dos = new OptionService();
#region IServiceProvider Members
public object GetService(Type serviceType)
{
if (serviceType == typeof(DesignerOptionService))
{
return dos;
}
return null;
}
#endregion
private class OptionService : DesignerOptionService
{
protected override void PopulateOptionCollection(DesignerOptionCollection options)
{
if (options.Parent == null)
{
base.CreateOptionCollection(options, "DesignerOptions", new Options());
}
}
}
private class Options : DesignerOptions
{
public override bool UseSmartTags
{
get
{
return true;
}
}
public override bool UseSnapLines
{
get
{
return false;
}
}
public override bool ShowGrid
{
get
{
return true;
}
}
}
}
}
Then I added the service in the designerhost implementation:
AtlasOptionServiceProvider aosp = new AtlasOptionServiceProvider();
designerOptionService = aosp.GetService(typeof(DesignerOptionService)) as DesignerOptionService;
serviceContainer.AddService(typeof(DesignerOptionService), designerOptionService);
The smartTag feature still cannot be activated. However, the snapline and showgrid feature works as expected. I have no clue at this point what went wrong. Could you please shed more light on this, preferably with some code demo. Thank you!
Alan